gcc/testsuite/gdc.test/runnable/test7603.d
raw| 1 | void test7603() |
| 2 | { |
| 3 | int g; |
| 4 | void foo(int n, ref int r = g) { r = n; } |
| 5 | |
| 6 | int x; |
| 7 | foo(1, x); |
| 8 | assert(x == 1); |
| 9 | |
| 10 | foo(2); |
| 11 | assert(g == 2); |
| 12 | |
| 13 | int h = 100; |
| 14 | void bar(int n, out int r = h) { if (n != 0) r = n; } |
| 15 | |
| 16 | bar(0); |
| 17 | assert(h == 0); |
| 18 | |
| 19 | bar(10); |
| 20 | assert(h == 10); |
| 21 | |
| 22 | bar(10, x); |
| 23 | assert(x == 10); |
| 24 | |
| 25 | bar(0, x); |
| 26 | assert(x == 0); |
| 27 | |
| 28 | } |
| 29 | |
| 30 | void main() { test7603(); } |