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