From: Corentin Noël Date: Fri, 22 Mar 2019 08:09:21 +0000 (+0100) Subject: tests: Add more invalid "assignment" tests to increase coverage X-Git-Tag: 0.42.7~17 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=457a0b8b4a6692caa90768398cda49e4854f2f25;p=thirdparty%2Fvala.git tests: Add more invalid "assignment" tests to increase coverage --- diff --git a/tests/Makefile.am b/tests/Makefile.am index 5434c5c25..019779c88 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -66,7 +66,9 @@ TESTS = \ basic-types/bug787152.vala \ basic-types/bug788775.vala \ arrays/class-field-length-cname.vala \ + arrays/expression-bracket.test \ arrays/field-global-length-cname.vala \ + arrays/fixed-length-non-const.test \ arrays/struct-field-length-cname.vala \ arrays/slice-invalid-start.test \ arrays/slice-invalid-stop.test \ @@ -181,12 +183,14 @@ TESTS = \ control-semantic/argument-owned-ref.test \ control-semantic/argument-value-out.test \ control-semantic/argument-value-ref.test \ + control-semantic/literal-immutable.test \ control-semantic/member-incompatible-type.test \ control-semantic/member-invalid.test \ control-semantic/member-private.test \ control-semantic/member-readonly.test \ control-semantic/printf-too-few.test \ control-semantic/printf-too-many.test \ + control-semantic/this-assignment.test \ control-semantic/variadic-argument-invalid.test \ enums/enum_only.vala \ enums/enum-no-gtype.vala \ @@ -280,6 +284,9 @@ TESTS = \ objects/properties.vala \ objects/property-notify.vala \ objects/property-read-only-auto.vala \ + objects/property-read-only-write.test \ + objects/property-construct-only-write.test \ + objects/property-construct-only-write-foreign.test \ objects/property-static.vala \ objects/regex.vala \ objects/signals.vala \ diff --git a/tests/arrays/expression-bracket.test b/tests/arrays/expression-bracket.test new file mode 100644 index 000000000..c0422a34f --- /dev/null +++ b/tests/arrays/expression-bracket.test @@ -0,0 +1,13 @@ +Invalid Code + +int bar () { + return 1; +} + +string[bar ()]? foo () { + return null; +} + +void main () { + foo (); +} diff --git a/tests/arrays/fixed-length-non-const.test b/tests/arrays/fixed-length-non-const.test new file mode 100644 index 000000000..7ae22936f --- /dev/null +++ b/tests/arrays/fixed-length-non-const.test @@ -0,0 +1,6 @@ +Invalid Code + +void main () { + int test_len = 60; + string test_array[test_len]; +} diff --git a/tests/control-semantic/literal-immutable.test b/tests/control-semantic/literal-immutable.test new file mode 100644 index 000000000..a335da9ee --- /dev/null +++ b/tests/control-semantic/literal-immutable.test @@ -0,0 +1,5 @@ +Invalid Code + +void main () { + true = false; +} diff --git a/tests/control-semantic/this-assignment.test b/tests/control-semantic/this-assignment.test new file mode 100644 index 000000000..69dc5709a --- /dev/null +++ b/tests/control-semantic/this-assignment.test @@ -0,0 +1,12 @@ +Invalid Code + +class Foo { + public void do_bar () { + this = new Foo (); + } +} + +void main () { + var foo = new Foo (); + foo.do_bar (); +} diff --git a/tests/objects/property-construct-only-write-foreign.test b/tests/objects/property-construct-only-write-foreign.test new file mode 100644 index 000000000..4ec5be7ff --- /dev/null +++ b/tests/objects/property-construct-only-write-foreign.test @@ -0,0 +1,16 @@ +Invalid Code + +class Foo : GLib.Object { + public string test { construct; } + public Foo () { + var other = new Foo.ok (); + other.test = ""; + } + + public Foo.ok () { + } +} + +void main () { + var foo = new Foo (); +} diff --git a/tests/objects/property-construct-only-write.test b/tests/objects/property-construct-only-write.test new file mode 100644 index 000000000..1b7636c77 --- /dev/null +++ b/tests/objects/property-construct-only-write.test @@ -0,0 +1,12 @@ +Invalid Code + +class Foo : GLib.Object { + public string test { construct; } + public Foo () { + test = ""; + } +} + +void main () { + var foo = new Foo (); +} diff --git a/tests/objects/property-read-only-write.test b/tests/objects/property-read-only-write.test new file mode 100644 index 000000000..7e1e02de2 --- /dev/null +++ b/tests/objects/property-read-only-write.test @@ -0,0 +1,12 @@ +Invalid Code + +class Foo : GLib.Object { + public string test { get; } + public Foo () { + } +} + +void main () { + var foo = new Foo (); + foo.test= ""; +}