mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 13:40: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);
|
return removeImpl!s(range, offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ditto
|
||||||
deprecated("Use of non-integral tuples is deprecated. Use remove(tuple(start, end).")
|
deprecated("Use of non-integral tuples is deprecated. Use remove(tuple(start, end).")
|
||||||
Range remove
|
Range remove
|
||||||
(SwapStrategy s = SwapStrategy.stable, Range, Offset ...)
|
(SwapStrategy s = SwapStrategy.stable, Range, Offset ...)
|
||||||
|
|
|
@ -4676,6 +4676,7 @@ nothrow pure @safe @nogc unittest
|
||||||
assert(a == [0, 1]);
|
assert(a == [0, 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ditto
|
||||||
pragma(inline, true) U[n] staticArray(U, T, size_t n)(auto ref T[n] a)
|
pragma(inline, true) U[n] staticArray(U, T, size_t n)(auto ref T[n] a)
|
||||||
if (!is(T == U) && is(T : U))
|
if (!is(T == U) && is(T : U))
|
||||||
{
|
{
|
||||||
|
|
|
@ -784,48 +784,6 @@ if (is(T == class))
|
||||||
static assert(!__traits(compiles, bar(s)));
|
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)
|
private struct FloatingPointRepresentation(T)
|
||||||
{
|
{
|
||||||
static if (is(T == float))
|
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
|
@safe unittest
|
||||||
{
|
{
|
||||||
|
@ -899,6 +878,27 @@ private struct FloatingPointRepresentation(T)
|
||||||
assert(rep.sign);
|
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
|
@safe unittest
|
||||||
{
|
{
|
||||||
|
|
|
@ -38,11 +38,6 @@ $(BR) $(LINK2 https://en.wikipedia.org/wiki/MurmurHash, Wikipedia)
|
||||||
*/
|
*/
|
||||||
module std.digest.murmurhash;
|
module std.digest.murmurhash;
|
||||||
|
|
||||||
version (X86)
|
|
||||||
version = HaveUnalignedLoads;
|
|
||||||
else version (X86_64)
|
|
||||||
version = HaveUnalignedLoads;
|
|
||||||
|
|
||||||
///
|
///
|
||||||
@safe unittest
|
@safe unittest
|
||||||
{
|
{
|
||||||
|
@ -97,6 +92,11 @@ else version (X86_64)
|
||||||
assert(hashed == [188, 165, 108, 2]);
|
assert(hashed == [188, 165, 108, 2]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
version (X86)
|
||||||
|
version = HaveUnalignedLoads;
|
||||||
|
else version (X86_64)
|
||||||
|
version = HaveUnalignedLoads;
|
||||||
|
|
||||||
public import std.digest;
|
public import std.digest;
|
||||||
|
|
||||||
@safe:
|
@safe:
|
||||||
|
|
|
@ -678,6 +678,7 @@ struct JSONValue
|
||||||
assert( j["language"].str == "Perl" );
|
assert( j["language"].str == "Perl" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ditto
|
||||||
void opIndexAssign(T)(T arg, size_t i)
|
void opIndexAssign(T)(T arg, size_t i)
|
||||||
{
|
{
|
||||||
auto a = this.arrayNoRef;
|
auto a = this.arrayNoRef;
|
||||||
|
@ -754,11 +755,13 @@ struct JSONValue
|
||||||
assert(j["author"].str == "Walter");
|
assert(j["author"].str == "Walter");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///
|
||||||
bool opEquals(const JSONValue rhs) const @nogc nothrow pure @safe
|
bool opEquals(const JSONValue rhs) const @nogc nothrow pure @safe
|
||||||
{
|
{
|
||||||
return opEquals(rhs);
|
return opEquals(rhs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ditto
|
||||||
bool opEquals(ref const JSONValue rhs) const @nogc nothrow pure @trusted
|
bool opEquals(ref const JSONValue rhs) const @nogc nothrow pure @trusted
|
||||||
{
|
{
|
||||||
// Default doesn't work well since store is a union. Compare only
|
// 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.range.primitives;
|
||||||
import std.traits;
|
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
|
@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]));
|
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)
|
version (StdUnittest)
|
||||||
{
|
{
|
||||||
static import std.meta;
|
static import std.meta;
|
||||||
|
|
|
@ -4845,6 +4845,7 @@ if (isForwardRange!Range && isSomeChar!(ElementEncodingType!Range) &&
|
||||||
assert(detabber(" \n\tx", 9).array == " \n x");
|
assert(detabber(" \n\tx", 9).array == " \n x");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// ditto
|
||||||
auto detabber(Range)(auto ref Range r, size_t tabSize = 8)
|
auto detabber(Range)(auto ref Range r, size_t tabSize = 8)
|
||||||
if (isConvertibleToString!Range)
|
if (isConvertibleToString!Range)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue