1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
|
using GLib;
class Maman.Bar : Object {
public int foo { get; set; }
public void run () {
/* test with local variable */
int i = 1;
stdout.printf (" %d", ++i);
stdout.printf (" %d", i + 1);
i = 4;
stdout.printf (" %d", i++);
stdout.printf (" %d", i);
i = 7;
stdout.printf (" %d", --(i));
stdout.printf (" %d", i + 1);
i = 8;
stdout.printf (" %d", (i)--);
stdout.printf (" %d", i + 2);
/* test with field */
foo = 9;
stdout.printf (" %d", ++foo);
stdout.printf (" %d", foo + 1);
foo = 12;
stdout.printf (" %d", foo++);
stdout.printf (" %d", foo);
foo = 15;
stdout.printf (" %d", --(foo));
stdout.printf (" %d", foo + 1);
foo = 16;
stdout.printf (" %d", (foo)--);
stdout.printf (" %d", foo + 2);
}
static void test_postfix_and_prefix_expressions () {
stdout.printf ("Postfix and Prefix Expression Test: 1");
var bar = new Bar ();
bar.run ();
stdout.printf (" 18\n");
}
static void test_prefix_increment_in_loop () {
stdout.printf ("Prefix Increment in Loop Test: ");
int i = 0, j = 0;
do {
stdout.printf (" %d", i);
j = j + 1;
} while (++i < 10 && j < 15);
stdout.printf (" %d\n", i);
}
static int main (string[] args) {
test_postfix_and_prefix_expressions ();
test_prefix_increment_in_loop ();
return 0;
}
}
|