diff options
Diffstat (limited to 'tests/control-flow/switch.test')
-rw-r--r-- | tests/control-flow/switch.test | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/control-flow/switch.test b/tests/control-flow/switch.test new file mode 100644 index 000000000..1ee8bb735 --- /dev/null +++ b/tests/control-flow/switch.test @@ -0,0 +1,86 @@ + +Program: test + +using GLib; + +class Maman.Bar : Object { + static bool test_switch_control_flow_graph () { + int a = 0; + switch (a) { + case 1: + return false; + default: + return true; + } + } + + static int main (string[] args) { + stdout.printf ("For Test: 1"); + + int i; + for (i = 2; i < 7; i++) { + stdout.printf (" %d", i); + } + + stdout.printf (" 7\n"); + + stdout.printf ("Switch statement: 1"); + + var foo = new Foo (); + foo.run (); + + stdout.printf (" 7\n"); + + test_switch_control_flow_graph (); + + return 0; + } +} + +class Maman.Foo : Object { + public void run () { + stdout.printf (" 2"); + + switch (23) { + case 23: + stdout.printf (" 3"); + break; + default: + stdout.printf (" BAD"); + break; + } + + switch (inc ()) { + case 0: + stdout.printf (" 4"); + break; + case 1: + stdout.printf (" BAD"); + break; + default: + stdout.printf (" BAD"); + break; + } + + switch (42) { + case 0: + stdout.printf (" BAD"); + break; + default: + stdout.printf (" 5"); + break; + case 1: + stdout.printf (" BAD"); + break; + } + + stdout.printf (" 6"); + } + + public int inc () { + return counter++; + } + + private int counter = 0; +} + |