summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRico Tzschichholz <ricotz@ubuntu.com>2016-09-25 21:29:30 +0200
committerRico Tzschichholz <ricotz@ubuntu.com>2016-09-25 21:29:30 +0200
commitad9fa2ab57b2bdf81cc594bc6955a0bb46a08bec (patch)
tree2a005ae132456de57139ede055d6cbcc1cdf8915
parent0c35fd2b11ebaa72e78081db344dc59fa0d753ba (diff)
downloadvala-ad9fa2ab57b2bdf81cc594bc6955a0bb46a08bec.tar.gz
tests: Additional test-cases taken from transform-branch
-rw-r--r--tests/Makefile.am2
-rw-r--r--tests/asynchronous/yield.vala10
-rw-r--r--tests/control-flow/bug628336.vala8
-rw-r--r--tests/dbus/dicts.test13
-rw-r--r--tests/methods/symbolresolution.vala8
-rw-r--r--tests/objects/properties.vala8
-rw-r--r--tests/structs/structs.vala16
7 files changed, 65 insertions, 0 deletions
diff --git a/tests/Makefile.am b/tests/Makefile.am
index e5c23018e..d4f0fc3c7 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 000000000..4c4d53b30
--- /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 000000000..86ac154e7
--- /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 c67c515ff..1e7037ed7 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 90fe97c30..ba3beec2e 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 b0518256e..2e2b2ee05 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 e991121cd..ae4e6f734 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");