vala r885 - in trunk: . tests



Author: juergbi
Date: Tue Jan 22 17:15:36 2008
New Revision: 885
URL: http://svn.gnome.org/viewvc/vala?rev=885&view=rev

Log:
2008-01-22  Juerg Billeter  <j bitron ch>

	* tests/Makefile.am, tests/arrays.exp, tests/arrays.vala: add element
	  access tests to array tests


Removed:
   trunk/tests/test-019.exp
   trunk/tests/test-019.vala
Modified:
   trunk/ChangeLog
   trunk/tests/Makefile.am
   trunk/tests/arrays.exp
   trunk/tests/arrays.vala

Modified: trunk/tests/Makefile.am
==============================================================================
--- trunk/tests/Makefile.am	(original)
+++ trunk/tests/Makefile.am	Tue Jan 22 17:15:36 2008
@@ -36,7 +36,6 @@
 	exceptions.vala \
 	\
 	test-015.vala \
-	test-019.vala \
 	test-021.vala \
 	test-023.vala \
 	test-025.vala \
@@ -75,7 +74,6 @@
 	exceptions.exp \
 	\
 	test-015.exp \
-	test-019.exp \
 	test-021.exp \
 	test-023.exp \
 	test-025.exp \

Modified: trunk/tests/arrays.exp
==============================================================================
--- trunk/tests/arrays.exp	(original)
+++ trunk/tests/arrays.exp	Tue Jan 22 17:15:36 2008
@@ -3,3 +3,4 @@
 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

Modified: trunk/tests/arrays.vala
==============================================================================
--- trunk/tests/arrays.vala	(original)
+++ trunk/tests/arrays.vala	Tue Jan 22 17:15:36 2008
@@ -173,6 +173,49 @@
 		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 @@
 		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 {



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]