-
-
Notifications
You must be signed in to change notification settings - Fork 606
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix Issue 4018 - __FILE__ and __LINE__ as default template parameters…
… not set to instantiation point per spec Also fixes __MODULE__, __FUNCITON__, and __PRETTY_FUNCTION__
- Loading branch information
Showing
7 changed files
with
200 additions
and
106 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
module imports.testkwd; | ||
|
||
/****************************************/ | ||
|
||
version(Windows) enum sep = "\\"; else enum sep = "/"; | ||
|
||
enum thatFile = "runnable"~sep~"imports"~sep~"testkwd_file.d"; | ||
enum thatMod = "imports.testkwd"; | ||
//enum thatLine; | ||
enum thatFunc = "imports.testkwd.getCalleeFunc"; | ||
enum thatFunc2 = `string imports.testkwd.getCalleeFunc2(int x = 1, string s = "hello")`; | ||
|
||
string getCalleeFile() { return __FILE__; } | ||
ulong getCalleeLine() { return __LINE__; } enum thatLine = 14; | ||
string getCalleeMod() { return __MODULE__; } | ||
string getCalleeFunc() { return __FUNCTION__; } | ||
string getCalleeFunc2(int x = 1, string s = "hello") { return __PRETTY_FUNCTION__; } | ||
|
||
/****************************************/ | ||
|
||
string getFuncArgFile (string name = __FILE__ ) { return name; } | ||
ulong getFuncArgLine (ulong lnum = __LINE__ ) { return lnum; } | ||
string getFuncArgMod (string name = __MODULE__ ) { return name; } | ||
string getFuncArgFunc (string name = __FUNCTION__ ) { return name; } | ||
string getFuncArgFunc2(string name = __PRETTY_FUNCTION__) { return name; } | ||
|
||
string getFuncTiargFile (string name = __FILE__ )() { return name; } | ||
ulong getFuncTiargLine (ulong lnum = __LINE__ )() { return lnum; } | ||
string getFuncTiargMod (string name = __MODULE__ )() { return name; } | ||
string getFuncTiargFunc (string name = __FUNCTION__ )() { return name; } | ||
string getFuncTiargFunc2(string name = __PRETTY_FUNCTION__)() { return name; } | ||
|
||
template getInstTiargFile (string name = __FILE__ ) { enum getInstTiargFile = name; } | ||
template getInstTiargLine (ulong lnum = __LINE__ ) { enum getInstTiargLine = lnum; } | ||
template getInstTiargMod (string name = __MODULE__ ) { enum getInstTiargMod = name; } | ||
template getInstTiargFunc (string name = __FUNCTION__ ) { enum getInstTiargFunc = name; } | ||
template getInstTiargFunc2(string name = __PRETTY_FUNCTION__) { enum getInstTiargFunc2 = name; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,152 @@ | ||
// PERMUTE_ARGS: | ||
// EXTRA_SOURCES: imports/testkwd_file.d | ||
module testkeyword; | ||
import imports.testkwd; | ||
|
||
/****************************************/ | ||
// calee test | ||
|
||
static assert(getCalleeFile() == thatFile); | ||
static assert(getCalleeLine() == thatLine); | ||
static assert(getCalleeMod() == thatMod); | ||
static assert(getCalleeFunc() == thatFunc); | ||
static assert(getCalleeFunc2() == thatFunc2); | ||
|
||
void testCallee() | ||
{ | ||
static assert(getCalleeFile() == thatFile); | ||
static assert(getCalleeLine() == thatLine); | ||
static assert(getCalleeMod() == thatMod); | ||
static assert(getCalleeFunc() == thatFunc); | ||
static assert(getCalleeFunc2() == thatFunc2); | ||
} | ||
|
||
/****************************************/ | ||
// caller test | ||
|
||
version(Windows) enum sep = "\\"; else enum sep = "/"; | ||
|
||
enum thisFile = "runnable"~sep~"testkeyword.d"; | ||
enum thisMod = "testkeyword"; | ||
|
||
static assert(getFuncArgFile() == thisFile); | ||
static assert(getFuncArgLine() == 33); | ||
static assert(getFuncArgMod() == thisMod); | ||
static assert(getFuncArgFunc() == ""); | ||
static assert(getFuncArgFunc2() == ""); | ||
|
||
static assert(getFuncTiargFile() == thisFile); | ||
static assert(getFuncTiargLine() == 39); | ||
static assert(getFuncTiargMod() == thisMod); | ||
static assert(getFuncTiargFunc() == ""); | ||
static assert(getFuncTiargFunc2() == ""); | ||
|
||
static assert(getInstTiargFile!() == thisFile); | ||
static assert(getInstTiargLine!() == 45); | ||
static assert(getInstTiargMod!() == thisMod); | ||
static assert(getInstTiargFunc!() == ""); | ||
static assert(getInstTiargFunc2!() == ""); | ||
|
||
void main(string[] args) nothrow | ||
{ | ||
enum thisFunc = "testkeyword.main"; | ||
enum thisFunc2 = "void testkeyword.main(string[] args) nothrow"; | ||
|
||
static assert(getFuncArgFile() == thisFile); | ||
static assert(getFuncArgLine() == 56); | ||
static assert(getFuncArgMod() == thisMod); | ||
static assert(getFuncArgFunc() == thisFunc); | ||
static assert(getFuncArgFunc2() == thisFunc2); | ||
|
||
static assert(getFuncTiargFile() == thisFile); | ||
static assert(getFuncTiargLine() == 62); | ||
static assert(getFuncTiargMod() == thisMod); | ||
static assert(getFuncTiargFunc() == thisFunc); | ||
static assert(getFuncTiargFunc2() == thisFunc2); | ||
|
||
static assert(getInstTiargFile!() == thisFile); | ||
static assert(getInstTiargLine!() == 68); | ||
static assert(getInstTiargMod!() == thisMod); | ||
static assert(getInstTiargFunc!() == thisFunc); | ||
static assert(getInstTiargFunc2!() == thisFunc2); | ||
|
||
void nested(int x, float y) nothrow | ||
{ | ||
enum thisFunc = "testkeyword.main.nested"; | ||
enum thisFunc2 = "void testkeyword.main.nested(int x, float y) nothrow"; | ||
|
||
static assert(getFuncArgFile() == thisFile); | ||
static assert(getFuncArgLine() == 79); | ||
static assert(getFuncArgMod() == thisMod); | ||
static assert(getFuncArgFunc() == thisFunc); | ||
static assert(getFuncArgFunc2() == thisFunc2); | ||
|
||
static assert(getFuncTiargFile() == thisFile); | ||
static assert(getFuncTiargLine() == 85); | ||
static assert(getFuncTiargMod() == thisMod); | ||
static assert(getFuncTiargFunc() == thisFunc); | ||
static assert(getFuncTiargFunc2() == thisFunc2); | ||
|
||
static assert(getInstTiargFile!() == thisFile); | ||
static assert(getInstTiargLine!() == 91); | ||
static assert(getInstTiargMod!() == thisMod); | ||
static assert(getInstTiargFunc!() == thisFunc); | ||
static assert(getInstTiargFunc2!() == thisFunc2); | ||
} | ||
nested(1, 1.0); | ||
|
||
auto funcLiteral = (int x, int y) | ||
{ | ||
enum thisFunc = "testkeyword.main.__lambda3"; | ||
enum thisFunc2 = "testkeyword.main.__lambda3(int x, int y)"; | ||
|
||
static assert(getFuncArgFile() == thisFile); | ||
static assert(getFuncArgLine() == 104); | ||
static assert(getFuncArgMod() == thisMod); | ||
static assert(getFuncArgFunc() == thisFunc); | ||
static assert(getFuncArgFunc2() == thisFunc2); | ||
|
||
static assert(getFuncTiargFile() == thisFile); | ||
static assert(getFuncTiargLine() == 110); | ||
static assert(getFuncTiargMod() == thisMod); | ||
static assert(getFuncTiargFunc() == thisFunc); | ||
static assert(getFuncTiargFunc2() == thisFunc2); | ||
|
||
static assert(getInstTiargFile!() == thisFile); | ||
static assert(getInstTiargLine!() == 116); | ||
static assert(getInstTiargMod!() == thisMod); | ||
static assert(getInstTiargFunc!() == thisFunc); | ||
static assert(getInstTiargFunc2!() == thisFunc2); | ||
}; | ||
funcLiteral(1, 2); | ||
|
||
static struct S | ||
{ | ||
void func(string cs, T1, alias T2, T...)(int x) const | ||
{ | ||
enum thisFunc = `testkeyword.main.S.func!("foo", int, symbol, int[], float[]).func`; | ||
enum thisFunc2 = `void testkeyword.main.S.func!("foo", int, symbol, int[], float[]).func(int x) const`; | ||
|
||
static assert(getFuncArgFile() == thisFile); | ||
static assert(getFuncArgLine() == 131); | ||
static assert(getFuncArgMod() == thisMod); | ||
static assert(getFuncArgFunc() == thisFunc); | ||
static assert(getFuncArgFunc2() == thisFunc2); | ||
|
||
static assert(getFuncTiargFile() == thisFile); | ||
static assert(getFuncTiargLine() == 137); | ||
static assert(getFuncTiargMod() == thisMod); | ||
static assert(getFuncTiargFunc() == thisFunc); | ||
static assert(getFuncTiargFunc2() == thisFunc2); | ||
|
||
static assert(getInstTiargFile!() == thisFile); | ||
static assert(getInstTiargLine!() == 143); | ||
static assert(getInstTiargMod!() == thisMod); | ||
static assert(getInstTiargFunc!() == thisFunc); | ||
static assert(getInstTiargFunc2!() == thisFunc2); | ||
} | ||
} | ||
static int symbol; | ||
S s; | ||
s.func!("foo", int, symbol, int[], float[])(1); | ||
} |