1 // PERMUTE_ARGS:
2 // EXTRA_SOURCES: imports/testkwd_file.d
3 module testkeyword;
4 import imports.testkwd;
5
6 /****************************************/
7 // calee test
8
9 static assert(getCalleeFile() == thatFile);
10 static assert(getCalleeLine() == thatLine);
11 static assert(getCalleeMod() == thatMod);
12 static assert(getCalleeFunc() == thatFunc);
13 static assert(getCalleeFunc2() == thatFunc2);
14
testCallee()15 void testCallee()
16 {
17 static assert(getCalleeFile() == thatFile);
18 static assert(getCalleeLine() == thatLine);
19 static assert(getCalleeMod() == thatMod);
20 static assert(getCalleeFunc() == thatFunc);
21 static assert(getCalleeFunc2() == thatFunc2);
22 }
23
24 /****************************************/
25 // caller test
26
27 version(Windows) enum sep = "\\"; else enum sep = "/";
28
29 enum thisFile = "runnable"~sep~"testkeyword.d";
30 enum thisMod = "testkeyword";
31
32 static assert(getFuncArgFile() == thisFile);
33 static assert(getFuncArgLine() == 33);
34 static assert(getFuncArgMod() == thisMod);
35 static assert(getFuncArgFunc() == "");
36 static assert(getFuncArgFunc2() == "");
37
38 static assert(getFuncTiargFile() == thisFile);
39 static assert(getFuncTiargLine() == 39);
40 static assert(getFuncTiargMod() == thisMod);
41 static assert(getFuncTiargFunc() == "");
42 static assert(getFuncTiargFunc2() == "");
43
44 static assert(getInstTiargFile!() == thisFile);
45 static assert(getInstTiargLine!() == 45);
46 static assert(getInstTiargMod!() == thisMod);
47 static assert(getInstTiargFunc!() == "");
48 static assert(getInstTiargFunc2!() == "");
49
main(string[]args)50 void main(string[] args) nothrow
51 {
52 enum thisFunc = "testkeyword.main";
53 enum thisFunc2 = "void testkeyword.main(string[] args) nothrow";
54
55 static assert(getFuncArgFile() == thisFile);
56 static assert(getFuncArgLine() == 56);
57 static assert(getFuncArgMod() == thisMod);
58 static assert(getFuncArgFunc() == thisFunc);
59 static assert(getFuncArgFunc2() == thisFunc2);
60
61 static assert(getFuncTiargFile() == thisFile);
62 static assert(getFuncTiargLine() == 62);
63 static assert(getFuncTiargMod() == thisMod);
64 static assert(getFuncTiargFunc() == thisFunc);
65 static assert(getFuncTiargFunc2() == thisFunc2);
66
67 static assert(getInstTiargFile!() == thisFile);
68 static assert(getInstTiargLine!() == 68);
69 static assert(getInstTiargMod!() == thisMod);
70 static assert(getInstTiargFunc!() == thisFunc);
71 static assert(getInstTiargFunc2!() == thisFunc2);
72
73 void nested(int x, float y) nothrow
74 {
75 enum thisFunc = "testkeyword.main.nested";
76 enum thisFunc2 = "void testkeyword.main.nested(int x, float y) nothrow";
77
78 static assert(getFuncArgFile() == thisFile);
79 static assert(getFuncArgLine() == 79);
80 static assert(getFuncArgMod() == thisMod);
81 static assert(getFuncArgFunc() == thisFunc);
82 static assert(getFuncArgFunc2() == thisFunc2);
83
84 static assert(getFuncTiargFile() == thisFile);
85 static assert(getFuncTiargLine() == 85);
86 static assert(getFuncTiargMod() == thisMod);
87 static assert(getFuncTiargFunc() == thisFunc);
88 static assert(getFuncTiargFunc2() == thisFunc2);
89
90 static assert(getInstTiargFile!() == thisFile);
91 static assert(getInstTiargLine!() == 91);
92 static assert(getInstTiargMod!() == thisMod);
93 static assert(getInstTiargFunc!() == thisFunc);
94 static assert(getInstTiargFunc2!() == thisFunc2);
95 }
96 nested(1, 1.0);
97
98 auto funcLiteral = (int x, int y)
99 {
100 enum thisFunc = "testkeyword.main.__lambda3";
101 enum thisFunc2 = "testkeyword.main.__lambda3(int x, int y)";
102
103 static assert(getFuncArgFile() == thisFile);
104 static assert(getFuncArgLine() == 104);
105 static assert(getFuncArgMod() == thisMod);
106 static assert(getFuncArgFunc() == thisFunc);
107 static assert(getFuncArgFunc2() == thisFunc2);
108
109 static assert(getFuncTiargFile() == thisFile);
110 static assert(getFuncTiargLine() == 110);
111 static assert(getFuncTiargMod() == thisMod);
112 static assert(getFuncTiargFunc() == thisFunc);
113 static assert(getFuncTiargFunc2() == thisFunc2);
114
115 static assert(getInstTiargFile!() == thisFile);
116 static assert(getInstTiargLine!() == 116);
117 static assert(getInstTiargMod!() == thisMod);
118 static assert(getInstTiargFunc!() == thisFunc);
119 static assert(getInstTiargFunc2!() == thisFunc2);
120 };
121 funcLiteral(1, 2);
122
123 static struct S
124 {
125 void func(string cs, T1, alias T2, T...)(int x) const
126 {
127 enum thisFunc = `testkeyword.main.S.func!("foo", int, symbol, int[], float[]).func`;
128 enum thisFunc2 = `void testkeyword.main.S.func!("foo", int, symbol, int[], float[]).func(int x) const`;
129
130 static assert(getFuncArgFile() == thisFile);
131 static assert(getFuncArgLine() == 131);
132 static assert(getFuncArgMod() == thisMod);
133 static assert(getFuncArgFunc() == thisFunc);
134 static assert(getFuncArgFunc2() == thisFunc2);
135
136 static assert(getFuncTiargFile() == thisFile);
137 static assert(getFuncTiargLine() == 137);
138 static assert(getFuncTiargMod() == thisMod);
139 static assert(getFuncTiargFunc() == thisFunc);
140 static assert(getFuncTiargFunc2() == thisFunc2);
141
142 static assert(getInstTiargFile!() == thisFile);
143 static assert(getInstTiargLine!() == 143);
144 static assert(getInstTiargMod!() == thisMod);
145 static assert(getInstTiargFunc!() == thisFunc);
146 static assert(getInstTiargFunc2!() == thisFunc2);
147 }
148 }
149 static int symbol;
150 S s;
151 s.func!("foo", int, symbol, int[], float[])(1);
152 }
153