From: Corentin Noël Date: Mon, 5 Feb 2018 01:02:21 +0000 (+0000) Subject: tests: Add more "parser" tests to increase coverage X-Git-Tag: 0.39.91~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=9653ac055e0fba5964d4539f15ace5327e5bc0c6;p=thirdparty%2Fvala.git tests: Add more "parser" tests to increase coverage --- diff --git a/tests/Makefile.am b/tests/Makefile.am index afdb412e4..545ad1a35 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -334,12 +334,62 @@ TESTS = \ annotations/description.vala \ annotations/noaccessormethod.test \ parser/assignment.vala \ + parser/attribute-duplicate.test \ + parser/attribute-wrong-number.test \ + parser/constructor-no-new.test \ + parser/constructor-no-static-class.test \ parser/continue-statement.vala \ + parser/creation-no-abstract.test \ + parser/creation-no-override.test \ + parser/creation-no-virtual.test \ + parser/delegate-no-new.test \ + parser/destructor-no-new.test \ + parser/destructor-no-static-class.test \ + parser/destructor-wrong-name.test \ parser/do-statement.vala \ + parser/expect-endbrace.test \ + parser/expect-error.test \ + parser/field-no-abstract.test \ + parser/field-no-override.test \ + parser/field-no-static-class.test \ + parser/field-no-virtual.test \ + parser/foreach-no-type.test \ + parser/function-syntax-error.test \ + parser/inner-array-size.test \ + parser/invalid-brace.test \ + parser/method-no-abstract-override.test \ + parser/method-no-abstract-virtual-override.test \ + parser/method-no-abstract-virtual.test \ + parser/method-no-class-abstract.test \ + parser/method-no-class-override.test \ + parser/method-no-class-virtual.test \ + parser/method-no-static-abstract.test \ + parser/method-no-static-class.test \ + parser/method-no-static-override.test \ + parser/method-no-static-virtual.test \ + parser/method-no-virtual-override.test \ + parser/namespace-missing-bracket.test \ parser/preprocessor.vala \ + parser/property-default-redefined.test \ + parser/property-get-must-have-body.test \ + parser/property-get-redefined.test \ + parser/property-get-set-construct.test \ + parser/property-no-abstract-override.test \ + parser/property-no-abstract-virtual.test \ + parser/property-no-abstract-virtual-override.test \ + parser/property-no-static-class.test \ + parser/property-no-virtual-override.test \ + parser/property-set-must-have-body.test \ + parser/property-set-redefined.test \ + parser/signal-no-class.test \ + parser/signal-no-static.test \ + parser/statement-outside-root.test \ parser/switch-statement.vala \ parser/template.vala \ parser/tuple.vala \ + parser/unsupported-property-async.test \ + parser/unsupported-property-throws.test \ + parser/yield-method.test \ semantic/field-accessibility.test \ semantic/field-compact-static.test \ semantic/field-external.test \ diff --git a/tests/parser/assignment.vala b/tests/parser/assignment.vala index ceef7cf97..257cd55ea 100644 --- a/tests/parser/assignment.vala +++ b/tests/parser/assignment.vala @@ -6,9 +6,10 @@ void main () { i *= 2; i /= 2; i |= 1; - i &= 1; + i &= 1; i ^= 1; i %= 1; + i = ~1; i <<= 2; i >>= 2; } diff --git a/tests/parser/attribute-duplicate.test b/tests/parser/attribute-duplicate.test new file mode 100644 index 000000000..bf2ac0709 --- /dev/null +++ b/tests/parser/attribute-duplicate.test @@ -0,0 +1,5 @@ +Invalid Code + +[CCode (cname = "test1"), CCode (cname = "test2")] +void main () { +} diff --git a/tests/parser/attribute-wrong-number.test b/tests/parser/attribute-wrong-number.test new file mode 100644 index 000000000..9b7eb0452 --- /dev/null +++ b/tests/parser/attribute-wrong-number.test @@ -0,0 +1,5 @@ +Invalid Code + +[Attribute (prop = -a)] +void main () { +} diff --git a/tests/parser/constructor-no-new.test b/tests/parser/constructor-no-new.test new file mode 100644 index 000000000..107576ce0 --- /dev/null +++ b/tests/parser/constructor-no-new.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + new construct { + } +} + +void main () { +} diff --git a/tests/parser/constructor-no-static-class.test b/tests/parser/constructor-no-static-class.test new file mode 100644 index 000000000..24896535e --- /dev/null +++ b/tests/parser/constructor-no-static-class.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + static class construct { + } +} + +void main () { +} diff --git a/tests/parser/creation-no-abstract.test b/tests/parser/creation-no-abstract.test new file mode 100644 index 000000000..7754063af --- /dev/null +++ b/tests/parser/creation-no-abstract.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + abstract Test () { + } +} + +void main () { +} diff --git a/tests/parser/creation-no-override.test b/tests/parser/creation-no-override.test new file mode 100644 index 000000000..b76328408 --- /dev/null +++ b/tests/parser/creation-no-override.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + override Test () { + } +} + +void main () { +} diff --git a/tests/parser/creation-no-virtual.test b/tests/parser/creation-no-virtual.test new file mode 100644 index 000000000..fa7ee81bf --- /dev/null +++ b/tests/parser/creation-no-virtual.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + virtual Test () { + } +} + +void main () { +} diff --git a/tests/parser/delegate-no-new.test b/tests/parser/delegate-no-new.test new file mode 100644 index 000000000..32c1bf32a --- /dev/null +++ b/tests/parser/delegate-no-new.test @@ -0,0 +1,6 @@ +Invalid Code + +public new delegate void MyDelegate (); + +void main () { +} diff --git a/tests/parser/destructor-no-new.test b/tests/parser/destructor-no-new.test new file mode 100644 index 000000000..f9857aaaf --- /dev/null +++ b/tests/parser/destructor-no-new.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + new ~Test () { + } +} + +void main () { +} diff --git a/tests/parser/destructor-no-static-class.test b/tests/parser/destructor-no-static-class.test new file mode 100644 index 000000000..50f601e81 --- /dev/null +++ b/tests/parser/destructor-no-static-class.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + static class ~Test () { + } +} + +void main () { +} diff --git a/tests/parser/destructor-wrong-name.test b/tests/parser/destructor-wrong-name.test new file mode 100644 index 000000000..aa721e341 --- /dev/null +++ b/tests/parser/destructor-wrong-name.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + ~TestTypo () { + } +} + +void main () { +} diff --git a/tests/parser/expect-endbrace.test b/tests/parser/expect-endbrace.test new file mode 100644 index 000000000..bfea53275 --- /dev/null +++ b/tests/parser/expect-endbrace.test @@ -0,0 +1,7 @@ +Invalid Code + +void main () { + if (true) { + + return; +} diff --git a/tests/parser/expect-error.test b/tests/parser/expect-error.test new file mode 100644 index 000000000..4eaf23132 --- /dev/null +++ b/tests/parser/expect-error.test @@ -0,0 +1,7 @@ +Invalid Code + +public private class Test { +} + +void main () { +} diff --git a/tests/parser/field-no-abstract.test b/tests/parser/field-no-abstract.test new file mode 100644 index 000000000..e5c8f8cc4 --- /dev/null +++ b/tests/parser/field-no-abstract.test @@ -0,0 +1,8 @@ +Invalid Code + +public class Test { + abstract int i; +} + +void main () { +} diff --git a/tests/parser/field-no-override.test b/tests/parser/field-no-override.test new file mode 100644 index 000000000..584eb8622 --- /dev/null +++ b/tests/parser/field-no-override.test @@ -0,0 +1,8 @@ +Invalid Code + +public class Test { + override int i; +} + +void main () { +} diff --git a/tests/parser/field-no-static-class.test b/tests/parser/field-no-static-class.test new file mode 100644 index 000000000..3b1faca1e --- /dev/null +++ b/tests/parser/field-no-static-class.test @@ -0,0 +1,8 @@ +Invalid Code + +public class Test { + static class int i; +} + +void main () { +} diff --git a/tests/parser/field-no-virtual.test b/tests/parser/field-no-virtual.test new file mode 100644 index 000000000..64d5fc336 --- /dev/null +++ b/tests/parser/field-no-virtual.test @@ -0,0 +1,8 @@ +Invalid Code + +public class Test { + virtual int i; +} + +void main () { +} diff --git a/tests/parser/foreach-no-type.test b/tests/parser/foreach-no-type.test new file mode 100644 index 000000000..ed38d3b09 --- /dev/null +++ b/tests/parser/foreach-no-type.test @@ -0,0 +1,7 @@ +Invalid Code + +void main () { + int[] test = {}; + foreach (t in test) { + } +} diff --git a/tests/parser/function-syntax-error.test b/tests/parser/function-syntax-error.test new file mode 100644 index 000000000..8bd96e926 --- /dev/null +++ b/tests/parser/function-syntax-error.test @@ -0,0 +1,4 @@ +Invalid Code + +void int main () { +} diff --git a/tests/parser/inner-array-size.test b/tests/parser/inner-array-size.test new file mode 100644 index 000000000..fc882e15d --- /dev/null +++ b/tests/parser/inner-array-size.test @@ -0,0 +1,5 @@ +Invalid Code + +void main () { + var test = new string[4][]; +} diff --git a/tests/parser/invalid-brace.test b/tests/parser/invalid-brace.test new file mode 100644 index 000000000..c84f7e705 --- /dev/null +++ b/tests/parser/invalid-brace.test @@ -0,0 +1,5 @@ +Invalid Code + +void main () { +} +} diff --git a/tests/parser/method-no-abstract-override.test b/tests/parser/method-no-abstract-override.test new file mode 100644 index 000000000..e6ef1b117 --- /dev/null +++ b/tests/parser/method-no-abstract-override.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + abstract override void test () { + } +} + +void main () { +} diff --git a/tests/parser/method-no-abstract-virtual-override.test b/tests/parser/method-no-abstract-virtual-override.test new file mode 100644 index 000000000..31cba59f8 --- /dev/null +++ b/tests/parser/method-no-abstract-virtual-override.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + abstract virtual override void test () { + } +} + +void main () { +} diff --git a/tests/parser/method-no-abstract-virtual.test b/tests/parser/method-no-abstract-virtual.test new file mode 100644 index 000000000..d1c387c90 --- /dev/null +++ b/tests/parser/method-no-abstract-virtual.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + abstract virtual void test () { + } +} + +void main () { +} diff --git a/tests/parser/method-no-class-abstract.test b/tests/parser/method-no-class-abstract.test new file mode 100644 index 000000000..186286ab6 --- /dev/null +++ b/tests/parser/method-no-class-abstract.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + class abstract void test () { + } +} + +void main () { +} diff --git a/tests/parser/method-no-class-override.test b/tests/parser/method-no-class-override.test new file mode 100644 index 000000000..ff8eebf36 --- /dev/null +++ b/tests/parser/method-no-class-override.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + class override void test () { + } +} + +void main () { +} diff --git a/tests/parser/method-no-class-virtual.test b/tests/parser/method-no-class-virtual.test new file mode 100644 index 000000000..744944609 --- /dev/null +++ b/tests/parser/method-no-class-virtual.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + class virtual void test () { + } +} + +void main () { +} diff --git a/tests/parser/method-no-static-abstract.test b/tests/parser/method-no-static-abstract.test new file mode 100644 index 000000000..02b05d297 --- /dev/null +++ b/tests/parser/method-no-static-abstract.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + static abstract void test () { + } +} + +void main () { +} diff --git a/tests/parser/method-no-static-class.test b/tests/parser/method-no-static-class.test new file mode 100644 index 000000000..05eb6702a --- /dev/null +++ b/tests/parser/method-no-static-class.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + static class void test () { + } +} + +void main () { +} diff --git a/tests/parser/method-no-static-override.test b/tests/parser/method-no-static-override.test new file mode 100644 index 000000000..26a638488 --- /dev/null +++ b/tests/parser/method-no-static-override.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + static override void test () { + } +} + +void main () { +} diff --git a/tests/parser/method-no-static-virtual.test b/tests/parser/method-no-static-virtual.test new file mode 100644 index 000000000..744944609 --- /dev/null +++ b/tests/parser/method-no-static-virtual.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + class virtual void test () { + } +} + +void main () { +} diff --git a/tests/parser/method-no-virtual-override.test b/tests/parser/method-no-virtual-override.test new file mode 100644 index 000000000..e6ef1b117 --- /dev/null +++ b/tests/parser/method-no-virtual-override.test @@ -0,0 +1,9 @@ +Invalid Code + +public class Test { + abstract override void test () { + } +} + +void main () { +} diff --git a/tests/parser/namespace-missing-bracket.test b/tests/parser/namespace-missing-bracket.test new file mode 100644 index 000000000..98e8dd34e --- /dev/null +++ b/tests/parser/namespace-missing-bracket.test @@ -0,0 +1,6 @@ +Invalid Code + +void main () { +} + +namespace Test { diff --git a/tests/parser/property-default-redefined.test b/tests/parser/property-default-redefined.test new file mode 100644 index 000000000..2b2a87fd0 --- /dev/null +++ b/tests/parser/property-default-redefined.test @@ -0,0 +1,8 @@ +Invalid Code + +public class Test { + public int i { get; set; default=0; default=1; } +} + +void main () { +} diff --git a/tests/parser/property-get-must-have-body.test b/tests/parser/property-get-must-have-body.test new file mode 100644 index 000000000..7eaf37a53 --- /dev/null +++ b/tests/parser/property-get-must-have-body.test @@ -0,0 +1,13 @@ +Invalid Code + +public class Test { + public int i { + get; + set { + return 0; + } + } +} + +void main () { +} diff --git a/tests/parser/property-get-redefined.test b/tests/parser/property-get-redefined.test new file mode 100644 index 000000000..5862dffb7 --- /dev/null +++ b/tests/parser/property-get-redefined.test @@ -0,0 +1,15 @@ +Invalid Code + +public class Test { + public int i { + get; + get { + return 0; + } + set { + } + } +} + +void main () { +} diff --git a/tests/parser/property-get-set-construct.test b/tests/parser/property-get-set-construct.test new file mode 100644 index 000000000..32cf5a14c --- /dev/null +++ b/tests/parser/property-get-set-construct.test @@ -0,0 +1,8 @@ +Invalid Code + +public class Test { + public int i { get; set; delete; } +} + +void main () { +} diff --git a/tests/parser/property-no-abstract-override.test b/tests/parser/property-no-abstract-override.test new file mode 100644 index 000000000..124a41ca0 --- /dev/null +++ b/tests/parser/property-no-abstract-override.test @@ -0,0 +1,8 @@ +Invalid Code + +public class Test { + abstract override int i { get; set; } +} + +void main () { +} diff --git a/tests/parser/property-no-abstract-virtual-override.test b/tests/parser/property-no-abstract-virtual-override.test new file mode 100644 index 000000000..0d210a031 --- /dev/null +++ b/tests/parser/property-no-abstract-virtual-override.test @@ -0,0 +1,8 @@ +Invalid Code + +public class Test { + abstract virtual override int i { get; set; } +} + +void main () { +} diff --git a/tests/parser/property-no-abstract-virtual.test b/tests/parser/property-no-abstract-virtual.test new file mode 100644 index 000000000..ee66a0ed5 --- /dev/null +++ b/tests/parser/property-no-abstract-virtual.test @@ -0,0 +1,8 @@ +Invalid Code + +public class Test { + abstract virtual int i { get; set; } +} + +void main () { +} diff --git a/tests/parser/property-no-static-class.test b/tests/parser/property-no-static-class.test new file mode 100644 index 000000000..f5125d62b --- /dev/null +++ b/tests/parser/property-no-static-class.test @@ -0,0 +1,8 @@ +Invalid Code + +public class Test { + static class int i { get; set; } +} + +void main () { +} diff --git a/tests/parser/property-no-virtual-override.test b/tests/parser/property-no-virtual-override.test new file mode 100644 index 000000000..f5344807a --- /dev/null +++ b/tests/parser/property-no-virtual-override.test @@ -0,0 +1,8 @@ +Invalid Code + +public class Test { + virtual override int i { get; set; } +} + +void main () { +} diff --git a/tests/parser/property-set-must-have-body.test b/tests/parser/property-set-must-have-body.test new file mode 100644 index 000000000..ea31af316 --- /dev/null +++ b/tests/parser/property-set-must-have-body.test @@ -0,0 +1,13 @@ +Invalid Code + +public class Test { + public int i { + get { + return 0; + } + set; + } +} + +void main () { +} diff --git a/tests/parser/property-set-redefined.test b/tests/parser/property-set-redefined.test new file mode 100644 index 000000000..48f67e677 --- /dev/null +++ b/tests/parser/property-set-redefined.test @@ -0,0 +1,15 @@ +Invalid Code + +public class Test { + public int i { + get { + return 0; + } + set; + set { + } + } +} + +void main () { +} diff --git a/tests/parser/signal-no-class.test b/tests/parser/signal-no-class.test new file mode 100644 index 000000000..72df991bd --- /dev/null +++ b/tests/parser/signal-no-class.test @@ -0,0 +1,8 @@ +Invalid Code + +public class Test { + public class signal void test (); +} + +void main () { +} diff --git a/tests/parser/signal-no-static.test b/tests/parser/signal-no-static.test new file mode 100644 index 000000000..fae0214f7 --- /dev/null +++ b/tests/parser/signal-no-static.test @@ -0,0 +1,8 @@ +Invalid Code + +public class Test { + public static signal void test (); +} + +void main () { +} diff --git a/tests/parser/statement-outside-root.test b/tests/parser/statement-outside-root.test new file mode 100644 index 000000000..0cd1c22b7 --- /dev/null +++ b/tests/parser/statement-outside-root.test @@ -0,0 +1,8 @@ +Invalid Code + +namespace Test { + var i = {}; +} + +void main () { +} diff --git a/tests/parser/tuple.vala b/tests/parser/tuple.vala index 1c16942de..8ad65b5f9 100644 --- a/tests/parser/tuple.vala +++ b/tests/parser/tuple.vala @@ -11,4 +11,8 @@ void main () { (i, j) = BAR; assert (i == 42); assert (j == 4711); + + var (test, test2) = new int[] { 23, 51 }; + assert (test == 23); + assert (test2 == 51); } diff --git a/tests/parser/unsupported-property-async.test b/tests/parser/unsupported-property-async.test new file mode 100644 index 000000000..124ab93bf --- /dev/null +++ b/tests/parser/unsupported-property-async.test @@ -0,0 +1,8 @@ +Invalid Code + +public class Test { + public async int i { get; set; } +} + +void main () { +} diff --git a/tests/parser/unsupported-property-throws.test b/tests/parser/unsupported-property-throws.test new file mode 100644 index 000000000..35a8bfebc --- /dev/null +++ b/tests/parser/unsupported-property-throws.test @@ -0,0 +1,8 @@ +Invalid Code + +public class Test { + public int i throws int { get; set; } +} + +void main () { +} diff --git a/tests/parser/yield-method.test b/tests/parser/yield-method.test new file mode 100644 index 000000000..1cf7cdf96 --- /dev/null +++ b/tests/parser/yield-method.test @@ -0,0 +1,9 @@ +Invalid Code + +async void test () { + yield ""; +} + +void main () { + test.begin (); +}