-
-
Notifications
You must be signed in to change notification settings - Fork 747
Remove version(unittest) imports to avoid extra imports in user code. #6451
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5337,6 +5337,7 @@ version(unittest) private class __conv_EmplaceTestClass | |
| assert(s.i == 2); | ||
| } | ||
| } | ||
|
|
||
| version(unittest) | ||
| { | ||
| //Ambiguity | ||
|
|
@@ -5357,16 +5358,17 @@ version(unittest) | |
| ref __std_conv_S foo() return @property {s.i = j; return s;} | ||
| alias foo this; | ||
| } | ||
| } | ||
|
|
||
| @system unittest | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not a fan of unittests being inside |
||
| { | ||
| static assert(is(__std_conv_SS : __std_conv_S)); | ||
| @system unittest | ||
| { | ||
| __std_conv_S s = void; | ||
| __std_conv_SS ss = __std_conv_SS(1); | ||
| __std_conv_S s = void; | ||
| __std_conv_SS ss = __std_conv_SS(1); | ||
|
|
||
| __std_conv_S sTest1 = ss; //this calls "SS alias this" (and not "S.this(SS)") | ||
| emplace(&s, ss); //"alias this" should take precedence in emplace over "opCall" | ||
| assert(s.i == 1); | ||
| } | ||
| __std_conv_S sTest1 = ss; //this calls "SS alias this" (and not "S.this(SS)") | ||
| emplace(&s, ss); //"alias this" should take precedence in emplace over "opCall" | ||
| assert(s.i == 1); | ||
| } | ||
|
|
||
| //Nested classes | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -281,6 +281,55 @@ import std.typecons; | |
| "\uFFFD","\uFFFD","\uFFFD","\uFFFD","\uFFFD","\uFFFD","\uFFFD","\uFFFD", | ||
| ]; | ||
|
|
||
| // HELPER FUNCTIONS | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Note, these were copied as-is to this unittest. I'm not in love with the implementation, but wanted to keep the PR simple.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This movaroo wasn't quite needed because it doesn't import anything. But fine by me. |
||
| // we can probably do this better... | ||
| static char toHexDigit(int n) | ||
| { | ||
| return "0123456789ABCDEF"[n & 0xF]; | ||
| } | ||
|
|
||
| static string makeReadable(string s) | ||
| { | ||
| string r = "\""; | ||
| foreach (char c;s) | ||
| { | ||
| if (c >= 0x20 && c < 0x80) | ||
| { | ||
| r ~= c; | ||
| } | ||
| else | ||
| { | ||
| r ~= "\\x"; | ||
| r ~= toHexDigit(c >> 4); | ||
| r ~= toHexDigit(c); | ||
| } | ||
| } | ||
| r ~= "\""; | ||
| return r; | ||
| } | ||
|
|
||
| void transcodeReverse(Src,Dst)(immutable(Src)[] s, out immutable(Dst)[] r) | ||
| { | ||
| static if (is(Src == Dst)) | ||
| { | ||
| return s; | ||
| } | ||
| else static if (is(Src == AsciiChar)) | ||
| { | ||
| transcodeReverse!(char,Dst)(cast(string) s,r); | ||
| } | ||
| else | ||
| { | ||
| foreach_reverse (d;codePoints(s)) | ||
| { | ||
| foreach_reverse (c;codeUnits!(Dst)(d)) | ||
| { | ||
| r = c ~ r; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| // Make sure everything that should be valid, is | ||
| foreach (a;validStrings) | ||
| { | ||
|
|
@@ -3633,111 +3682,6 @@ class EncodingSchemeUtf32Native : EncodingScheme | |
| //============================================================================= | ||
|
|
||
|
|
||
| // Helper functions | ||
| version(unittest) | ||
| { | ||
| void transcodeReverse(Src,Dst)(immutable(Src)[] s, out immutable(Dst)[] r) | ||
| { | ||
| static if (is(Src == Dst)) | ||
| { | ||
| return s; | ||
| } | ||
| else static if (is(Src == AsciiChar)) | ||
| { | ||
| transcodeReverse!(char,Dst)(cast(string) s,r); | ||
| } | ||
| else | ||
| { | ||
| foreach_reverse (d;codePoints(s)) | ||
| { | ||
| foreach_reverse (c;codeUnits!(Dst)(d)) | ||
| { | ||
| r = c ~ r; | ||
| } | ||
| } | ||
| } | ||
| } | ||
|
|
||
| string makeReadable(string s) | ||
| { | ||
| string r = "\""; | ||
| foreach (char c;s) | ||
| { | ||
| if (c >= 0x20 && c < 0x80) | ||
| { | ||
| r ~= c; | ||
| } | ||
| else | ||
| { | ||
| r ~= "\\x"; | ||
| r ~= toHexDigit(c >> 4); | ||
| r ~= toHexDigit(c); | ||
| } | ||
| } | ||
| r ~= "\""; | ||
| return r; | ||
| } | ||
|
|
||
| string makeReadable(wstring s) | ||
| { | ||
| string r = "\""; | ||
| foreach (wchar c;s) | ||
| { | ||
| if (c >= 0x20 && c < 0x80) | ||
| { | ||
| r ~= cast(char) c; | ||
| } | ||
| else | ||
| { | ||
| r ~= "\\u"; | ||
| r ~= toHexDigit(c >> 12); | ||
| r ~= toHexDigit(c >> 8); | ||
| r ~= toHexDigit(c >> 4); | ||
| r ~= toHexDigit(c); | ||
| } | ||
| } | ||
| r ~= "\"w"; | ||
| return r; | ||
| } | ||
|
|
||
| string makeReadable(dstring s) | ||
| { | ||
| string r = "\""; | ||
| foreach (dchar c; s) | ||
| { | ||
| if (c >= 0x20 && c < 0x80) | ||
| { | ||
| r ~= cast(char) c; | ||
| } | ||
| else if (c < 0x10000) | ||
| { | ||
| r ~= "\\u"; | ||
| r ~= toHexDigit(c >> 12); | ||
| r ~= toHexDigit(c >> 8); | ||
| r ~= toHexDigit(c >> 4); | ||
| r ~= toHexDigit(c); | ||
| } | ||
| else | ||
| { | ||
| r ~= "\\U00"; | ||
| r ~= toHexDigit(c >> 20); | ||
| r ~= toHexDigit(c >> 16); | ||
| r ~= toHexDigit(c >> 12); | ||
| r ~= toHexDigit(c >> 8); | ||
| r ~= toHexDigit(c >> 4); | ||
| r ~= toHexDigit(c); | ||
| } | ||
| } | ||
| r ~= "\"d"; | ||
| return r; | ||
| } | ||
|
|
||
| char toHexDigit(int n) | ||
| { | ||
| return "0123456789ABCDEF"[n & 0xF]; | ||
| } | ||
| } | ||
|
|
||
| /** Definitions of common Byte Order Marks. | ||
| The elements of the `enum` can used as indices into `bomTable` to get | ||
| matching `BOMSeq`. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since in-function structs depend on the order defined, these have to be defined at module-level. Did not work if I put it inside the unittest itself.
But these structs are super-simple, and have no external dependencies.