From 3e2ed5e3f4dffa53999c22bacc2a4f7c374a2450 Mon Sep 17 00:00:00 2001 From: Juerg Billeter Date: Tue, 22 Jan 2008 17:15:36 +0000 Subject: [PATCH] add element access tests to array tests 2008-01-22 Juerg Billeter * tests/Makefile.am, tests/arrays.exp, tests/arrays.vala: add element access tests to array tests svn path=/trunk/; revision=885 --- ChangeLog | 5 +++++ tests/Makefile.am | 2 -- tests/arrays.exp | 1 + tests/arrays.vala | 51 +++++++++++++++++++++++++++++++++++++++++++++ tests/test-019.exp | 1 - tests/test-019.vala | 60 ----------------------------------------------------- 6 files changed, 57 insertions(+), 63 deletions(-) delete mode 100644 tests/test-019.exp delete mode 100644 tests/test-019.vala diff --git a/ChangeLog b/ChangeLog index c2dec4b..78df10b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,10 @@ 2008-01-22 Jürg Billeter + * tests/Makefile.am, tests/arrays.exp, tests/arrays.vala: add element + access tests to array tests + +2008-01-22 Jürg Billeter + * vala/valasemanticanalyzer.vala: check type of variable initializer * gee/hashmap.vala, gee/hashset.vala, vala/valasymbol.vala: fix invalid diff --git a/tests/Makefile.am b/tests/Makefile.am index 508bb3e..3828f96 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -36,7 +36,6 @@ TESTS = \ exceptions.vala \ \ test-015.vala \ - test-019.vala \ test-021.vala \ test-023.vala \ test-025.vala \ @@ -75,7 +74,6 @@ EXTRA_DIST = \ exceptions.exp \ \ test-015.exp \ - test-019.exp \ test-021.exp \ test-023.exp \ test-025.exp \ diff --git a/tests/arrays.exp b/tests/arrays.exp index a2ee285..344248b 100644 --- a/tests/arrays.exp +++ b/tests/arrays.exp @@ -3,3 +3,4 @@ String array creation and assignment: 1 2 3 4 5 6 7 8 9 10 11 Object array creation and assignment: 1 2 3 4 5 6 7 8 9 10 11 Array Test: 1 2 3 4 5 testing switch on strings: 1 2 3 4 5 6 7 +Element access: 1 2 3 4 5 6 7 8 9 10 11 12 13 diff --git a/tests/arrays.vala b/tests/arrays.vala index 3847dc7..5ca3c5b 100644 --- a/tests/arrays.vala +++ b/tests/arrays.vala @@ -173,6 +173,49 @@ class Maman.Foo : Object { assert (i == 6); } + static void test_element_access () { + stdout.printf ("Element access: 1"); + + stdout.printf (" 2"); + + var sa = "a,b,c,d".split (","); + int i = 3; + + stdout.printf (" 3"); + + if (sa[inc()] == "a") { + stdout.printf (" 4"); + } + if (sa[inc()] == "b") { + stdout.printf (" 5"); + } + if (sa[2] == "c") { + stdout.printf (" 6"); + } + if (sa[i] == "d") { + stdout.printf (" 7"); + } + + string bar = "efgh"; + counter = 0; + if (bar[inc()] == 'e') { + stdout.printf (" 8"); + } + if (bar[inc()] == 'f') { + stdout.printf (" 9"); + } + if (bar[2] == 'g') { + stdout.printf (" 10"); + } + if (bar[i] == 'h') { + stdout.printf (" 11"); + } + + stdout.printf (" 12"); + + stdout.printf (" 13\n"); + } + static void main (string[] args) { test_integer_array (); test_string_array (); @@ -188,7 +231,15 @@ class Maman.Foo : Object { test_switch_on_strings (); test_array_creation_side_effects (); + + test_element_access (); } + + public static int inc () { + return counter++; + } + + private static int counter = 0; } class Maman.Bar : Object { diff --git a/tests/test-019.exp b/tests/test-019.exp deleted file mode 100644 index b57b47c..0000000 --- a/tests/test-019.exp +++ /dev/null @@ -1 +0,0 @@ -Element access: 1 2 3 4 5 6 7 8 9 10 11 12 13 diff --git a/tests/test-019.vala b/tests/test-019.vala deleted file mode 100644 index 7d33072..0000000 --- a/tests/test-019.vala +++ /dev/null @@ -1,60 +0,0 @@ -using GLib; - -class Maman.Foo : Object { - public void run () { - stdout.printf (" 2"); - - var sa = "a,b,c,d".split (","); - int i = 3; - - stdout.printf (" 3"); - - if (sa[inc()] == "a") { - stdout.printf (" 4"); - } - if (sa[inc()] == "b") { - stdout.printf (" 5"); - } - if (sa[2] == "c") { - stdout.printf (" 6"); - } - if (sa[i] == "d") { - stdout.printf (" 7"); - } - - string bar = "efgh"; - counter = 0; - if (bar[inc()] == 'e') { - stdout.printf (" 8"); - } - if (bar[inc()] == 'f') { - stdout.printf (" 9"); - } - if (bar[2] == 'g') { - stdout.printf (" 10"); - } - if (bar[i] == 'h') { - stdout.printf (" 11"); - } - - - stdout.printf (" 12"); - } - - public int inc () { - return counter++; - } - - static int main (string[] args) { - stdout.printf ("Element access: 1"); - - var foo = new Foo (); - foo.run (); - - stdout.printf (" 13\n"); - - return 0; - } - - private int counter = 0; -} -- 2.7.4