[vala/staging] tests: Add various regression "codegen" tests to increase coverage
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] tests: Add various regression "codegen" tests to increase coverage
- Date: Tue, 6 Feb 2018 17:05:19 +0000 (UTC)
commit 87020808d89ba4507e410aec615a2985f3b57bf8
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Tue Feb 6 09:01:12 2018 +0100
tests: Add various regression "codegen" tests to increase coverage
tests/Makefile.am | 13 +++++++++++++
tests/asynchronous/bug612641.vala | 10 ++++++++++
tests/asynchronous/bug626053.vala | 8 ++++++++
tests/delegates/bug519949.test | 10 ++++++++++
tests/delegates/bug632017.test | 7 +++++++
tests/delegates/fields.vala | 17 +++++++++++++++++
tests/delegates/wrapper.vala | 18 ++++++++++++++++++
tests/errors/catch-error-code.vala | 16 ++++++++++++++++
tests/methods/bug620673.test | 8 ++++++++
tests/methods/iterator.vala | 14 ++++++++++++++
tests/objects/bug541728.test | 8 ++++++++
tests/objects/bug564011.test | 9 +++++++++
tests/objects/bug564090.test | 13 +++++++++++++
tests/objects/bug574146.test | 8 ++++++++
tests/objects/bug585344.test | 11 +++++++++++
tests/structs/gvalue.vala | 19 +++++++++++++++++++
16 files changed, 189 insertions(+), 0 deletions(-)
---
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 358b586..063c7e8 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -79,6 +79,7 @@ TESTS = \
methods/bug599892.vala \
methods/bug613483.vala \
methods/bug615450.test \
+ methods/bug620673.test \
methods/bug620673.vala \
methods/bug622570.vala \
methods/bug626783.vala \
@@ -200,11 +201,15 @@ TESTS = \
delegates/casting.vala \
delegates/delegates.vala \
delegates/delegates-error.test \
+ delegates/fields.vala \
delegates/reference_transfer.vala \
+ delegates/wrapper.vala \
+ delegates/bug519949.test \
delegates/bug539166.vala \
delegates/bug595610.vala \
delegates/bug595639.vala \
delegates/bug598869.test \
+ delegates/bug632017.test \
delegates/bug638415.vala \
delegates/bug639751.vala \
delegates/bug659778.vala \
@@ -232,7 +237,12 @@ TESTS = \
objects/test-026.vala \
objects/test-029.vala \
objects/test-034.vala \
+ objects/bug541728.test \
+ objects/bug564011.test \
+ objects/bug564090.test \
objects/bug566909.vala \
+ objects/bug574146.test \
+ objects/bug585344.test \
objects/bug587905.test \
objects/bug588203.vala \
objects/bug589928.vala \
@@ -293,6 +303,7 @@ TESTS = \
objects/bug779955.vala \
objects/bug783897.vala \
objects/bug788964.vala \
+ errors/catch-error-code.vala \
errors/errors.vala \
errors/bug567181.vala \
errors/bug579101.vala \
@@ -312,9 +323,11 @@ TESTS = \
asynchronous/bug599568.vala \
asynchronous/bug600827.vala \
asynchronous/bug601558.vala \
+ asynchronous/bug612641.vala \
asynchronous/bug613484.vala \
asynchronous/bug614294.vala \
asynchronous/bug620740.vala \
+ asynchronous/bug626053.vala \
asynchronous/bug639591.vala \
asynchronous/bug640721.vala \
asynchronous/bug641182.vala \
diff --git a/tests/asynchronous/bug612641.vala b/tests/asynchronous/bug612641.vala
new file mode 100644
index 0000000..5b62634
--- /dev/null
+++ b/tests/asynchronous/bug612641.vala
@@ -0,0 +1,10 @@
+delegate void FooFunc ();
+
+class Foo {
+ async FooFunc foo () {
+ return () => {};
+ }
+}
+
+void main () {
+}
diff --git a/tests/asynchronous/bug626053.vala b/tests/asynchronous/bug626053.vala
new file mode 100644
index 0000000..cb1fa3a
--- /dev/null
+++ b/tests/asynchronous/bug626053.vala
@@ -0,0 +1,8 @@
+class Foo {
+ async string[] foo () {
+ return { "foo", "bar" };
+ }
+}
+
+void main () {
+}
diff --git a/tests/delegates/bug519949.test b/tests/delegates/bug519949.test
new file mode 100644
index 0000000..a8283e4
--- /dev/null
+++ b/tests/delegates/bug519949.test
@@ -0,0 +1,10 @@
+Invalid Code
+
+delegate void FooFunc ();
+
+class Foo<G> {
+}
+
+void main () {
+ var foo = new Foo<FooFunc> ();
+}
diff --git a/tests/delegates/bug632017.test b/tests/delegates/bug632017.test
new file mode 100644
index 0000000..afc8362
--- /dev/null
+++ b/tests/delegates/bug632017.test
@@ -0,0 +1,7 @@
+Invalid Code
+
+delegate void FooFunc ();
+
+void main() {
+ var array = new FooFunc[3];
+}
diff --git a/tests/delegates/fields.vala b/tests/delegates/fields.vala
new file mode 100644
index 0000000..ff68289
--- /dev/null
+++ b/tests/delegates/fields.vala
@@ -0,0 +1,17 @@
+delegate void FooFunc ();
+
+[CCode (has_target = false)]
+delegate void FooFuncTargetless ();
+
+FooFunc foo;
+unowned FooFunc foo_unowned;
+FooFuncTargetless foo_targetless;
+
+void func () {
+}
+
+void main () {
+ foo = func;
+ foo_unowned = func;
+ foo_targetless = func;
+}
diff --git a/tests/delegates/wrapper.vala b/tests/delegates/wrapper.vala
new file mode 100644
index 0000000..01b9518
--- /dev/null
+++ b/tests/delegates/wrapper.vala
@@ -0,0 +1,18 @@
+delegate void FooFunc ([CCode (array_length = false, array_null_terminated = true)] string[] a);
+delegate void BarFunc (owned FooFunc func);
+
+void foo (string[] a) {
+ assert (a.length == 2);
+ assert (a[1] == "bar");
+}
+
+void bar (owned FooFunc func) {
+ string[] ia = { "foo", "bar" };
+ func (ia);
+}
+
+void main () {
+ FooFunc f = foo;
+ BarFunc b = bar;
+ b ((owned) f);
+}
diff --git a/tests/errors/catch-error-code.vala b/tests/errors/catch-error-code.vala
new file mode 100644
index 0000000..10bfd9d
--- /dev/null
+++ b/tests/errors/catch-error-code.vala
@@ -0,0 +1,16 @@
+errordomain FooError {
+ BAR,
+ FOO
+}
+
+void main () {
+ bool cond = false;
+ try {
+ if (cond)
+ throw new FooError.BAR ("bad");
+ throw new FooError.FOO ("worse");
+ } catch (FooError.FOO e) {
+ } catch (FooError e) {
+ assert_not_reached ();
+ }
+}
diff --git a/tests/methods/bug620673.test b/tests/methods/bug620673.test
new file mode 100644
index 0000000..26fbcbd
--- /dev/null
+++ b/tests/methods/bug620673.test
@@ -0,0 +1,8 @@
+Invalid Code
+
+void foo () {
+ va_list args = va_list ();
+}
+
+void main () {
+}
diff --git a/tests/methods/iterator.vala b/tests/methods/iterator.vala
index 3dd9966..68d573e 100644
--- a/tests/methods/iterator.vala
+++ b/tests/methods/iterator.vala
@@ -69,4 +69,18 @@ void main () {
foreach (var foo3 in collection3) {
assert (foo3 == foo_instance);
}
+
+ // GLib.List
+ var list = new List<Foo> ();
+ list.append (foo_instance);
+ foreach (var e in list) {
+ assert (e == foo_instance);
+ }
+
+ // GLib.SList
+ var slist = new SList<Foo> ();
+ slist.append (foo_instance);
+ foreach (var e in slist) {
+ assert (e == foo_instance);
+ }
}
diff --git a/tests/objects/bug541728.test b/tests/objects/bug541728.test
new file mode 100644
index 0000000..37fb72b
--- /dev/null
+++ b/tests/objects/bug541728.test
@@ -0,0 +1,8 @@
+Invalid Code
+
+class Foo {
+ public string bar { get; construct; }
+}
+
+void main () {
+}
diff --git a/tests/objects/bug564011.test b/tests/objects/bug564011.test
new file mode 100644
index 0000000..1bf9d32
--- /dev/null
+++ b/tests/objects/bug564011.test
@@ -0,0 +1,9 @@
+Invalid Code
+
+class Foo {
+ static ~Foo () {
+ }
+}
+
+void main () {
+}
diff --git a/tests/objects/bug564090.test b/tests/objects/bug564090.test
new file mode 100644
index 0000000..6e62a4a
--- /dev/null
+++ b/tests/objects/bug564090.test
@@ -0,0 +1,13 @@
+Invalid Code
+
+[Compact]
+class Foo {
+ class int x = 1;
+
+ class construct {
+ x = 2;
+ }
+}
+
+void main () {
+}
diff --git a/tests/objects/bug574146.test b/tests/objects/bug574146.test
new file mode 100644
index 0000000..40c3e87
--- /dev/null
+++ b/tests/objects/bug574146.test
@@ -0,0 +1,8 @@
+Invalid Code
+
+class Foo : Object {
+ public int[] bar { get; construct; }
+}
+
+void main () {
+}
diff --git a/tests/objects/bug585344.test b/tests/objects/bug585344.test
new file mode 100644
index 0000000..68559a6
--- /dev/null
+++ b/tests/objects/bug585344.test
@@ -0,0 +1,11 @@
+Invalid Code
+
+[Compact]
+class Foo {
+}
+
+void main () {
+ var foo = new Foo ();
+ if (foo is Foo) {
+ }
+}
diff --git a/tests/structs/gvalue.vala b/tests/structs/gvalue.vala
index c17c9d9..927db03 100644
--- a/tests/structs/gvalue.vala
+++ b/tests/structs/gvalue.vala
@@ -55,10 +55,29 @@ bool make_bool () {
return true;
}
+struct FooStruct {
+ public int i;
+}
+
+void test_try_cast_value () {
+ FooStruct s = { 42 };
+ Value vs = s;
+
+ FooStruct s2 = (FooStruct) vs;
+ assert (s2.i == 42);
+
+ string[] sarray = { "hello", "vala", "world" };
+ Value va = sarray;
+
+ string[] sarray2 = (string[]) va;
+ assert (sarray[1] == "vala");
+}
+
void main () {
test_value ();
test_value_array ();
test_nullable_value ();
test_nullable_value_array ();
take_value (make_bool ());
+ test_try_cast_value ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]