diff options
Diffstat (limited to 'tests/semantic')
-rw-r--r-- | tests/semantic/with-array.test | 7 | ||||
-rw-r--r-- | tests/semantic/with-buildin.vala | 5 | ||||
-rw-r--r-- | tests/semantic/with-class.test | 9 | ||||
-rw-r--r-- | tests/semantic/with-compact.vala | 13 | ||||
-rw-r--r-- | tests/semantic/with-declaration-cast-type.vala | 10 | ||||
-rw-r--r-- | tests/semantic/with-declaration-wrong-type.test | 12 | ||||
-rw-r--r-- | tests/semantic/with-declaration.vala | 35 | ||||
-rw-r--r-- | tests/semantic/with-dereferenced-pointer.vala | 14 | ||||
-rw-r--r-- | tests/semantic/with-enum-member.vala | 8 | ||||
-rw-r--r-- | tests/semantic/with-enum.test | 10 | ||||
-rw-r--r-- | tests/semantic/with-error-member.test | 11 | ||||
-rw-r--r-- | tests/semantic/with-error.test | 10 | ||||
-rw-r--r-- | tests/semantic/with-namespace.test | 9 | ||||
-rw-r--r-- | tests/semantic/with-no-declaration.test | 9 | ||||
-rw-r--r-- | tests/semantic/with-no-such-member.test | 10 | ||||
-rw-r--r-- | tests/semantic/with-null.vala | 12 | ||||
-rw-r--r-- | tests/semantic/with-outside-declaration.test | 13 | ||||
-rw-r--r-- | tests/semantic/with-pointer.test | 7 | ||||
-rw-r--r-- | tests/semantic/with-string.vala | 5 | ||||
-rw-r--r-- | tests/semantic/with-value.vala | 10 |
20 files changed, 219 insertions, 0 deletions
diff --git a/tests/semantic/with-array.test b/tests/semantic/with-array.test new file mode 100644 index 000000000..bf0b4d18d --- /dev/null +++ b/tests/semantic/with-array.test @@ -0,0 +1,7 @@ +Invalid Code + +void main () { + int[] arr = { 1, 2, 3 }; + with (arr) { + } +} diff --git a/tests/semantic/with-buildin.vala b/tests/semantic/with-buildin.vala new file mode 100644 index 000000000..999554adf --- /dev/null +++ b/tests/semantic/with-buildin.vala @@ -0,0 +1,5 @@ +void main () { + with (stdout) { + assert (!eof ()); + } +} diff --git a/tests/semantic/with-class.test b/tests/semantic/with-class.test new file mode 100644 index 000000000..2bea6e52c --- /dev/null +++ b/tests/semantic/with-class.test @@ -0,0 +1,9 @@ +Invalid Code + +class Foo { +} + +void main () { + with (Foo) { + } +} diff --git a/tests/semantic/with-compact.vala b/tests/semantic/with-compact.vala new file mode 100644 index 000000000..b2530c91f --- /dev/null +++ b/tests/semantic/with-compact.vala @@ -0,0 +1,13 @@ +[Compact] +class Foo { + public int i; +} + +void main () { + var foo = new Foo (); + with (foo) { + i = 13; + } + + assert (foo.i == 13); +} diff --git a/tests/semantic/with-declaration-cast-type.vala b/tests/semantic/with-declaration-cast-type.vala new file mode 100644 index 000000000..c855d1c0b --- /dev/null +++ b/tests/semantic/with-declaration-cast-type.vala @@ -0,0 +1,10 @@ +class Foo { +} + +class Bar : Foo { +} + +void main () { + with (Foo f = new Bar ()) { + } +} diff --git a/tests/semantic/with-declaration-wrong-type.test b/tests/semantic/with-declaration-wrong-type.test new file mode 100644 index 000000000..79ae8f8fb --- /dev/null +++ b/tests/semantic/with-declaration-wrong-type.test @@ -0,0 +1,12 @@ +Invalid Code + +class Foo { +} + +class Bar { +} + +void main () { + with (Bar f = new Foo ()) { + } +} diff --git a/tests/semantic/with-declaration.vala b/tests/semantic/with-declaration.vala new file mode 100644 index 000000000..78763c333 --- /dev/null +++ b/tests/semantic/with-declaration.vala @@ -0,0 +1,35 @@ +class Foo { + public int i; + public int j; +} + +void main () { + var foo = new Foo (); + with (foo) { + i = 10; + } + + assert (foo.i == 10); + with (var f = foo) { + i = 100; + f.j = 200; + } + + assert (foo.i == 100); + assert (foo.j == 200); + with (Foo f = foo) { + i = 1000; + f.j = 2000; + } + + assert (foo.i == 1000); + assert (foo.j == 2000); + Foo f; + with (f = foo) { + i = 10000; + f.j = 20000; + } + + assert (f.i == 10000); + assert (foo.j == 20000); +} diff --git a/tests/semantic/with-dereferenced-pointer.vala b/tests/semantic/with-dereferenced-pointer.vala new file mode 100644 index 000000000..42fc20fd8 --- /dev/null +++ b/tests/semantic/with-dereferenced-pointer.vala @@ -0,0 +1,14 @@ +class Foo { + public int i; +} + +void main () { + var f = new Foo (); + var p = &f; + + with (*p) { + i = 13; + } + + assert (f.i == 13); +} diff --git a/tests/semantic/with-enum-member.vala b/tests/semantic/with-enum-member.vala new file mode 100644 index 000000000..3b5517db0 --- /dev/null +++ b/tests/semantic/with-enum-member.vala @@ -0,0 +1,8 @@ +enum FooEnum { + FIRST +} + +void main () { + with (FooEnum.FIRST) { + } +} diff --git a/tests/semantic/with-enum.test b/tests/semantic/with-enum.test new file mode 100644 index 000000000..3a473a2f1 --- /dev/null +++ b/tests/semantic/with-enum.test @@ -0,0 +1,10 @@ +Invalid Code + +enum FooEnum { + FIRST +} + +void main () { + with (FooEnum) { + } +} diff --git a/tests/semantic/with-error-member.test b/tests/semantic/with-error-member.test new file mode 100644 index 000000000..6d883b6e5 --- /dev/null +++ b/tests/semantic/with-error-member.test @@ -0,0 +1,11 @@ +Invalid Code + +errordomain FooError { + FAIL +} + +void main () { + var e = new FooError.FAIL ("foo"); + with (e) { + } +} diff --git a/tests/semantic/with-error.test b/tests/semantic/with-error.test new file mode 100644 index 000000000..61cc28efa --- /dev/null +++ b/tests/semantic/with-error.test @@ -0,0 +1,10 @@ +Invalid Code + +errordomain FooError { + FAIL +} + +void main () { + with (FooError) { + } +} diff --git a/tests/semantic/with-namespace.test b/tests/semantic/with-namespace.test new file mode 100644 index 000000000..e328fe205 --- /dev/null +++ b/tests/semantic/with-namespace.test @@ -0,0 +1,9 @@ +Invalid Code + +namespace Foo { +} + +void main () { + with (Foo) { + } +} diff --git a/tests/semantic/with-no-declaration.test b/tests/semantic/with-no-declaration.test new file mode 100644 index 000000000..3b033a8e3 --- /dev/null +++ b/tests/semantic/with-no-declaration.test @@ -0,0 +1,9 @@ +Invalid Code + +class Foo { +} + +void main () { + with (f = new Foo ()) { + } +} diff --git a/tests/semantic/with-no-such-member.test b/tests/semantic/with-no-such-member.test new file mode 100644 index 000000000..5f20d21c8 --- /dev/null +++ b/tests/semantic/with-no-such-member.test @@ -0,0 +1,10 @@ +Invalid Code + +class Foo { +} + +void main () { + with (new Foo ()) { + field = 100; + } +} diff --git a/tests/semantic/with-null.vala b/tests/semantic/with-null.vala new file mode 100644 index 000000000..dd108b256 --- /dev/null +++ b/tests/semantic/with-null.vala @@ -0,0 +1,12 @@ +class Foo { + public int i; +} + +void main () { + Foo? f = null; + Process.exit (0); + + with (f) { + i = 7; + } +} diff --git a/tests/semantic/with-outside-declaration.test b/tests/semantic/with-outside-declaration.test new file mode 100644 index 000000000..86af413e7 --- /dev/null +++ b/tests/semantic/with-outside-declaration.test @@ -0,0 +1,13 @@ +Invalid Code + +class Foo { + public int i; +} + +void main () { + with (var f = new Foo ()) { + i = 10; + } + + f.i = 100; +} diff --git a/tests/semantic/with-pointer.test b/tests/semantic/with-pointer.test new file mode 100644 index 000000000..d268b1cd2 --- /dev/null +++ b/tests/semantic/with-pointer.test @@ -0,0 +1,7 @@ +Invalid Code + +void main () { + int i = 0; + with (&i) { + } +} diff --git a/tests/semantic/with-string.vala b/tests/semantic/with-string.vala new file mode 100644 index 000000000..133be17b6 --- /dev/null +++ b/tests/semantic/with-string.vala @@ -0,0 +1,5 @@ +void main () { + with ("string ") { + assert (chomp () == "string"); + } +} diff --git a/tests/semantic/with-value.vala b/tests/semantic/with-value.vala new file mode 100644 index 000000000..a0f111ad8 --- /dev/null +++ b/tests/semantic/with-value.vala @@ -0,0 +1,10 @@ +void main () { + int i = 0; + string s; + + with (i) { + s = i.to_string (); + } + + assert (s == "0"); +} |