mirror of
https://github.com/dlang/phobos.git
synced 2025-04-26 21:22:20 +03:00
Fix missing unittests in docs (#8603)
* Fix missing staticArray unittest in docs Found using https://github.com/dlang/dmd/pull/14527. * Fix missing FloatRep and DoubleRep unittests in docs * 2 JSONValue op overloads * std.random * detabber * remove * std.digest.murmurhash
This commit is contained in:
parent
4967c07b19
commit
281f42d306
7 changed files with 65 additions and 59 deletions
|
@ -1943,6 +1943,7 @@ if (Offset.length >= 1 && allSatisfy!(isValidIntegralTuple, Offset))
|
|||
return removeImpl!s(range, offset);
|
||||
}
|
||||
|
||||
/// ditto
|
||||
deprecated("Use of non-integral tuples is deprecated. Use remove(tuple(start, end).")
|
||||
Range remove
|
||||
(SwapStrategy s = SwapStrategy.stable, Range, Offset ...)
|
||||
|
|
|
@ -4676,6 +4676,7 @@ nothrow pure @safe @nogc unittest
|
|||
assert(a == [0, 1]);
|
||||
}
|
||||
|
||||
/// ditto
|
||||
pragma(inline, true) U[n] staticArray(U, T, size_t n)(auto ref T[n] a)
|
||||
if (!is(T == U) && is(T : U))
|
||||
{
|
||||
|
|
|
@ -784,48 +784,6 @@ if (is(T == class))
|
|||
static assert(!__traits(compiles, bar(s)));
|
||||
}
|
||||
|
||||
/**
|
||||
Allows manipulating the fraction, exponent, and sign parts of a
|
||||
`float` separately. The definition is:
|
||||
|
||||
----
|
||||
struct FloatRep
|
||||
{
|
||||
union
|
||||
{
|
||||
float value;
|
||||
mixin(bitfields!(
|
||||
uint, "fraction", 23,
|
||||
ubyte, "exponent", 8,
|
||||
bool, "sign", 1));
|
||||
}
|
||||
enum uint bias = 127, fractionBits = 23, exponentBits = 8, signBits = 1;
|
||||
}
|
||||
----
|
||||
*/
|
||||
alias FloatRep = FloatingPointRepresentation!float;
|
||||
|
||||
/**
|
||||
Allows manipulating the fraction, exponent, and sign parts of a
|
||||
`double` separately. The definition is:
|
||||
|
||||
----
|
||||
struct DoubleRep
|
||||
{
|
||||
union
|
||||
{
|
||||
double value;
|
||||
mixin(bitfields!(
|
||||
ulong, "fraction", 52,
|
||||
ushort, "exponent", 11,
|
||||
bool, "sign", 1));
|
||||
}
|
||||
enum uint bias = 1023, signBits = 1, fractionBits = 52, exponentBits = 11;
|
||||
}
|
||||
----
|
||||
*/
|
||||
alias DoubleRep = FloatingPointRepresentation!double;
|
||||
|
||||
private struct FloatingPointRepresentation(T)
|
||||
{
|
||||
static if (is(T == float))
|
||||
|
@ -851,6 +809,27 @@ private struct FloatingPointRepresentation(T)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
Allows manipulating the fraction, exponent, and sign parts of a
|
||||
`float` separately. The definition is:
|
||||
|
||||
----
|
||||
struct FloatRep
|
||||
{
|
||||
union
|
||||
{
|
||||
float value;
|
||||
mixin(bitfields!(
|
||||
uint, "fraction", 23,
|
||||
ubyte, "exponent", 8,
|
||||
bool, "sign", 1));
|
||||
}
|
||||
enum uint bias = 127, fractionBits = 23, exponentBits = 8, signBits = 1;
|
||||
}
|
||||
----
|
||||
*/
|
||||
alias FloatRep = FloatingPointRepresentation!float;
|
||||
|
||||
///
|
||||
@safe unittest
|
||||
{
|
||||
|
@ -899,6 +878,27 @@ private struct FloatingPointRepresentation(T)
|
|||
assert(rep.sign);
|
||||
}
|
||||
|
||||
/**
|
||||
Allows manipulating the fraction, exponent, and sign parts of a
|
||||
`double` separately. The definition is:
|
||||
|
||||
----
|
||||
struct DoubleRep
|
||||
{
|
||||
union
|
||||
{
|
||||
double value;
|
||||
mixin(bitfields!(
|
||||
ulong, "fraction", 52,
|
||||
ushort, "exponent", 11,
|
||||
bool, "sign", 1));
|
||||
}
|
||||
enum uint bias = 1023, signBits = 1, fractionBits = 52, exponentBits = 11;
|
||||
}
|
||||
----
|
||||
*/
|
||||
alias DoubleRep = FloatingPointRepresentation!double;
|
||||
|
||||
///
|
||||
@safe unittest
|
||||
{
|
||||
|
|
|
@ -38,11 +38,6 @@ $(BR) $(LINK2 https://en.wikipedia.org/wiki/MurmurHash, Wikipedia)
|
|||
*/
|
||||
module std.digest.murmurhash;
|
||||
|
||||
version (X86)
|
||||
version = HaveUnalignedLoads;
|
||||
else version (X86_64)
|
||||
version = HaveUnalignedLoads;
|
||||
|
||||
///
|
||||
@safe unittest
|
||||
{
|
||||
|
@ -97,6 +92,11 @@ else version (X86_64)
|
|||
assert(hashed == [188, 165, 108, 2]);
|
||||
}
|
||||
|
||||
version (X86)
|
||||
version = HaveUnalignedLoads;
|
||||
else version (X86_64)
|
||||
version = HaveUnalignedLoads;
|
||||
|
||||
public import std.digest;
|
||||
|
||||
@safe:
|
||||
|
|
|
@ -678,6 +678,7 @@ struct JSONValue
|
|||
assert( j["language"].str == "Perl" );
|
||||
}
|
||||
|
||||
/// ditto
|
||||
void opIndexAssign(T)(T arg, size_t i)
|
||||
{
|
||||
auto a = this.arrayNoRef;
|
||||
|
@ -754,11 +755,13 @@ struct JSONValue
|
|||
assert(j["author"].str == "Walter");
|
||||
}
|
||||
|
||||
///
|
||||
bool opEquals(const JSONValue rhs) const @nogc nothrow pure @safe
|
||||
{
|
||||
return opEquals(rhs);
|
||||
}
|
||||
|
||||
/// ditto
|
||||
bool opEquals(ref const JSONValue rhs) const @nogc nothrow pure @trusted
|
||||
{
|
||||
// Default doesn't work well since store is a union. Compare only
|
||||
|
|
24
std/random.d
24
std/random.d
|
@ -107,18 +107,6 @@ module std.random;
|
|||
import std.range.primitives;
|
||||
import std.traits;
|
||||
|
||||
version (OSX)
|
||||
version = Darwin;
|
||||
else version (iOS)
|
||||
version = Darwin;
|
||||
else version (TVOS)
|
||||
version = Darwin;
|
||||
else version (WatchOS)
|
||||
version = Darwin;
|
||||
|
||||
version (D_InlineAsm_X86) version = InlineAsm_X86_Any;
|
||||
version (D_InlineAsm_X86_64) version = InlineAsm_X86_Any;
|
||||
|
||||
///
|
||||
@safe unittest
|
||||
{
|
||||
|
@ -178,6 +166,18 @@ version (D_InlineAsm_X86_64) version = InlineAsm_X86_Any;
|
|||
assert([0, 1, 2, 4, 5].randomShuffle(rnd2).equal([4, 2, 5, 0, 1]));
|
||||
}
|
||||
|
||||
version (OSX)
|
||||
version = Darwin;
|
||||
else version (iOS)
|
||||
version = Darwin;
|
||||
else version (TVOS)
|
||||
version = Darwin;
|
||||
else version (WatchOS)
|
||||
version = Darwin;
|
||||
|
||||
version (D_InlineAsm_X86) version = InlineAsm_X86_Any;
|
||||
version (D_InlineAsm_X86_64) version = InlineAsm_X86_Any;
|
||||
|
||||
version (StdUnittest)
|
||||
{
|
||||
static import std.meta;
|
||||
|
|
|
@ -4845,6 +4845,7 @@ if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) &&
|
|||
assert(detabber(" \n\tx", 9).array == " \n x");
|
||||
}
|
||||
|
||||
/// ditto
|
||||
auto detabber(Range)(auto ref Range r, size_t tabSize = 8)
|
||||
if (isConvertibleToString!Range)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue