Debian Codegraph @

gcc/testsuite/gdc.test/runnable/test16579.d

raw
1 // REQUIRED_ARGS: -unittest
2 // PERMUTE_ARGS:
3 // https://issues.dlang.org/show_bug.cgi?id=16579
4
5 struct Thing
6 {
7 enum Instance = Thing();
8 int a = 42;
9
10 void iter()
11 {
12 assert(this.a == 42);
13 }
14 }
15
16 void main()
17 {
18 return Thing.Instance.iter; // Added 'return'
19 }
20
21 // From https://issues.dlang.org/show_bug.cgi?id=16576
22
23 alias a = test2!();
24 alias b = test3!();
25
26
27 template test2()
28 {
29 struct Thing{
30 static enum Instance = Thing([0, 1, 2, 3]);
31 int[] array;
32 void iter(in string str) const{
33 foreach(j, tup; this.array) assert(tup == j);
34 assert(this.array && this.array.length == 4);
35 }
36 }
37 unittest{
38 auto test(in string str){return Thing.Instance.iter(str);}
39 test("?");
40 }
41 }
42
43 template test3()
44 {
45 struct Thing{
46 static enum Instance = Thing([0, 1, 2, 3]);
47 int[] array;
48 void iter() const{
49 foreach(j, tup; this.array) assert(tup == j);
50 assert(this.array && this.array.length == 4);
51 }
52 }
53 unittest{
54 auto test(){return Thing.Instance.iter();}
55 test();
56 }
57 }