[vala] tests: Additional test-cases taken from transform-branch



commit ad9fa2ab57b2bdf81cc594bc6955a0bb46a08bec
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Sun Sep 25 21:29:30 2016 +0200

    tests: Additional test-cases taken from transform-branch

 tests/Makefile.am                   |    2 ++
 tests/asynchronous/yield.vala       |   10 ++++++++++
 tests/control-flow/bug628336.vala   |    8 ++++++++
 tests/dbus/dicts.test               |   13 +++++++++++++
 tests/methods/symbolresolution.vala |    8 ++++++++
 tests/objects/properties.vala       |    8 ++++++++
 tests/structs/structs.vala          |   16 ++++++++++++++++
 7 files changed, 65 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e5c2301..d4f0fc3 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -80,6 +80,7 @@ TESTS = \
        control-flow/nested-conditional.vala \
        control-flow/switch.vala \
        control-flow/sideeffects.vala \
+       control-flow/bug628336.vala \
        control-flow/bug639482.vala \
        control-flow/bug652549.vala \
        control-flow/bug661985.vala \
@@ -203,6 +204,7 @@ TESTS = \
        asynchronous/bug661961.vala \
        asynchronous/bug742621.vala \
        asynchronous/closures.vala \
+       asynchronous/yield.vala \
        dbus/basic-types.test \
        dbus/arrays.test \
        dbus/structs.test \
diff --git a/tests/asynchronous/yield.vala b/tests/asynchronous/yield.vala
new file mode 100644
index 0000000..4c4d53b
--- /dev/null
+++ b/tests/asynchronous/yield.vala
@@ -0,0 +1,10 @@
+async void foo ()
+{
+    while (true) {
+        yield;
+    }
+}
+
+void main () {
+}
+
diff --git a/tests/control-flow/bug628336.vala b/tests/control-flow/bug628336.vala
new file mode 100644
index 0000000..86ac154
--- /dev/null
+++ b/tests/control-flow/bug628336.vala
@@ -0,0 +1,8 @@
+void main () {
+       var foo = new string[]{"bar", "bar"};
+       foreach (string bar in foo) {
+               assert (bar == "bar");
+               SourceFunc f = () => bar == "bar";
+               assert (f ());
+       }
+}
diff --git a/tests/dbus/dicts.test b/tests/dbus/dicts.test
index c67c515..1e7037e 100644
--- a/tests/dbus/dicts.test
+++ b/tests/dbus/dicts.test
@@ -32,6 +32,19 @@ class Test : Object {
        }
 }
 
+namespace TestInterface {
+       [DBus (name = "org.vala.Test.Bar")]
+       public interface Bar : GLib.Object {
+               public abstract HashTable<string, Variant> foo () throws IOError;
+       }
+
+       public class Foo : GLib.DBusProxy, Bar {
+               public HashTable<string, Variant> foo () throws IOError {
+                       return new HashTable<string, Variant> (str_hash, str_equal);
+               }
+       }
+}
+
 MainLoop main_loop;
 
 void client_exit (Pid pid, int status) {
diff --git a/tests/methods/symbolresolution.vala b/tests/methods/symbolresolution.vala
index 90fe97c..ba3beec 100644
--- a/tests/methods/symbolresolution.vala
+++ b/tests/methods/symbolresolution.vala
@@ -9,6 +9,14 @@ public class Class {
                Foo func = () => { foo (); };
                func ();
        }
+
+
+       void active_scope () {
+               foreach (var bar in new string[] {}) {
+               }
+
+               var bar = "bar";
+       }
 }
 
 void main () {
diff --git a/tests/objects/properties.vala b/tests/objects/properties.vala
index b051825..2e2b2ee 100644
--- a/tests/objects/properties.vala
+++ b/tests/objects/properties.vala
@@ -92,6 +92,14 @@ abstract class Maman.Foo : Object {
        public abstract int abstract_base_property { get; set; }
 }
 
+enum FooEnum {
+       FOO
+}
+
+abstract class Maman.EnumDefault {
+       public abstract FooEnum bar { get; default = FooEnum.FOO; }
+}
+
 class Maman.Bar : Foo {
        public int public_property { get; set; default = 3; }
        public override int abstract_base_property { get; set; }
diff --git a/tests/structs/structs.vala b/tests/structs/structs.vala
index e991121..ae4e6f7 100644
--- a/tests/structs/structs.vala
+++ b/tests/structs/structs.vala
@@ -25,6 +25,16 @@ struct StructWithNamedCreationMethod {
        public int field;
 }
 
+
+delegate void Func ();
+
+struct StructWithFunc {
+       int foo;
+
+       public StructWithFunc (Func f) {
+       }
+}
+
 void test_in_parameter (SimpleStruct st) {
        stdout.printf ("test_in_parameter: st.field = %d\n", st.field);
 }
@@ -44,6 +54,12 @@ void test_out_parameter (out SimpleStruct st) {
        st.field = 3;
 }
 
+void test_struct_with_func () {
+       var foes = new StructWithFunc[] {
+               StructWithFunc (() => {})
+       };
+}
+
 void main () {
        stdout.printf ("Structs Test:\n");
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]