update for 0.4.0 release
[vala-lang.git] / tests / test-027.vala
blob3b7cd322df990dd0e79df4a6901eac5e47cbbd41
1 using GLib;
3 class Maman.Bar : Object {
4 public int foo { get; set; }
6 public void run () {
7 /* test with local variable */
8 int i = 1;
9 stdout.printf (" %d", ++i);
11 stdout.printf (" %d", i + 1);
13 i = 4;
14 stdout.printf (" %d", i++);
16 stdout.printf (" %d", i);
18 i = 7;
19 stdout.printf (" %d", --(i));
21 stdout.printf (" %d", i + 1);
23 i = 8;
24 stdout.printf (" %d", (i)--);
26 stdout.printf (" %d", i + 2);
28 /* test with field */
29 foo = 9;
30 stdout.printf (" %d", ++foo);
32 stdout.printf (" %d", foo + 1);
34 foo = 12;
35 stdout.printf (" %d", foo++);
37 stdout.printf (" %d", foo);
39 foo = 15;
40 stdout.printf (" %d", --(foo));
42 stdout.printf (" %d", foo + 1);
44 foo = 16;
45 stdout.printf (" %d", (foo)--);
47 stdout.printf (" %d", foo + 2);
50 static void test_postfix_and_prefix_expressions () {
51 stdout.printf ("Postfix and Prefix Expression Test: 1");
53 var bar = new Bar ();
54 bar.run ();
56 stdout.printf (" 18\n");
59 static void test_prefix_increment_in_loop () {
60 stdout.printf ("Prefix Increment in Loop Test: ");
62 int i = 0, j = 0;
64 do {
65 stdout.printf (" %d", i);
66 j = j + 1;
67 } while (++i < 10 && j < 15);
69 stdout.printf (" %d\n", i);
72 static int main (string[] args) {
73 test_postfix_and_prefix_expressions ();
74 test_prefix_increment_in_loop ();
76 return 0;