mirror of
https://github.com/dlang/phobos.git
synced 2025-05-02 08:00:48 +03:00
commit
73c8b59bb5
13 changed files with 72 additions and 75 deletions
|
@ -1263,12 +1263,12 @@ unittest
|
||||||
static struct S3
|
static struct S3
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
this(this){};
|
this(this){}
|
||||||
}
|
}
|
||||||
static struct S4
|
static struct S4
|
||||||
{
|
{
|
||||||
int i = 1;
|
int i = 1;
|
||||||
this(this){};
|
this(this){}
|
||||||
}
|
}
|
||||||
static assert (!hasElaborateAssign!S1);
|
static assert (!hasElaborateAssign!S1);
|
||||||
static assert (!hasElaborateAssign!S2);
|
static assert (!hasElaborateAssign!S2);
|
||||||
|
|
|
@ -723,9 +723,8 @@ struct BitArray
|
||||||
lo++;
|
lo++;
|
||||||
hi--;
|
hi--;
|
||||||
}
|
}
|
||||||
Ldone:
|
|
||||||
;
|
|
||||||
}
|
}
|
||||||
|
Ldone:
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2181,10 +2181,10 @@ Target parse(Target, Source)(ref Source p)
|
||||||
{
|
{
|
||||||
static import core.stdc.math/* : HUGE_VAL*/;
|
static import core.stdc.math/* : HUGE_VAL*/;
|
||||||
|
|
||||||
static immutable real negtab[14] =
|
static immutable real[14] negtab =
|
||||||
[ 1e-4096L,1e-2048L,1e-1024L,1e-512L,1e-256L,1e-128L,1e-64L,1e-32L,
|
[ 1e-4096L,1e-2048L,1e-1024L,1e-512L,1e-256L,1e-128L,1e-64L,1e-32L,
|
||||||
1e-16L,1e-8L,1e-4L,1e-2L,1e-1L,1.0L ];
|
1e-16L,1e-8L,1e-4L,1e-2L,1e-1L,1.0L ];
|
||||||
static immutable real postab[13] =
|
static immutable real[13] postab =
|
||||||
[ 1e+4096L,1e+2048L,1e+1024L,1e+512L,1e+256L,1e+128L,1e+64L,1e+32L,
|
[ 1e+4096L,1e+2048L,1e+1024L,1e+512L,1e+256L,1e+128L,1e+64L,1e+32L,
|
||||||
1e+16L,1e+8L,1e+4L,1e+2L,1e+1L ];
|
1e+16L,1e+8L,1e+4L,1e+2L,1e+1L ];
|
||||||
// static immutable string infinity = "infinity";
|
// static immutable string infinity = "infinity";
|
||||||
|
@ -2574,7 +2574,7 @@ unittest
|
||||||
debug(conv) scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " succeeded.");
|
debug(conv) scope(success) writeln("unittest @", __FILE__, ":", __LINE__, " succeeded.");
|
||||||
struct longdouble
|
struct longdouble
|
||||||
{
|
{
|
||||||
ushort value[5];
|
ushort[5] value;
|
||||||
}
|
}
|
||||||
|
|
||||||
real ld;
|
real ld;
|
||||||
|
|
|
@ -430,7 +430,7 @@ unittest
|
||||||
int value;
|
int value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Layout ans[3];
|
Layout[3] ans;
|
||||||
ans[0].name = "one";
|
ans[0].name = "one";
|
||||||
ans[0].value = 1;
|
ans[0].value = 1;
|
||||||
ans[1].name = "two";
|
ans[1].name = "two";
|
||||||
|
@ -481,7 +481,7 @@ unittest
|
||||||
double other;
|
double other;
|
||||||
}
|
}
|
||||||
|
|
||||||
Layout ans[2];
|
Layout[2] ans;
|
||||||
ans[0].name = "\U00010143Hello";
|
ans[0].name = "\U00010143Hello";
|
||||||
ans[0].value = 65;
|
ans[0].value = 65;
|
||||||
ans[0].other = 63.63;
|
ans[0].other = 63.63;
|
||||||
|
@ -528,7 +528,7 @@ unittest
|
||||||
|
|
||||||
auto records = csvReader!Layout(str, ["b","c","a"]);
|
auto records = csvReader!Layout(str, ["b","c","a"]);
|
||||||
|
|
||||||
Layout ans[2];
|
Layout[2] ans;
|
||||||
ans[0].name = "Hello";
|
ans[0].name = "Hello";
|
||||||
ans[0].value = 65;
|
ans[0].value = 65;
|
||||||
ans[0].other = 63.63;
|
ans[0].other = 63.63;
|
||||||
|
|
|
@ -1402,7 +1402,7 @@ private void formatUnsigned(Writer, Char)(Writer w, ulong arg, ref FormatSpec!Ch
|
||||||
forcedPrefix = '-';
|
forcedPrefix = '-';
|
||||||
}
|
}
|
||||||
// fill the digits
|
// fill the digits
|
||||||
char buffer[64]; // 64 bits in base 2 at most
|
char[64] buffer; // 64 bits in base 2 at most
|
||||||
char[] digits;
|
char[] digits;
|
||||||
{
|
{
|
||||||
uint i = buffer.length;
|
uint i = buffer.length;
|
||||||
|
@ -1592,8 +1592,8 @@ if (is(FloatingPointTypeOf!T) && !is(T == enum) && !hasToString!(T, Char))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (fs.spec == 's') fs.spec = 'g';
|
if (fs.spec == 's') fs.spec = 'g';
|
||||||
char sprintfSpec[1 /*%*/ + 5 /*flags*/ + 3 /*width.prec*/ + 2 /*format*/
|
char[1 /*%*/ + 5 /*flags*/ + 3 /*width.prec*/ + 2 /*format*/
|
||||||
+ 1 /*\0*/] = void;
|
+ 1 /*\0*/] sprintfSpec = void;
|
||||||
sprintfSpec[0] = '%';
|
sprintfSpec[0] = '%';
|
||||||
uint i = 1;
|
uint i = 1;
|
||||||
if (fs.flDash) sprintfSpec[i++] = '-';
|
if (fs.flDash) sprintfSpec[i++] = '-';
|
||||||
|
|
22
std/math.d
22
std/math.d
|
@ -123,8 +123,8 @@ version(unittest)
|
||||||
if (isnan(x) || isnan(y))
|
if (isnan(x) || isnan(y))
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
char bufx[30];
|
char[30] bufx;
|
||||||
char bufy[30];
|
char[30] bufy;
|
||||||
assert(ndigits < bufx.length);
|
assert(ndigits < bufx.length);
|
||||||
|
|
||||||
int ix;
|
int ix;
|
||||||
|
@ -486,8 +486,7 @@ trigerr:
|
||||||
}
|
}
|
||||||
return real.nan;
|
return real.nan;
|
||||||
|
|
||||||
Lret:
|
Lret: {}
|
||||||
;
|
|
||||||
}
|
}
|
||||||
else version(D_InlineAsm_X86_64)
|
else version(D_InlineAsm_X86_64)
|
||||||
{
|
{
|
||||||
|
@ -535,8 +534,7 @@ trigerr:
|
||||||
}
|
}
|
||||||
return real.nan;
|
return real.nan;
|
||||||
|
|
||||||
Lret:
|
Lret: {}
|
||||||
;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -546,7 +544,7 @@ Lret:
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
static real vals[][2] = // angle,tan
|
static real[2][] vals = // angle,tan
|
||||||
[
|
[
|
||||||
[ 0, 0],
|
[ 0, 0],
|
||||||
[ .5, .5463024898],
|
[ .5, .5463024898],
|
||||||
|
@ -1788,7 +1786,7 @@ real frexp(real value, out int exp) @trusted pure nothrow
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
static real vals[][3] = // x,frexp,exp
|
static real[3][] vals = // x,frexp,exp
|
||||||
[
|
[
|
||||||
[0.0, 0.0, 0],
|
[0.0, 0.0, 0],
|
||||||
[-0.0, -0.0, 0],
|
[-0.0, -0.0, 0],
|
||||||
|
@ -1818,7 +1816,7 @@ unittest
|
||||||
|
|
||||||
static if (real.mant_dig == 64)
|
static if (real.mant_dig == 64)
|
||||||
{
|
{
|
||||||
static real extendedvals[][3] = [ // x,frexp,exp
|
static real[3][] extendedvals = [ // x,frexp,exp
|
||||||
[0x1.a5f1c2eb3fe4efp+73L, 0x1.A5F1C2EB3FE4EFp-1L, 74], // normal
|
[0x1.a5f1c2eb3fe4efp+73L, 0x1.A5F1C2EB3FE4EFp-1L, 74], // normal
|
||||||
[0x1.fa01712e8f0471ap-1064L, 0x1.fa01712e8f0471ap-1L, -1063],
|
[0x1.fa01712e8f0471ap-1064L, 0x1.fa01712e8f0471ap-1L, -1063],
|
||||||
[real.min_normal, .5, -16381],
|
[real.min_normal, .5, -16381],
|
||||||
|
@ -1929,7 +1927,7 @@ unittest
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
static real vals[][3] = // value,exp,ldexp
|
static real[3][] vals = // value,exp,ldexp
|
||||||
[
|
[
|
||||||
[ 0, 0, 0],
|
[ 0, 0, 0],
|
||||||
[ 1, 0, 1],
|
[ 1, 0, 1],
|
||||||
|
@ -2305,7 +2303,7 @@ real hypot(real x, real y) @safe pure nothrow
|
||||||
|
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
static real vals[][3] = // x,y,hypot
|
static real[3][] vals = // x,y,hypot
|
||||||
[
|
[
|
||||||
[ 0.0, 0.0, 0.0],
|
[ 0.0, 0.0, 0.0],
|
||||||
[ 0.0, -0.0, 0.0],
|
[ 0.0, -0.0, 0.0],
|
||||||
|
@ -4725,7 +4723,7 @@ unittest
|
||||||
{
|
{
|
||||||
debug (math) printf("math.poly.unittest\n");
|
debug (math) printf("math.poly.unittest\n");
|
||||||
real x = 3.1;
|
real x = 3.1;
|
||||||
static real pp[] = [56.1, 32.7, 6];
|
static real[] pp = [56.1, 32.7, 6];
|
||||||
|
|
||||||
assert( poly(x, pp) == (56.1L + (32.7L + 6L * x) * x) );
|
assert( poly(x, pp) == (56.1L + (32.7L + 6L * x) * x) );
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,7 +292,7 @@ struct MD5_CTX
|
||||||
*/
|
*/
|
||||||
void finish(ref ubyte[16] digest) /* message digest */
|
void finish(ref ubyte[16] digest) /* message digest */
|
||||||
{
|
{
|
||||||
ubyte bits[8] = void;
|
ubyte[8] bits = void;
|
||||||
uint index, padLen;
|
uint index, padLen;
|
||||||
|
|
||||||
/* Save number of bits */
|
/* Save number of bits */
|
||||||
|
|
|
@ -2068,7 +2068,7 @@ unittest
|
||||||
["nyuk", "I", "have", "no", "chocolate", "giba"],
|
["nyuk", "I", "have", "no", "chocolate", "giba"],
|
||||||
["wyda", "I", "have", "I", "have", "have", "I", "have", "hehe"],
|
["wyda", "I", "have", "I", "have", "have", "I", "have", "hehe"],
|
||||||
0.5);
|
0.5);
|
||||||
double witness[] = [ 7.0, 4.03125, 0, 0 ];
|
double[] witness = [ 7.0, 4.03125, 0, 0 ];
|
||||||
foreach (e; sim)
|
foreach (e; sim)
|
||||||
{
|
{
|
||||||
//writeln(e);
|
//writeln(e);
|
||||||
|
@ -2217,10 +2217,10 @@ private:
|
||||||
recurseRange.popHalf();
|
recurseRange.popHalf();
|
||||||
slowFourier2(recurseRange, buf[$ / 2..$]);
|
slowFourier2(recurseRange, buf[$ / 2..$]);
|
||||||
}
|
}
|
||||||
|
|
||||||
butterfly(buf);
|
butterfly(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
// This algorithm works by performing the even and odd parts of our FFT
|
// This algorithm works by performing the even and odd parts of our FFT
|
||||||
// using the "two for the price of one" method mentioned at
|
// using the "two for the price of one" method mentioned at
|
||||||
// http://www.engineeringproductivitytools.com/stuff/T0001/PT10.HTM#Head521
|
// http://www.engineeringproductivitytools.com/stuff/T0001/PT10.HTM#Head521
|
||||||
|
@ -2232,7 +2232,7 @@ private:
|
||||||
assert(isPowerOfTwo(range.length));
|
assert(isPowerOfTwo(range.length));
|
||||||
} body {
|
} body {
|
||||||
alias ElementType!R E;
|
alias ElementType!R E;
|
||||||
|
|
||||||
// Converts odd indices of range to the imaginary components of
|
// Converts odd indices of range to the imaginary components of
|
||||||
// a range half the size. The even indices become the real components.
|
// a range half the size. The even indices become the real components.
|
||||||
static if(isArray!R && isFloatingPoint!E) {
|
static if(isArray!R && isFloatingPoint!E) {
|
||||||
|
@ -2240,57 +2240,57 @@ private:
|
||||||
// cheap way to convert. This is a common case, so take advantage.
|
// cheap way to convert. This is a common case, so take advantage.
|
||||||
auto oddsImag = cast(Complex!E[]) range;
|
auto oddsImag = cast(Complex!E[]) range;
|
||||||
} else {
|
} else {
|
||||||
// General case: Use a higher order range. We can assume
|
// General case: Use a higher order range. We can assume
|
||||||
// source.length is even because it has to be a power of 2.
|
// source.length is even because it has to be a power of 2.
|
||||||
static struct OddToImaginary {
|
static struct OddToImaginary {
|
||||||
R source;
|
R source;
|
||||||
alias Complex!(CommonType!(E, typeof(buf[0].re))) C;
|
alias Complex!(CommonType!(E, typeof(buf[0].re))) C;
|
||||||
|
|
||||||
@property {
|
@property {
|
||||||
C front() {
|
C front() {
|
||||||
return C(source[0], source[1]);
|
return C(source[0], source[1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
C back() {
|
C back() {
|
||||||
immutable n = source.length;
|
immutable n = source.length;
|
||||||
return C(source[n - 2], source[n - 1]);
|
return C(source[n - 2], source[n - 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
typeof(this) save() {
|
typeof(this) save() {
|
||||||
return typeof(this)(source.save);
|
return typeof(this)(source.save);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool empty() {
|
bool empty() {
|
||||||
return source.empty;
|
return source.empty;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t length() {
|
size_t length() {
|
||||||
return source.length / 2;
|
return source.length / 2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void popFront() {
|
void popFront() {
|
||||||
source.popFront();
|
source.popFront();
|
||||||
source.popFront();
|
source.popFront();
|
||||||
}
|
}
|
||||||
|
|
||||||
void popBack() {
|
void popBack() {
|
||||||
source.popBack();
|
source.popBack();
|
||||||
source.popBack();
|
source.popBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
C opIndex(size_t index) {
|
C opIndex(size_t index) {
|
||||||
return C(source[index * 2], source[index * 2 + 1]);
|
return C(source[index * 2], source[index * 2 + 1]);
|
||||||
}
|
}
|
||||||
|
|
||||||
typeof(this) opSlice(size_t lower, size_t upper) {
|
typeof(this) opSlice(size_t lower, size_t upper) {
|
||||||
return typeof(this)(source[lower * 2..upper * 2]);
|
return typeof(this)(source[lower * 2..upper * 2]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
auto oddsImag = OddToImaginary(range);
|
auto oddsImag = OddToImaginary(range);
|
||||||
}
|
}
|
||||||
|
|
||||||
fft(oddsImag, buf[0..$ / 2]);
|
fft(oddsImag, buf[0..$ / 2]);
|
||||||
auto evenFft = buf[0..$ / 2];
|
auto evenFft = buf[0..$ / 2];
|
||||||
auto oddFft = buf[$ / 2..$];
|
auto oddFft = buf[$ / 2..$];
|
||||||
|
@ -2299,7 +2299,7 @@ private:
|
||||||
oddFft[0].im = 0;
|
oddFft[0].im = 0;
|
||||||
evenFft[0].im = 0;
|
evenFft[0].im = 0;
|
||||||
// evenFft[0].re is already right b/c it's aliased with buf[0].re.
|
// evenFft[0].re is already right b/c it's aliased with buf[0].re.
|
||||||
|
|
||||||
foreach(k; 1..halfN / 2 + 1) {
|
foreach(k; 1..halfN / 2 + 1) {
|
||||||
immutable bufk = buf[k];
|
immutable bufk = buf[k];
|
||||||
immutable bufnk = buf[buf.length / 2 - k];
|
immutable bufnk = buf[buf.length / 2 - k];
|
||||||
|
@ -2307,7 +2307,7 @@ private:
|
||||||
evenFft[halfN - k].re = evenFft[k].re;
|
evenFft[halfN - k].re = evenFft[k].re;
|
||||||
evenFft[k].im = 0.5 * (bufk.im - bufnk.im);
|
evenFft[k].im = 0.5 * (bufk.im - bufnk.im);
|
||||||
evenFft[halfN - k].im = -evenFft[k].im;
|
evenFft[halfN - k].im = -evenFft[k].im;
|
||||||
|
|
||||||
oddFft[k].re = 0.5 * (bufk.im + bufnk.im);
|
oddFft[k].re = 0.5 * (bufk.im + bufnk.im);
|
||||||
oddFft[halfN - k].re = oddFft[k].re;
|
oddFft[halfN - k].re = oddFft[k].re;
|
||||||
oddFft[k].im = 0.5 * (bufnk.re - bufk.re);
|
oddFft[k].im = 0.5 * (bufnk.re - bufk.re);
|
||||||
|
@ -2316,8 +2316,8 @@ private:
|
||||||
|
|
||||||
butterfly(buf);
|
butterfly(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
void butterfly(R)(R buf) const
|
void butterfly(R)(R buf) const
|
||||||
in {
|
in {
|
||||||
assert(isPowerOfTwo(buf.length));
|
assert(isPowerOfTwo(buf.length));
|
||||||
} body {
|
} body {
|
||||||
|
@ -2440,8 +2440,8 @@ private:
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
/**Create an $(D Fft) object for computing fast Fourier transforms of
|
/**Create an $(D Fft) object for computing fast Fourier transforms of
|
||||||
* power of two sizes of $(D size) or smaller. $(D size) must be a
|
* power of two sizes of $(D size) or smaller. $(D size) must be a
|
||||||
* power of two.
|
* power of two.
|
||||||
*/
|
*/
|
||||||
this(size_t size) {
|
this(size_t size) {
|
||||||
|
@ -2464,7 +2464,7 @@ public:
|
||||||
*
|
*
|
||||||
* Note: Pure real FFTs are automatically detected and the relevant
|
* Note: Pure real FFTs are automatically detected and the relevant
|
||||||
* optimizations are performed.
|
* optimizations are performed.
|
||||||
*
|
*
|
||||||
* Returns: An array of complex numbers representing the transformed data in
|
* Returns: An array of complex numbers representing the transformed data in
|
||||||
* the frequency domain.
|
* the frequency domain.
|
||||||
*/
|
*/
|
||||||
|
@ -2506,7 +2506,7 @@ public:
|
||||||
alias ElementType!R E;
|
alias ElementType!R E;
|
||||||
static if(is(E : real)) {
|
static if(is(E : real)) {
|
||||||
return fftImplPureReal(range, buf);
|
return fftImplPureReal(range, buf);
|
||||||
} else {
|
} else {
|
||||||
static if(is(R : Stride!R)) {
|
static if(is(R : Stride!R)) {
|
||||||
return fftImpl(range, buf);
|
return fftImpl(range, buf);
|
||||||
} else {
|
} else {
|
||||||
|
@ -2611,13 +2611,13 @@ unittest {
|
||||||
[36.0, -4, -4, -4, -4, -4, -4, -4]));
|
[36.0, -4, -4, -4, -4, -4, -4, -4]));
|
||||||
assert(approxEqual(map!"a.im"(fft1),
|
assert(approxEqual(map!"a.im"(fft1),
|
||||||
[0, 9.6568, 4, 1.6568, 0, -1.6568, -4, -9.6568]));
|
[0, 9.6568, 4, 1.6568, 0, -1.6568, -4, -9.6568]));
|
||||||
|
|
||||||
auto fft1Retro = fft(retro(arr));
|
auto fft1Retro = fft(retro(arr));
|
||||||
assert(approxEqual(map!"a.re"(fft1Retro),
|
assert(approxEqual(map!"a.re"(fft1Retro),
|
||||||
[36.0, 4, 4, 4, 4, 4, 4, 4]));
|
[36.0, 4, 4, 4, 4, 4, 4, 4]));
|
||||||
assert(approxEqual(map!"a.im"(fft1Retro),
|
assert(approxEqual(map!"a.im"(fft1Retro),
|
||||||
[0, -9.6568, -4, -1.6568, 0, 1.6568, 4, 9.6568]));
|
[0, -9.6568, -4, -1.6568, 0, 1.6568, 4, 9.6568]));
|
||||||
|
|
||||||
auto fft1Float = fft(to!(float[])(arr));
|
auto fft1Float = fft(to!(float[])(arr));
|
||||||
assert(approxEqual(map!"a.re"(fft1), map!"a.re"(fft1Float)));
|
assert(approxEqual(map!"a.re"(fft1), map!"a.re"(fft1Float)));
|
||||||
assert(approxEqual(map!"a.im"(fft1), map!"a.im"(fft1Float)));
|
assert(approxEqual(map!"a.im"(fft1), map!"a.im"(fft1Float)));
|
||||||
|
|
|
@ -638,7 +638,7 @@ Parameter for the generator.
|
||||||
upperMask = ~((cast(UIntType) 1u <<
|
upperMask = ~((cast(UIntType) 1u <<
|
||||||
(UIntType.sizeof * 8 - (w - r))) - 1),
|
(UIntType.sizeof * 8 - (w - r))) - 1),
|
||||||
lowerMask = (cast(UIntType) 1u << r) - 1;
|
lowerMask = (cast(UIntType) 1u << r) - 1;
|
||||||
static immutable UIntType mag01[2] = [0x0UL, a];
|
static immutable UIntType[2] mag01 = [0x0UL, a];
|
||||||
|
|
||||||
ulong y = void;
|
ulong y = void;
|
||||||
|
|
||||||
|
|
34
std/regex.d
34
std/regex.d
|
@ -648,10 +648,10 @@ enum RegexOption: uint {
|
||||||
nonunicode = 0x8,
|
nonunicode = 0x8,
|
||||||
multiline = 0x10,
|
multiline = 0x10,
|
||||||
singleline = 0x20
|
singleline = 0x20
|
||||||
};
|
}
|
||||||
alias TypeTuple!('g', 'i', 'x', 'U', 'm', 's') RegexOptionNames;//do not reorder this list
|
alias TypeTuple!('g', 'i', 'x', 'U', 'm', 's') RegexOptionNames;//do not reorder this list
|
||||||
static assert( RegexOption.max < 0x80);
|
static assert( RegexOption.max < 0x80);
|
||||||
enum RegexInfo : uint { oneShot = 0x80 };
|
enum RegexInfo : uint { oneShot = 0x80 }
|
||||||
|
|
||||||
private enum NEL = '\u0085', LS = '\u2028', PS = '\u2029';
|
private enum NEL = '\u0085', LS = '\u2028', PS = '\u2029';
|
||||||
|
|
||||||
|
@ -681,9 +681,9 @@ dchar parseUniHex(Char)(ref Char[] str, size_t maxDigit)
|
||||||
|
|
||||||
@system unittest //BUG canFind is system
|
@system unittest //BUG canFind is system
|
||||||
{
|
{
|
||||||
string[] non_hex = [ "000j", "000z", "FffG", "0Z"];
|
string[] non_hex = [ "000j", "000z", "FffG", "0Z"];
|
||||||
string[] hex = [ "01", "ff", "00af", "10FFFF" ];
|
string[] hex = [ "01", "ff", "00af", "10FFFF" ];
|
||||||
int value[] = [ 1, 0xFF, 0xAF, 0x10FFFF ];
|
int[] value = [ 1, 0xFF, 0xAF, 0x10FFFF ];
|
||||||
foreach(v; non_hex)
|
foreach(v; non_hex)
|
||||||
assert(collectException(parseUniHex(v, v.length)).msg
|
assert(collectException(parseUniHex(v, v.length)).msg
|
||||||
.canFind("invalid escape sequence"));
|
.canFind("invalid escape sequence"));
|
||||||
|
@ -1301,7 +1301,7 @@ struct Parser(R, bool CTFE = false)
|
||||||
enforce(ir.length + len < maxCompiledLength, "maximum compiled pattern length is exceeded");
|
enforce(ir.length + len < maxCompiledLength, "maximum compiled pattern length is exceeded");
|
||||||
//workaround @@@BUG@@@ 9634
|
//workaround @@@BUG@@@ 9634
|
||||||
if(__ctfe)
|
if(__ctfe)
|
||||||
{
|
{
|
||||||
foreach(v; ir[offset .. offset+len])
|
foreach(v; ir[offset .. offset+len])
|
||||||
ir ~= v;
|
ir ~= v;
|
||||||
}
|
}
|
||||||
|
@ -1400,7 +1400,7 @@ struct Parser(R, bool CTFE = false)
|
||||||
//CodepointSet operations relatively in order of priority
|
//CodepointSet operations relatively in order of priority
|
||||||
enum Operator:uint {
|
enum Operator:uint {
|
||||||
Open = 0, Negate, Difference, SymDifference, Intersection, Union, None
|
Open = 0, Negate, Difference, SymDifference, Intersection, Union, None
|
||||||
};
|
}
|
||||||
|
|
||||||
//parse unit of CodepointSet spec, most notably escape sequences and char ranges
|
//parse unit of CodepointSet spec, most notably escape sequences and char ranges
|
||||||
//also fetches next set operation
|
//also fetches next set operation
|
||||||
|
@ -2022,7 +2022,7 @@ public struct Regex(Char)
|
||||||
end = e;
|
end = e;
|
||||||
}
|
}
|
||||||
|
|
||||||
@property string front() { return groups[start].name; };
|
@property string front() { return groups[start].name; }
|
||||||
@property string back() { return groups[end-1].name; }
|
@property string back() { return groups[end-1].name; }
|
||||||
@property bool empty() { return start >= end; }
|
@property bool empty() { return start >= end; }
|
||||||
@property size_t length() { return end - start; }
|
@property size_t length() { return end - start; }
|
||||||
|
@ -2030,7 +2030,7 @@ public struct Regex(Char)
|
||||||
@property NamedGroupRange save()
|
@property NamedGroupRange save()
|
||||||
{
|
{
|
||||||
return NamedGroupRange(groups, start, end);
|
return NamedGroupRange(groups, start, end);
|
||||||
};
|
}
|
||||||
void popFront() { assert(!empty); start++; }
|
void popFront() { assert(!empty); start++; }
|
||||||
void popBack() { assert(!empty); end--; }
|
void popBack() { assert(!empty); end--; }
|
||||||
string opIndex()(size_t i)
|
string opIndex()(size_t i)
|
||||||
|
@ -2639,7 +2639,7 @@ public:
|
||||||
fChar = re.ir[i].data;
|
fChar = re.ir[i].data;
|
||||||
static if(charSize != 3)
|
static if(charSize != 3)
|
||||||
{
|
{
|
||||||
Char buf[dchar.sizeof/Char.sizeof];
|
Char[dchar.sizeof/Char.sizeof] buf;
|
||||||
encode(buf, fChar);
|
encode(buf, fChar);
|
||||||
fChar = buf[0];
|
fChar = buf[0];
|
||||||
}
|
}
|
||||||
|
@ -5534,7 +5534,7 @@ enum OneShot { Fwd, Bwd };
|
||||||
static if(direction == OneShot.Fwd)
|
static if(direction == OneShot.Fwd)
|
||||||
writefln("-- Threaded matching (forward) threads at %s", s[index..s.lastIndex]);
|
writefln("-- Threaded matching (forward) threads at %s", s[index..s.lastIndex]);
|
||||||
else
|
else
|
||||||
writefln("-- Threaded matching (backward) threads at %s", retro(s[index..s.lastIndex]));
|
writefln("-- Threaded matching (backward) threads at %s", retro(s[index..s.lastIndex]));
|
||||||
}
|
}
|
||||||
if(startPc!=RestartPc)
|
if(startPc!=RestartPc)
|
||||||
{
|
{
|
||||||
|
@ -5545,7 +5545,7 @@ enum OneShot { Fwd, Bwd };
|
||||||
for(;;)
|
for(;;)
|
||||||
{
|
{
|
||||||
debug(fred_matching) writeln("\n-- Started iteration of main cycle");
|
debug(fred_matching) writeln("\n-- Started iteration of main cycle");
|
||||||
genCounter++;
|
genCounter++;
|
||||||
debug(fred_matching)
|
debug(fred_matching)
|
||||||
{
|
{
|
||||||
foreach(t; clist[])
|
foreach(t; clist[])
|
||||||
|
@ -7556,16 +7556,16 @@ else
|
||||||
enforce(m);
|
enforce(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
// bugzilla 8725
|
// bugzilla 8725
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
static italic = regex( r"\*
|
static italic = regex( r"\*
|
||||||
(?!\s+)
|
(?!\s+)
|
||||||
(.*?)
|
(.*?)
|
||||||
(?!\s+)
|
(?!\s+)
|
||||||
\*", "gx" );
|
\*", "gx" );
|
||||||
string input = "this * is* interesting, *very* interesting";
|
string input = "this * is* interesting, *very* interesting";
|
||||||
assert(replace(input, italic, "<i>$1</i>") ==
|
assert(replace(input, italic, "<i>$1</i>") ==
|
||||||
"this * is* interesting, <i>very</i> interesting");
|
"this * is* interesting, <i>very</i> interesting");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7582,10 +7582,10 @@ else
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
auto rx_1 = regex(r"^(\w)*(\d)");
|
auto rx_1 = regex(r"^(\w)*(\d)");
|
||||||
auto m = match("1234", rx_1);
|
auto m = match("1234", rx_1);
|
||||||
assert(equal(m.front, ["1234", "3", "4"]));
|
assert(equal(m.front, ["1234", "3", "4"]));
|
||||||
auto rx_2 = regex(r"^([0-9])*(\d)");
|
auto rx_2 = regex(r"^([0-9])*(\d)");
|
||||||
auto m2 = match("1234", rx_2);
|
auto m2 = match("1234", rx_2);
|
||||||
assert(equal(m2.front, ["1234", "3", "4"]));
|
assert(equal(m2.front, ["1234", "3", "4"]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7602,7 +7602,7 @@ else
|
||||||
}
|
}
|
||||||
|
|
||||||
// bugzilla 9634
|
// bugzilla 9634
|
||||||
unittest
|
unittest
|
||||||
{
|
{
|
||||||
auto re = ctRegex!"(?:a+)";
|
auto re = ctRegex!"(?:a+)";
|
||||||
assert(match("aaaa", re).hit == "aaaa");
|
assert(match("aaaa", re).hit == "aaaa");
|
||||||
|
|
|
@ -288,7 +288,7 @@ unittest
|
||||||
//{
|
//{
|
||||||
auto p = toStringz("foo");
|
auto p = toStringz("foo");
|
||||||
assert(strlen(p) == 3);
|
assert(strlen(p) == 3);
|
||||||
const(char) foo[] = "abbzxyzzy";
|
const(char)[] foo = "abbzxyzzy";
|
||||||
p = toStringz(foo[3..5]);
|
p = toStringz(foo[3..5]);
|
||||||
assert(strlen(p) == 2);
|
assert(strlen(p) == 2);
|
||||||
|
|
||||||
|
|
|
@ -2481,4 +2481,4 @@ Lis:
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
return true;
|
return true;
|
||||||
};
|
}
|
||||||
|
|
|
@ -493,7 +493,7 @@ public struct UUID
|
||||||
|
|
||||||
enum ctfeEmpty = UUID.init.empty;
|
enum ctfeEmpty = UUID.init.empty;
|
||||||
assert(ctfeEmpty);
|
assert(ctfeEmpty);
|
||||||
|
|
||||||
bool ctfeTest()
|
bool ctfeTest()
|
||||||
{
|
{
|
||||||
for(size_t i = 0; i < 16; i++)
|
for(size_t i = 0; i < 16; i++)
|
||||||
|
@ -1396,7 +1396,7 @@ unittest
|
||||||
id = parseHelper!S("///8ab3060e2cba4f23b74cb52db3bdfb46||");
|
id = parseHelper!S("///8ab3060e2cba4f23b74cb52db3bdfb46||");
|
||||||
enum ctfeId = parseHelper!S("8ab3060e-2cba-4f23-b74c-b52db3bdfb46");
|
enum ctfeId = parseHelper!S("8ab3060e-2cba-4f23-b74c-b52db3bdfb46");
|
||||||
assert(parseHelper!S("8AB3060E-2cba-4f23-b74c-b52db3bdfb46") == ctfeId);
|
assert(parseHelper!S("8AB3060E-2cba-4f23-b74c-b52db3bdfb46") == ctfeId);
|
||||||
|
|
||||||
//Test valid, working cases
|
//Test valid, working cases
|
||||||
assert(parseHelper!S("00000000-0000-0000-0000-000000000000").empty);
|
assert(parseHelper!S("00000000-0000-0000-0000-000000000000").empty);
|
||||||
assert(parseHelper!S("8AB3060E-2CBA-4F23-b74c-B52Db3BDFB46").data
|
assert(parseHelper!S("8AB3060E-2CBA-4F23-b74c-B52Db3BDFB46").data
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue