Debian Codegraph @

gcc/testsuite/gdc.test/compilable/json.d

raw
1 // PERMUTE_ARGS:
2 // REQUIRED_ARGS: -d -preview=dip1000 -o- -X -Xf-
3 // EXTRA_FILES: imports/jsonimport1.d imports/jsonimport2.d imports/jsonimport3.d imports/jsonimport4.d
4 // TRANSFORM_OUTPUT: sanitize_json
5 // TEST_OUTPUT_FILE: extra-files/json.json
6 module json;
7
8 shared static this() {}
9 static this() {}
10 shared static ~this() {}
11 static ~this() {}
12
13 template X(T)
14 {
15 shared static this() {}
16 static this() {}
17 shared static ~this() {}
18 static ~this() {}
19 }
20
21 alias SSCDX = X!int;
22
23 class SSCDClass
24 {
25 shared static this() {}
26 static this() {}
27 shared static ~this() {}
28 static ~this() {}
29 }
30
31 #line 17
32
33 alias int myInt;
34 myInt x; // https://issues.dlang.org/show_bug.cgi?id=3404
35
36 struct Foo(T) { T t; }
37 class Bar(int T) { int t = T; }
38 interface Baz(T...) { T[0] t() const; } // https://issues.dlang.org/show_bug.cgi?id=3466
39
40 template P(alias T) {}
41
42 class Bar2 : Bar!1, Baz!(int, 2, null) {
43 this() {}
44 ~this() {} // https://issues.dlang.org/show_bug.cgi?id=4178
45
46 static foo() {}
47 protected abstract Foo!int baz();
48 override int t() const { return 0; }
49 }
50
51 class Bar3 : Bar2 {
52 private int val;
53 this(int i) { val = i; }
54
55 protected override Foo!int baz() { return Foo!int(val); }
56 }
57
58 struct Foo2 {
59 Bar2 bar2;
60 union U {
61 struct {
62 short s;
63 int i;
64 }
65 Object o;
66 }
67 }
68
69 struct Foo3(bool b) {
70 version(D_Ddoc) {
71 /// Doc 1
72 void method1();
73 }
74 static if (b) {
75 /// Doc 2
76 void method2();
77 } else {
78 /// Doc 3
79 void method3();
80 }
81
82 /// Doc 4
83 void method4();
84 }
85
86 /++
87 + Documentation test
88 +/
89 @trusted myInt bar(ref uint blah, Bar2 foo = new Bar3(7)) // https://issues.dlang.org/show_bug.cgi?id=4477
90 {
91 return -1;
92 }
93
94 @property int outer() nothrow
95 in {
96 assert(true);
97 }
98 out(result) {
99 assert(result == 18);
100 }
101 do {
102 int x = 8;
103 int inner(void* v) nothrow
104 {
105 int y = 2;
106 assert(true);
107 return x + y;
108 }
109 int z = inner(null);
110 return x + z;
111 }
112
113 /** Issue 9484 - selective and renamed imports */
114 import imports.jsonimport1 : target1, target2;
115 import imports.jsonimport2 : alias1 = target1, alias2 = target2;
116 import imports.jsonimport3 : alias3 = target1, alias4 = target2, target3;
117 import imports.jsonimport4;
118
119 struct S
120 {
121 /** Issue 9480 - Template name should be stripped of parameters */
122 this(T)(T t) { }
123 }
124
125 /** Issue 9755 - Protection not emitted properly for Templates. */
126 private struct S1_9755(T) { }
127 package struct S2_9755(T) { }
128
129 class C_9755
130 {
131 protected static class CI_9755(T) { }
132 }
133
134 /** Issue 10011 - init property is wrong for object initializer. */
135 const Object c_10011 = new Object();
136
137 ///
138 enum Numbers
139 {
140 unspecified1,
141 one = 2,
142 two = 3,
143 FILE_NOT_FOUND = 101,
144 unspecified3,
145 unspecified4,
146 four = 4,
147 }
148
149 template IncludeConstraint(T) if (T == string) {}
150
151 static foreach(enum i; 0..3)
152 {
153 mixin("int a" ~ i.stringof ~ " = 1;");
154 }
155
156 alias Seq(T...) = T;
157
158 static foreach(int i, alias a; Seq!(a0, a1, a2))
159 {
160 mixin("alias b" ~ i.stringof ~ " = a;");
161 }
162
163 // return ref, return scope, return ref scope
164 ref int foo(return ref int a) @safe
165 {
166 return a;
167 }
168
169 int* foo(return scope int* a) @safe
170 {
171 return a;
172 }
173
174 ref int* foo(scope return ref int* a) @safe
175 {
176 return a;
177 }
178
179 struct SafeS
180 {
181 @safe:
182 ref SafeS foo() return
183 {
184 return this;
185 }
186
187 SafeS foo2() return scope
188 {
189 return this;
190 }
191
192 ref SafeS foo3() return scope
193 {
194 static SafeS s; return s;
195 }
196
197 int* p;
198 }
199
200 extern int vlinkageDefault;
201 extern(D) int vlinkageD;
202 extern(C) int vlinakgeC;
203 extern(C++) __gshared int vlinkageCpp;
204 extern(Windows) int vlinkageWindows;
205 extern(Objective-C) int vlinkageObjc;
206 extern(System) int vlinkageSystem;
207 extern int flinkageDefault();
208 extern(D) int flinkageD();
209 extern(C) int linakgeC();
210 extern(C++) int flinkageCpp();
211 extern(Windows) int flinkageWindows();
212 extern(Objective-C) int flinkageObjc();
213 extern(System) int flinkageSystem();
214 mixin template test18211(int n)
215 {
216 static foreach (i; 0 .. n>10 ? 10 : n)
217 {
218 mixin("enum x" ~ cast(char)('0' + i));
219 }
220 static if (true) {}
221 }
222
223 alias F = size_t function (size_t a);