mirror of
https://github.com/dlang/phobos.git
synced 2025-04-28 06:00:35 +03:00
Merge pull request #2923 from yebblies/arraybool9999
Replace more implicit array to bool conversions
This commit is contained in:
commit
dfbd50636c
7 changed files with 20 additions and 20 deletions
|
@ -2378,7 +2378,7 @@ Target parse(Target, Source)(ref Source p)
|
|||
|
||||
ConvException bailOut()(string msg = null, string fn = __FILE__, size_t ln = __LINE__)
|
||||
{
|
||||
if (!msg)
|
||||
if (msg == null)
|
||||
msg = "Floating point conversion error";
|
||||
return new ConvException(text(msg, " for input \"", p, "\"."), fn, ln);
|
||||
}
|
||||
|
|
|
@ -4857,9 +4857,9 @@ body
|
|||
enforce(i <= T.length);
|
||||
}
|
||||
|
||||
if (spec.sep)
|
||||
if (spec.sep != null)
|
||||
fmt.readUpToNextSpec(input);
|
||||
auto sep = spec.sep ? spec.sep
|
||||
auto sep = spec.sep != null ? spec.sep
|
||||
: fmt.trailing;
|
||||
debug (unformatRange) {
|
||||
if (!sep.empty && !input.empty) printf("-> %c, sep = %.*s\n", input.front, sep);
|
||||
|
|
|
@ -718,7 +718,7 @@ JSONValue parseJSON(T)(T json, int maxDepth = -1) if(isInputRange!T)
|
|||
goto Next;
|
||||
}
|
||||
|
||||
return str.data ? str.data : "";
|
||||
return str.data.length ? str.data : "";
|
||||
}
|
||||
|
||||
void parseValue(JSONValue* value)
|
||||
|
|
|
@ -879,7 +879,7 @@ unittest // Specifying empty working directory.
|
|||
TestScript prog = "";
|
||||
|
||||
string directory = "";
|
||||
assert(directory && !directory.length);
|
||||
assert(directory.ptr && !directory.length);
|
||||
spawnProcess([prog.path], null, Config.none, directory).wait();
|
||||
}
|
||||
|
||||
|
|
|
@ -8053,7 +8053,7 @@ unittest
|
|||
assert(wrapper[2] == 2);
|
||||
assert(arr == [1, 42, 2, 41, 3, 40, 4, 42, 9]);
|
||||
|
||||
assert(*wrapper[3 .. 6].ptr, [41, 3, 40]);
|
||||
assert(*wrapper[3 .. 6].ptr != null, [41, 3, 40]);
|
||||
assert(arr == [1, 42, 2, 41, 3, 40, 4, 42, 9]);
|
||||
}
|
||||
|
||||
|
|
|
@ -252,7 +252,7 @@ mixin template Signal(T1...)
|
|||
* know that this object is destroyed so they are not left
|
||||
* with dangling references to it.
|
||||
*/
|
||||
if (slots)
|
||||
if (slots.length)
|
||||
{
|
||||
foreach (slot; slots[0 .. slots_idx])
|
||||
{
|
||||
|
@ -386,20 +386,20 @@ unittest {
|
|||
a.s2.connect(&o2.watchInt);
|
||||
a.s3.connect(&o3.watchLong);
|
||||
|
||||
assert(!o1.i && !o1.l && !o1.str);
|
||||
assert(!o2.i && !o2.l && !o2.str);
|
||||
assert(!o3.i && !o3.l && !o3.str);
|
||||
assert(!o1.i && !o1.l && o1.str == null);
|
||||
assert(!o2.i && !o2.l && o2.str == null);
|
||||
assert(!o3.i && !o3.l && o3.str == null);
|
||||
|
||||
a.value1 = 11;
|
||||
assert(o1.i == 11 && !o1.l && o1.str == "str1");
|
||||
assert(!o2.i && !o2.l && !o2.str);
|
||||
assert(!o3.i && !o3.l && !o3.str);
|
||||
assert(!o2.i && !o2.l && o2.str == null);
|
||||
assert(!o3.i && !o3.l && o3.str == null);
|
||||
o1.i = -11; o1.str = "x1";
|
||||
|
||||
a.value2 = 12;
|
||||
assert(o1.i == -11 && !o1.l && o1.str == "x1");
|
||||
assert(o2.i == 12 && !o2.l && o2.str == "str2");
|
||||
assert(!o3.i && !o3.l && !o3.str);
|
||||
assert(!o3.i && !o3.l && o3.str == null);
|
||||
o2.i = -12; o2.str = "x2";
|
||||
|
||||
a.value3 = 13;
|
||||
|
@ -468,20 +468,20 @@ unittest {
|
|||
a.s5.connect(&o5.watchInt);
|
||||
a.s6.connect(&o6.watchLong);
|
||||
|
||||
assert(!o4.i && !o4.l && !o4.str);
|
||||
assert(!o5.i && !o5.l && !o5.str);
|
||||
assert(!o6.i && !o6.l && !o6.str);
|
||||
assert(!o4.i && !o4.l && o4.str == null);
|
||||
assert(!o5.i && !o5.l && o5.str == null);
|
||||
assert(!o6.i && !o6.l && o6.str == null);
|
||||
|
||||
a.value4 = 44;
|
||||
assert(o4.i == 44 && !o4.l && o4.str == "str4");
|
||||
assert(!o5.i && !o5.l && !o5.str);
|
||||
assert(!o6.i && !o6.l && !o6.str);
|
||||
assert(!o5.i && !o5.l && o5.str == null);
|
||||
assert(!o6.i && !o6.l && o6.str == null);
|
||||
o4.i = -44; o4.str = "x4";
|
||||
|
||||
a.value5 = 45;
|
||||
assert(o4.i == -44 && !o4.l && o4.str == "x4");
|
||||
assert(o5.i == 45 && !o5.l && o5.str == "str5");
|
||||
assert(!o6.i && !o6.l && !o6.str);
|
||||
assert(!o6.i && !o6.l && o6.str == null);
|
||||
o5.i = -45; o5.str = "x5";
|
||||
|
||||
a.value6 = 46;
|
||||
|
|
|
@ -3175,7 +3175,7 @@ body
|
|||
assert(translate(to!S("hello world"), makeTrans("hl", "q5")) == to!S("qe55o wor5d"));
|
||||
assert(translate(to!S("hello \U00010143 world"), makeTrans("hl", "q5")) ==
|
||||
to!S("qe55o \U00010143 wor5d"));
|
||||
assert(translate(to!S("hello world"), makeTrans("ol", "1o")), to!S("heool wlrdd"));
|
||||
assert(translate(to!S("hello world"), makeTrans("ol", "1o")) == to!S("heoo1 w1rod"));
|
||||
assert(translate(to!S("hello world"), makeTrans("", "")) == to!S("hello world"));
|
||||
assert(translate(to!S("hello world"), makeTrans("12345", "67890")) == to!S("hello world"));
|
||||
assert(translate(to!S("hello \U00010143 world"), makeTrans("12345", "67890")) ==
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue