Skip to content

Commit 2d0281f

Browse files
authored
Merge pull request #6291 from JackStouffer/conv-examples
Add public examples to std.conv and enable dscanner check
2 parents a5eb8e2 + 6f2c09c commit 2d0281f

File tree

2 files changed

+38
-11
lines changed

2 files changed

+38
-11
lines changed

.dscanner.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ exception_check="-std.concurrency,-std.net.curl,-std.parallelism,-std.range,-std
124124
; Checks for poor placement of function attributes
125125
function_attribute_check="-std.algorithm.iteration,-std.concurrency,-std.conv,-std.datetime.interval,-std.exception,-std.functional,-std.net.curl,-std.numeric,-std.parallelism,-std.random,-std.range,-std.range.primitives,-std.socket,-std.traits,-std.typecons,-std.uni"
126126
; Check for public declarations without a documented unittest
127-
has_public_example="-etc.c.curl,-etc.c.sqlite3,-etc.c.zlib,-std.bitmanip,-std.complex,-std.concurrency,-std.container.array,-std.container.dlist,-std.container.rbtree,-std.container.slist,-std.conv,-std.csv,-std.datetime,-std.datetime.date,-std.datetime.interval,-std.datetime.stopwatch,-std.datetime.systime,-std.datetime.timezone,-std.demangle,-std.digest,-std.digest.hmac,-std.digest.murmurhash,-std.digest.sha,-std.encoding,-std.exception,-std.experimental.allocator,-std.experimental.allocator.building_blocks.allocator_list,-std.experimental.allocator.building_blocks.bitmapped_block,-std.experimental.allocator.building_blocks.fallback_allocator,-std.experimental.allocator.building_blocks.free_list,-std.experimental.allocator.building_blocks.free_tree,-std.experimental.allocator.building_blocks.null_allocator,-std.experimental.allocator.building_blocks.stats_collector,-std.experimental.allocator.common,-std.experimental.allocator.mmap_allocator,-std.experimental.allocator.typed,-std.experimental.checkedint,-std.experimental.logger.core,-std.experimental.logger.filelogger,-std.experimental.logger.multilogger,-std.experimental.typecons,-std.file,-std.format,-std.getopt,-std.internal.math.biguintcore,-std.internal.math.biguintnoasm,-std.internal.math.errorfunction,-std.internal.math.gammafunction,-std.internal.scopebuffer,-std.internal.test.dummyrange,-std.json,-std.math,-std.mathspecial,-std.mmfile,-std.net.curl,-std.net.isemail,-std.numeric,-std.outbuffer,-std.parallelism,-std.path,-std.process,-std.random,-std.range,-std.range.interfaces,-std.range.primitives,-std.regex,-std.regex.internal.ir,-std.socket,-std.stdio,-std.string,-std.traits,-std.typecons,-std.uni,-std.uri,-std.utf,-std.uuid,-std.variant,-std.xml,-std.zip,-std.zlib"
127+
has_public_example="-etc.c.curl,-etc.c.sqlite3,-etc.c.zlib,-std.bitmanip,-std.complex,-std.concurrency,-std.container.array,-std.container.dlist,-std.container.rbtree,-std.container.slist,-std.csv,-std.datetime,-std.datetime.date,-std.datetime.interval,-std.datetime.stopwatch,-std.datetime.systime,-std.datetime.timezone,-std.demangle,-std.digest,-std.digest.hmac,-std.digest.murmurhash,-std.digest.sha,-std.encoding,-std.exception,-std.experimental.allocator,-std.experimental.allocator.building_blocks.allocator_list,-std.experimental.allocator.building_blocks.bitmapped_block,-std.experimental.allocator.building_blocks.fallback_allocator,-std.experimental.allocator.building_blocks.free_list,-std.experimental.allocator.building_blocks.free_tree,-std.experimental.allocator.building_blocks.null_allocator,-std.experimental.allocator.building_blocks.stats_collector,-std.experimental.allocator.common,-std.experimental.allocator.mmap_allocator,-std.experimental.allocator.typed,-std.experimental.checkedint,-std.experimental.logger.core,-std.experimental.logger.filelogger,-std.experimental.logger.multilogger,-std.experimental.typecons,-std.file,-std.format,-std.getopt,-std.internal.math.biguintcore,-std.internal.math.biguintnoasm,-std.internal.math.errorfunction,-std.internal.math.gammafunction,-std.internal.scopebuffer,-std.internal.test.dummyrange,-std.json,-std.math,-std.mathspecial,-std.mmfile,-std.net.curl,-std.net.isemail,-std.numeric,-std.outbuffer,-std.parallelism,-std.path,-std.process,-std.random,-std.range,-std.range.interfaces,-std.range.primitives,-std.regex,-std.regex.internal.ir,-std.socket,-std.stdio,-std.string,-std.traits,-std.typecons,-std.uni,-std.uri,-std.utf,-std.uuid,-std.variant,-std.xml,-std.zip,-std.zlib"
128128
; Check for sortedness of imports
129129
imports_sortedness="+disabled"
130130
;imports_sortedness="-etc.c.curl,-std.algorithm.comparison,-std.algorithm.internal,-std.algorithm.iteration,-std.algorithm.mutation,-std.algorithm.searching,-std.algorithm.setops,-std.algorithm.sorting,-std.array,-std.bigint,-std.bitmanip,-std.c.freebsd.socket,-std.c.linux.pthread,-std.c.process,-std.complex,-std.concurrency,-std.container.array,-std.container.binaryheap,-std.container.dlist,-std.container.rbtree,-std.container.slist,-std.container.util,-std.conv,-std.datetime,-std.datetime.date,-std.datetime.interval,-std.datetime.systime,-std.datetime.timezone,-std.digest,-std.digest.hmac,-std.exception,-std.experimental.allocator,-std.experimental.allocator.building_blocks,-std.experimental.allocator.building_blocks.affix_allocator,-std.experimental.allocator.building_blocks.allocator_list,-std.experimental.allocator.building_blocks.free_list,-std.experimental.allocator.building_blocks.free_tree,-std.experimental.allocator.building_blocks.kernighan_ritchie,-std.experimental.allocator.building_blocks.region,-std.experimental.allocator.common,-std.experimental.allocator.mallocator,-std.experimental.allocator.mmap_allocator,-std.experimental.allocator.showcase,-std.experimental.allocator.typed,-std.experimental.checkedint,-std.experimental.logger.core,-std.experimental.typecons,-std.file,-std.format,-std.functional,-std.getopt,-std.internal.math.biguintcore,-std.internal.test.dummyrange,-std.json,-std.math,-std.meta,-std.mmfile,-std.net.curl,-std.net.isemail,-std.numeric,-std.outbuffer,-std.parallelism,-std.path,-std.process,-std.random,-std.range,-std.range.primitives,-std.regex,-std.regex.internal.backtracking,-std.regex.internal.generator,-std.regex.internal.kickstart,-std.regex.internal.parser,-std.regex.internal.tests,-std.signals,-std.socket,-std.stdio,-std.string,-std.uni,-std.utf,-std.uuid,-std.variant,-std.windows.charset,-std.windows.registry,-std.windows.syserror,-std.zip"

std/conv.d

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,13 @@ class ConvException : Exception
7474
mixin basicExceptionCtors;
7575
}
7676

77+
///
78+
@safe unittest
79+
{
80+
import std.exception : assertThrown;
81+
assertThrown!ConvException(to!int("abc"));
82+
}
83+
7784
private auto convError(S, T)(S source, string fn = __FILE__, size_t ln = __LINE__)
7885
{
7986
string msg;
@@ -175,6 +182,13 @@ class ConvOverflowException : ConvException
175182
}
176183
}
177184

185+
///
186+
@safe unittest
187+
{
188+
import std.exception : assertThrown;
189+
assertThrown!ConvOverflowException(to!ubyte(1_000_000));
190+
}
191+
178192
/**
179193
The `to` template converts a value from one type _to another.
180194
The source type is deduced and the target type must be specified, for example the
@@ -4179,20 +4193,10 @@ if (isInputRange!Source && isSomeChar!(ElementType!Source) &&
41794193
string text(T...)(T args)
41804194
if (T.length > 0) { return textImpl!string(args); }
41814195

4182-
// @@@DEPRECATED_2018-06@@@
4183-
deprecated("Calling `text` with 0 arguments is deprecated")
4184-
string text(T...)(T args)
4185-
if (T.length == 0) { return textImpl!string(args); }
4186-
41874196
///ditto
41884197
wstring wtext(T...)(T args)
41894198
if (T.length > 0) { return textImpl!wstring(args); }
41904199

4191-
// @@@DEPRECATED_2018-06@@@
4192-
deprecated("Calling `wtext` with 0 arguments is deprecated")
4193-
wstring wtext(T...)(T args)
4194-
if (T.length == 0) { return textImpl!wstring(args); }
4195-
41964200
///ditto
41974201
dstring dtext(T...)(T args)
41984202
if (T.length > 0) { return textImpl!dstring(args); }
@@ -4205,6 +4209,16 @@ if (T.length > 0) { return textImpl!dstring(args); }
42054209
assert(dtext(42, ' ', 1.5, ": xyz") == "42 1.5: xyz"d);
42064210
}
42074211

4212+
// @@@DEPRECATED_2018-06@@@
4213+
deprecated("Calling `text` with 0 arguments is deprecated")
4214+
string text(T...)(T args)
4215+
if (T.length == 0) { return textImpl!string(args); }
4216+
4217+
// @@@DEPRECATED_2018-06@@@
4218+
deprecated("Calling `wtext` with 0 arguments is deprecated")
4219+
wstring wtext(T...)(T args)
4220+
if (T.length == 0) { return textImpl!wstring(args); }
4221+
42084222
// @@@DEPRECATED_2018-06@@@
42094223
deprecated("Calling `dtext` with 0 arguments is deprecated")
42104224
dstring dtext(T...)(T args)
@@ -6440,6 +6454,19 @@ if ((radix == 2 || radix == 8 || radix == 10 || radix == 16) &&
64406454
}
64416455
}
64426456

6457+
///
6458+
@safe unittest
6459+
{
6460+
import std.algorithm.comparison : equal;
6461+
6462+
assert(toChars(1).equal("1"));
6463+
assert(toChars(1_000_000).equal("1000000"));
6464+
6465+
assert(toChars!(2)(2U).equal("10"));
6466+
assert(toChars!(16)(255U).equal("ff"));
6467+
assert(toChars!(16, char, LetterCase.upper)(255U).equal("FF"));
6468+
}
6469+
64436470

64446471
@safe unittest
64456472
{

0 commit comments

Comments
 (0)