]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gdc.test/compilable/json.d
d: Import dmd b8384668f, druntime e6caaab9, phobos 5ab9ad256 (v2.098.0-beta.1)
[thirdparty/gcc.git] / gcc / testsuite / gdc.test / compilable / json.d
CommitLineData
b4c522fa 1// PERMUTE_ARGS:
5fee5ec3 2// REQUIRED_ARGS: -d -preview=dip1000 -o- -X -Xf-
b4c522fa 3// EXTRA_FILES: imports/jsonimport1.d imports/jsonimport2.d imports/jsonimport3.d imports/jsonimport4.d
5fee5ec3
IB
4// TRANSFORM_OUTPUT: sanitize_json
5// TEST_OUTPUT_FILE: extra-files/json.json
b4c522fa
IB
6module json;
7
5fee5ec3 8shared static this() {}
b4c522fa 9static this() {}
5fee5ec3 10shared static ~this() {}
b4c522fa
IB
11static ~this() {}
12
5fee5ec3
IB
13template X(T)
14{
15 shared static this() {}
16 static this() {}
17 shared static ~this() {}
18 static ~this() {}
19}
20
21alias SSCDX = X!int;
22
23class SSCDClass
24{
25 shared static this() {}
26 static this() {}
27 shared static ~this() {}
28 static ~this() {}
29}
30
31#line 17
b4c522fa
IB
32
33alias int myInt;
5fee5ec3 34myInt x; // https://issues.dlang.org/show_bug.cgi?id=3404
b4c522fa
IB
35
36struct Foo(T) { T t; }
37class Bar(int T) { int t = T; }
5fee5ec3 38interface Baz(T...) { T[0] t() const; } // https://issues.dlang.org/show_bug.cgi?id=3466
b4c522fa
IB
39
40template P(alias T) {}
41
42class Bar2 : Bar!1, Baz!(int, 2, null) {
43 this() {}
5fee5ec3 44 ~this() {} // https://issues.dlang.org/show_bug.cgi?id=4178
b4c522fa
IB
45
46 static foo() {}
47 protected abstract Foo!int baz();
48 override int t() const { return 0; }
49}
50
51class Bar3 : Bar2 {
5fee5ec3 52 private int val;
b4c522fa
IB
53 this(int i) { val = i; }
54
55 protected override Foo!int baz() { return Foo!int(val); }
56}
57
58struct Foo2 {
5fee5ec3
IB
59 Bar2 bar2;
60 union U {
61 struct {
62 short s;
63 int i;
64 }
65 Object o;
66 }
67}
68
69struct 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();
b4c522fa
IB
84}
85
86/++
87 + Documentation test
88 +/
5fee5ec3 89@trusted myInt bar(ref uint blah, Bar2 foo = new Bar3(7)) // https://issues.dlang.org/show_bug.cgi?id=4477
b4c522fa 90{
5fee5ec3 91 return -1;
b4c522fa
IB
92}
93
94@property int outer() nothrow
95in {
5fee5ec3 96 assert(true);
b4c522fa
IB
97}
98out(result) {
5fee5ec3 99 assert(result == 18);
b4c522fa 100}
5fee5ec3
IB
101do {
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;
b4c522fa
IB
111}
112
113/** Issue 9484 - selective and renamed imports */
114import imports.jsonimport1 : target1, target2;
115import imports.jsonimport2 : alias1 = target1, alias2 = target2;
116import imports.jsonimport3 : alias3 = target1, alias4 = target2, target3;
117import imports.jsonimport4;
118
119struct 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. */
126private struct S1_9755(T) { }
127package struct S2_9755(T) { }
128
129class C_9755
130{
131 protected static class CI_9755(T) { }
132}
133
134/** Issue 10011 - init property is wrong for object initializer. */
135const Object c_10011 = new Object();
136
137///
138enum Numbers
139{
140 unspecified1,
141 one = 2,
142 two = 3,
143 FILE_NOT_FOUND = 101,
144 unspecified3,
145 unspecified4,
146 four = 4,
147}
148
149template IncludeConstraint(T) if (T == string) {}
5b74dd0a
IB
150
151static foreach(enum i; 0..3)
152{
153 mixin("int a" ~ i.stringof ~ " = 1;");
154}
155
156alias Seq(T...) = T;
157
158static foreach(int i, alias a; Seq!(a0, a1, a2))
159{
5fee5ec3
IB
160 mixin("alias b" ~ i.stringof ~ " = a;");
161}
162
163// return ref, return scope, return ref scope
164ref int foo(return ref int a) @safe
165{
166 return a;
5b74dd0a
IB
167}
168
5fee5ec3
IB
169int* foo(return scope int* a) @safe
170{
171 return a;
172}
173
174ref int* foo(scope return ref int* a) @safe
175{
176 return a;
177}
178
179struct 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 return this;
195 }
196
197 int* p;
198}
199
200extern int vlinkageDefault;
201extern(D) int vlinkageD;
202extern(C) int vlinakgeC;
203extern(C++) __gshared int vlinkageCpp;
204extern(Windows) int vlinkageWindows;
205extern(Objective-C) int vlinkageObjc;
206
207extern int flinkageDefault();
208extern(D) int flinkageD();
209extern(C) int linakgeC();
210extern(C++) int flinkageCpp();
211extern(Windows) int flinkageWindows();
212extern(Objective-C) int flinkageObjc();
213
5b74dd0a
IB
214mixin 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}
5fee5ec3
IB
222
223alias F = size_t function (size_t a);