2,128 changes: 1,471 additions & 657 deletions std/datetime.d

Large diffs are not rendered by default.

33 changes: 26 additions & 7 deletions std/digest/hmac.d
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ if (hashBlockSize % 8 == 0)
import std.string : representation;
auto hmac = HMAC!SHA1("My s3cR3T keY".representation);
hmac.put("Hello, world".representation);
static immutable expected = [130, 32, 235, 44, 208, 141, 150, 232, 211, 214, 162, 195, 188, 127, 52, 89, 100, 68, 90, 216];
static immutable expected = [
130, 32, 235, 44, 208, 141,
150, 232, 211, 214, 162, 195,
188, 127, 52, 89, 100, 68, 90, 216];
assert(hmac.finish() == expected);
}

Expand Down Expand Up @@ -133,7 +136,10 @@ if (hashBlockSize % 8 == 0)
hmac.put(data1.representation);
hmac.start(); // reset digest
hmac.put(data2.representation); // start over
static immutable expected = [122, 151, 232, 240, 249, 80, 19, 178, 186, 77, 110, 23, 208, 52, 11, 88, 34, 151, 192, 255];
static immutable expected = [
122, 151, 232, 240, 249, 80,
19, 178, 186, 77, 110, 23, 208,
52, 11, 88, 34, 151, 192, 255];
assert(hmac.finish() == expected);
}

Expand All @@ -160,7 +166,10 @@ if (hashBlockSize % 8 == 0)
auto hmac = HMAC!SHA1("My s3cR3T keY".representation);
hmac.put(data1.representation)
.put(data2.representation);
static immutable expected = [197, 57, 52, 3, 13, 194, 13, 36, 117, 228, 8, 11, 111, 51, 165, 3, 123, 31, 251, 113];
static immutable expected = [
197, 57, 52, 3, 13, 194, 13,
36, 117, 228, 8, 11, 111, 51,
165, 3, 123, 31, 251, 113];
assert(hmac.finish() == expected);
}

Expand Down Expand Up @@ -194,7 +203,10 @@ if (hashBlockSize % 8 == 0)
auto digest = hmac.put(data1.representation)
.put(data2.representation)
.finish();
static immutable expected = [197, 57, 52, 3, 13, 194, 13, 36, 117, 228, 8, 11, 111, 51, 165, 3, 123, 31, 251, 113];
static immutable expected = [
197, 57, 52, 3, 13, 194, 13,
36, 117, 228, 8, 11, 111, 51,
165, 3, 123, 31, 251, 113];
assert(digest == expected);
}
}
Expand Down Expand Up @@ -231,7 +243,10 @@ if (isDigest!H)
.put(data1.representation)
.put(data2.representation)
.finish();
static immutable expected = [197, 57, 52, 3, 13, 194, 13, 36, 117, 228, 8, 11, 111, 51, 165, 3, 123, 31, 251, 113];
static immutable expected = [
197, 57, 52, 3, 13, 194, 13, 36,
117, 228, 8, 11, 111, 51, 165,
3, 123, 31, 251, 113];
assert(digest == expected);
}

Expand Down Expand Up @@ -264,7 +279,10 @@ if (isDigest!H)
.map!(a => cast(ubyte)(a+1))
.hmac!SHA1("My s3cR3T keY".representation);
static assert(is(typeof(digest) == ubyte[20]));
static immutable expected = [163, 208, 118, 179, 216, 93, 17, 10, 84, 200, 87, 104, 244, 111, 136, 214, 167, 210, 58, 10];
static immutable expected = [
163, 208, 118, 179, 216, 93,
17, 10, 84, 200, 87, 104, 244,
111, 136, 214, 167, 210, 58, 10];
assert(digest == expected);
}
}
Expand Down Expand Up @@ -298,7 +316,8 @@ unittest

import std.string : representation;
auto key = "key".representation,
long_key = "012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789".representation,
long_key = ("012345678901234567890123456789012345678901"
~"234567890123456789012345678901234567890123456789").representation,
data1 = "The quick brown fox ".representation,
data2 = "jumps over the lazy dog".representation,
data = data1 ~ data2;
Expand Down
67 changes: 45 additions & 22 deletions std/digest/sha.d
Original file line number Diff line number Diff line change
Expand Up @@ -878,6 +878,7 @@ unittest
unittest
{
import std.range;
import std.conv : hexString;

ubyte[20] digest;
ubyte[28] digest224;
Expand Down Expand Up @@ -909,13 +910,15 @@ unittest
sha384.put(cast(ubyte[])"abcdef");
sha384.start();
sha384.put(cast(ubyte[])"");
assert(sha384.finish() == cast(ubyte[])x"38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b");
assert(sha384.finish() == cast(ubyte[])hexString!("38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c"
~"0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"));

SHA512 sha512;
sha512.put(cast(ubyte[])"abcdef");
sha512.start();
sha512.put(cast(ubyte[])"");
assert(sha512.finish() == cast(ubyte[])x"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e");
assert(sha512.finish() == cast(ubyte[])hexString!("cf83e1357eefb8bdf1542850d66d8007d620e4050b571"
~"5dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"));

SHA512_224 sha512_224;
sha512_224.put(cast(ubyte[])"abcdef");
Expand All @@ -939,8 +942,10 @@ unittest
assert(digest == cast(ubyte[])x"da39a3ee5e6b4b0d3255bfef95601890afd80709");
assert(digest224 == cast(ubyte[])x"d14a028c2a3a2bc9476102bb288234c415a2b01f828ea62ac5b3e42f");
assert(digest256 == cast(ubyte[])x"e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855");
assert(digest384 == cast(ubyte[])x"38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b");
assert(digest512 == cast(ubyte[])x"cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e");
assert(digest384 == cast(ubyte[])hexString!("38b060a751ac96384cd9327eb1b1e36a21fdb71114be07434c"
~"0cc7bf63f6e1da274edebfe76f65fbd51ad2f14898b95b"));
assert(digest512 == cast(ubyte[])hexString!("cf83e1357eefb8bdf1542850d66d8007d620e4050b5715dc83"
~"f4a921d36ce9ce47d0d13c5d85f2b0ff8318d2877eec2f63b931bd47417a81a538327af927da3e"));
assert(digest512_224 == cast(ubyte[])x"6ed0dd02806fa89e25de060c19d3ac86cabb87d6a0ddd05c333b84f4");
assert(digest512_256 == cast(ubyte[])x"c672b8d1ef56ed28ab87c3622c5114069bdd3ad7b8f9737498d0c01ecef0967a");

Expand All @@ -954,8 +959,10 @@ unittest
assert(digest == cast(ubyte[])x"86f7e437faa5a7fce15d1ddcb9eaeaea377667b8");
assert(digest224 == cast(ubyte[])x"abd37534c7d9a2efb9465de931cd7055ffdb8879563ae98078d6d6d5");
assert(digest256 == cast(ubyte[])x"ca978112ca1bbdcafac231b39a23dc4da786eff8147c4e72b9807785afee48bb");
assert(digest384 == cast(ubyte[])x"54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9cd697e85175033caa88e6d57bc35efae0b5afd3145f31");
assert(digest512 == cast(ubyte[])x"1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05abc54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75");
assert(digest384 == cast(ubyte[])hexString!("54a59b9f22b0b80880d8427e548b7c23abd873486e1f035dce9"
~"cd697e85175033caa88e6d57bc35efae0b5afd3145f31"));
assert(digest512 == cast(ubyte[])hexString!("1f40fc92da241694750979ee6cf582f2d5d7d28e18335de05ab"
~"c54d0560e0f5302860c652bf08d560252aa5e74210546f369fbbbce8c12cfc7957b2652fe9a75"));
assert(digest512_224 == cast(ubyte[])x"d5cdb9ccc769a5121d4175f2bfdd13d6310e0d3d361ea75d82108327");
assert(digest512_256 == cast(ubyte[])x"455e518824bc0601f9fb858ff5c37d417d67c2f8e0df2babe4808858aea830f8");

Expand All @@ -969,8 +976,10 @@ unittest
assert(digest == cast(ubyte[])x"a9993e364706816aba3e25717850c26c9cd0d89d");
assert(digest224 == cast(ubyte[])x"23097d223405d8228642a477bda255b32aadbce4bda0b3f7e36c9da7");
assert(digest256 == cast(ubyte[])x"ba7816bf8f01cfea414140de5dae2223b00361a396177a9cb410ff61f20015ad");
assert(digest384 == cast(ubyte[])x"cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7");
assert(digest512 == cast(ubyte[])x"ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f");
assert(digest384 == cast(ubyte[])hexString!("cb00753f45a35e8bb5a03d699ac65007272c32ab0eded1631a"
~"8b605a43ff5bed8086072ba1e7cc2358baeca134c825a7"));
assert(digest512 == cast(ubyte[])hexString!("ddaf35a193617abacc417349ae20413112e6fa4e89a97ea20a9"
~"eeee64b55d39a2192992a274fc1a836ba3c23a3feebbd454d4423643ce80e2a9ac94fa54ca49f"));
assert(digest512_224 == cast(ubyte[])x"4634270f707b6a54daae7530460842e20e37ed265ceee9a43e8924aa");
assert(digest512_256 == cast(ubyte[])x"53048e2681941ef99b2e29b76b4c7dabe4c2d0c634fc6d46e0e2f13107e7af23");

Expand All @@ -984,8 +993,10 @@ unittest
assert(digest == cast(ubyte[])x"84983e441c3bd26ebaae4aa1f95129e5e54670f1");
assert(digest224 == cast(ubyte[])x"75388b16512776cc5dba5da1fd890150b0c6455cb4f58b1952522525");
assert(digest256 == cast(ubyte[])x"248d6a61d20638b8e5c026930c3e6039a33ce45964ff2167f6ecedd419db06c1");
assert(digest384 == cast(ubyte[])x"3391fdddfc8dc7393707a65b1b4709397cf8b1d162af05abfe8f450de5f36bc6b0455a8520bc4e6f5fe95b1fe3c8452b");
assert(digest512 == cast(ubyte[])x"204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a8279be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445");
assert(digest384 == cast(ubyte[])hexString!("3391fdddfc8dc7393707a65b1b4709397cf8b1d162af05abfe"
~"8f450de5f36bc6b0455a8520bc4e6f5fe95b1fe3c8452b"));
assert(digest512 == cast(ubyte[])hexString!("204a8fc6dda82f0a0ced7beb8e08a41657c16ef468b228a827"
~"9be331a703c33596fd15c13b1b07f9aa1d3bea57789ca031ad85c7a71dd70354ec631238ca3445"));
assert(digest512_224 == cast(ubyte[])x"e5302d6d54bb242275d1e7622d68df6eb02dedd13f564c13dbda2174");
assert(digest512_256 == cast(ubyte[])x"bde8e1f9f19bb9fd3406c90ec6bc47bd36d8ada9f11880dbc8a22a7078b6a461");

Expand All @@ -999,8 +1010,10 @@ unittest
assert(digest == cast(ubyte[])x"c12252ceda8be8994d5fa0290a47231c1d16aae3");
assert(digest224 == cast(ubyte[])x"2cb21c83ae2f004de7e81c3c7019cbcb65b71ab656b22d6d0c39b8eb");
assert(digest256 == cast(ubyte[])x"f7846f55cf23e14eebeab5b4e1550cad5b509e3348fbc4efa3a1413d393cb650");
assert(digest384 == cast(ubyte[])x"473ed35167ec1f5d8e550368a3db39be54639f828868e9454c239fc8b52e3c61dbd0d8b4de1390c256dcbb5d5fd99cd5");
assert(digest512 == cast(ubyte[])x"107dbf389d9e9f71a3a95f6c055b9251bc5268c2be16d6c13492ea45b0199f3309e16455ab1e96118e8a905d5597b72038ddb372a89826046de66687bb420e7c");
assert(digest384 == cast(ubyte[])hexString!("473ed35167ec1f5d8e550368a3db39be54639f828868e9454c"
~"239fc8b52e3c61dbd0d8b4de1390c256dcbb5d5fd99cd5"));
assert(digest512 == cast(ubyte[])hexString!("107dbf389d9e9f71a3a95f6c055b9251bc5268c2be16d6c134"
~"92ea45b0199f3309e16455ab1e96118e8a905d5597b72038ddb372a89826046de66687bb420e7c"));
assert(digest512_224 == cast(ubyte[])x"ad1a4db188fe57064f4f24609d2a83cd0afb9b398eb2fcaeaae2c564");
assert(digest512_256 == cast(ubyte[])x"0cf471fd17ed69d990daf3433c89b16d63dec1bb9cb42a6094604ee5d7b4e9fb");

Expand All @@ -1014,8 +1027,10 @@ unittest
assert(digest == cast(ubyte[])x"32d10c7b8cf96570ca04ce37f2a19d84240d3a89");
assert(digest224 == cast(ubyte[])x"45a5f72c39c5cff2522eb3429799e49e5f44b356ef926bcf390dccc2");
assert(digest256 == cast(ubyte[])x"71c480df93d6ae2f1efad1447c66c9525e316218cf51fc8d9ed832f2daf18b73");
assert(digest384 == cast(ubyte[])x"feb67349df3db6f5924815d6c3dc133f091809213731fe5c7b5f4999e463479ff2877f5f2936fa63bb43784b12f3ebb4");
assert(digest512 == cast(ubyte[])x"4dbff86cc2ca1bae1e16468a05cb9881c97f1753bce3619034898faa1aabe429955a1bf8ec483d7421fe3c1646613a59ed5441fb0f321389f77f48a879c7b1f1");
assert(digest384 == cast(ubyte[])hexString!("feb67349df3db6f5924815d6c3dc133f091809213731fe5c7b5"
~"f4999e463479ff2877f5f2936fa63bb43784b12f3ebb4"));
assert(digest512 == cast(ubyte[])hexString!("4dbff86cc2ca1bae1e16468a05cb9881c97f1753bce3619034"
~"898faa1aabe429955a1bf8ec483d7421fe3c1646613a59ed5441fb0f321389f77f48a879c7b1f1"));
assert(digest512_224 == cast(ubyte[])x"ff83148aa07ec30655c1b40aff86141c0215fe2a54f767d3f38743d8");
assert(digest512_256 == cast(ubyte[])x"fc3189443f9c268f626aea08a756abe7b726b05f701cb08222312ccfd6710a26");

Expand All @@ -1029,8 +1044,10 @@ unittest
assert(digest == cast(ubyte[])x"761c457bf73b14d27e9e9265c46f4b4dda11f940");
assert(digest224 == cast(ubyte[])x"bff72b4fcb7d75e5632900ac5f90d219e05e97a7bde72e740db393d9");
assert(digest256 == cast(ubyte[])x"db4bfcbd4da0cd85a60c3c37d3fbd8805c77f15fc6b1fdfe614ee0a7c8fdb4c0");
assert(digest384 == cast(ubyte[])x"1761336e3f7cbfe51deb137f026f89e01a448e3b1fafa64039c1464ee8732f11a5341a6f41e0c202294736ed64db1a84");
assert(digest512 == cast(ubyte[])x"1e07be23c26a86ea37ea810c8ec7809352515a970e9253c26f536cfc7a9996c45c8370583e0a78fa4a90041d71a4ceab7423f19c71b9d5a3e01249f0bebd5894");
assert(digest384 == cast(ubyte[])hexString!("1761336e3f7cbfe51deb137f026f89e01a448e3b1fafa64039"
~"c1464ee8732f11a5341a6f41e0c202294736ed64db1a84"));
assert(digest512 == cast(ubyte[])hexString!("1e07be23c26a86ea37ea810c8ec7809352515a970e9253c26f"
~"536cfc7a9996c45c8370583e0a78fa4a90041d71a4ceab7423f19c71b9d5a3e01249f0bebd5894"));
assert(digest512_224 == cast(ubyte[])x"a8b4b9174b99ffc67d6f49be9981587b96441051e16e6dd036b140d3");
assert(digest512_256 == cast(ubyte[])x"cdf1cc0effe26ecc0c13758f7b4a48e000615df241284185c39eb05d355bb9c8");

Expand All @@ -1051,8 +1068,10 @@ unittest
assert(digest == cast(ubyte[])x"50abf5706a150990a08b2c5ea40fa0e585554732");
assert(digest224 == cast(ubyte[])x"b50aecbe4e9bb0b57bc5f3ae760a8e01db24f203fb3cdcd13148046e");
assert(digest256 == cast(ubyte[])x"f371bc4a311f2b009eef952dd83ca80e2b60026c8e935592d0f9c308453c813e");
assert(digest384 == cast(ubyte[])x"b12932b0627d1c060942f5447764155655bd4da0c9afa6dd9b9ef53129af1b8fb0195996d2de9ca0df9d821ffee67026");
assert(digest512 == cast(ubyte[])x"72ec1ef1124a45b047e8b7c75a932195135bb61de24ec0d1914042246e0aec3a2354e093d76f3048b456764346900cb130d2a4fd5dd16abb5e30bcb850dee843");
assert(digest384 == cast(ubyte[])hexString!("b12932b0627d1c060942f5447764155655bd4da0c9afa6dd9b"
~"9ef53129af1b8fb0195996d2de9ca0df9d821ffee67026"));
assert(digest512 == cast(ubyte[])hexString!("72ec1ef1124a45b047e8b7c75a932195135bb61de24ec0d191"
~"4042246e0aec3a2354e093d76f3048b456764346900cb130d2a4fd5dd16abb5e30bcb850dee843"));
assert(digest512_224 == cast(ubyte[])x"ae988faaa47e401a45f704d1272d99702458fea2ddc6582827556dd2");
assert(digest512_256 == cast(ubyte[])x"2c9fdbc0c90bdd87612ee8455474f9044850241dc105b1e8b94b8ddf5fac9148");

Expand All @@ -1068,8 +1087,10 @@ unittest
assert(digest == cast(ubyte[])x"34aa973cd4c4daa4f61eeb2bdbad27316534016f");
assert(digest224 == cast(ubyte[])x"20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67");
assert(digest256 == cast(ubyte[])x"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0");
assert(digest384 == cast(ubyte[])x"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985");
assert(digest512 == cast(ubyte[])x"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b");
assert(digest384 == cast(ubyte[])hexString!("9d0e1809716474cb086e834e310a4a1ced149e9c00f2485279"
~"72cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985"));
assert(digest512 == cast(ubyte[])hexString!("e718483d0ce769644e2e42c7bc15b4638e1f98b13b20442856"
~"32a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b"));
assert(digest512_224 == cast(ubyte[])x"37ab331d76f0d36de422bd0edeb22a28accd487b7a8453ae965dd287");
assert(digest512_256 == cast(ubyte[])x"9a59a052930187a97038cae692f30708aa6491923ef5194394dc68d56c74fb21");

Expand All @@ -1084,8 +1105,10 @@ unittest
assert(digest == cast(ubyte[])x"34aa973cd4c4daa4f61eeb2bdbad27316534016f");
assert(digest224 == cast(ubyte[])x"20794655980c91d8bbb4c1ea97618a4bf03f42581948b2ee4ee7ad67");
assert(digest256 == cast(ubyte[])x"cdc76e5c9914fb9281a1c7e284d73e67f1809a48a497200e046d39ccc7112cd0");
assert(digest384 == cast(ubyte[])x"9d0e1809716474cb086e834e310a4a1ced149e9c00f248527972cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985");
assert(digest512 == cast(ubyte[])x"e718483d0ce769644e2e42c7bc15b4638e1f98b13b2044285632a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b");
assert(digest384 == cast(ubyte[])hexString!("9d0e1809716474cb086e834e310a4a1ced149e9c00f2485279"
~"72cec5704c2a5b07b8b3dc38ecc4ebae97ddd87f3d8985"));
assert(digest512 == cast(ubyte[])hexString!("e718483d0ce769644e2e42c7bc15b4638e1f98b13b20442856"
~"32a803afa973ebde0ff244877ea60a4cb0432ce577c31beb009c5c2c49aa2e4eadb217ad8cc09b"));
assert(digest512_224 == cast(ubyte[])x"37ab331d76f0d36de422bd0edeb22a28accd487b7a8453ae965dd287");
assert(digest512_256 == cast(ubyte[])x"9a59a052930187a97038cae692f30708aa6491923ef5194394dc68d56c74fb21");

Expand Down
3 changes: 2 additions & 1 deletion std/encoding.d
Original file line number Diff line number Diff line change
Expand Up @@ -2274,7 +2274,8 @@ unittest

string asciiCharString = to!string(iota(0, 128, 1));

alias Types = AliasSeq!(string, Latin1String, Latin2String, AsciiString, Windows1250String, Windows1252String, dstring, wstring);
alias Types = AliasSeq!(string, Latin1String, Latin2String, AsciiString,
Windows1250String, Windows1252String, dstring, wstring);
foreach (S; Types)
foreach (D; Types)
{
Expand Down
25 changes: 20 additions & 5 deletions std/exception.d
Original file line number Diff line number Diff line change
Expand Up @@ -357,8 +357,8 @@ unittest
enforce(line.length, "Expected a non-empty line.");
--------------------
+/
T enforce(E : Throwable = Exception, T)(T value, lazy const(char)[] msg = null, string file = __FILE__, size_t line = __LINE__)
if (is(typeof({ if (!value) {} })))
T enforce(E : Throwable = Exception, T)(T value, lazy const(char)[] msg = null,
string file = __FILE__, size_t line = __LINE__) if (is(typeof({ if (!value) {} })))
{
if (!value) bailOut!E(file, line, msg);
return value;
Expand Down Expand Up @@ -1568,7 +1568,12 @@ class ErrnoException : Exception
CommonType!(T1, T2) ifThrown(E : Throwable = Exception, T1, T2)(lazy scope T1 expression, lazy scope T2 errorHandler)
{
static assert(!is(typeof(return) == void),
"The error handler's return value(" ~ T2.stringof ~ ") does not have a common type with the expression(" ~ T1.stringof ~ ").");
"The error handler's return value("
~ T2.stringof ~
") does not have a common type with the expression("
~ T1.stringof ~
")."
);
try
{
return expression();
Expand All @@ -1584,7 +1589,12 @@ CommonType!(T1, T2) ifThrown(E : Throwable = Exception, T1, T2)(lazy scope T1 ex
CommonType!(T1, T2) ifThrown(E : Throwable, T1, T2)(lazy scope T1 expression, scope T2 delegate(E) errorHandler)
{
static assert(!is(typeof(return) == void),
"The error handler's return value(" ~ T2.stringof ~ ") does not have a common type with the expression(" ~ T1.stringof ~ ").");
"The error handler's return value("
~ T2.stringof ~
") does not have a common type with the expression("
~ T1.stringof ~
")."
);
try
{
return expression();
Expand All @@ -1600,7 +1610,12 @@ CommonType!(T1, T2) ifThrown(E : Throwable, T1, T2)(lazy scope T1 expression, sc
CommonType!(T1, T2) ifThrown(T1, T2)(lazy scope T1 expression, scope T2 delegate(Exception) errorHandler)
{
static assert(!is(typeof(return) == void),
"The error handler's return value(" ~ T2.stringof ~ ") does not have a common type with the expression(" ~ T1.stringof ~ ").");
"The error handler's return value("
~ T2.stringof ~
") does not have a common type with the expression("
~ T1.stringof ~
")."
);
try
{
return expression();
Expand Down
6 changes: 4 additions & 2 deletions std/experimental/allocator/mallocator.d
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,10 @@ struct AlignedMallocator
return null;

else if (code == EINVAL)
assert (0, "AlignedMallocator.alignment is not a power of two multiple of (void*).sizeof, according to posix_memalign!");

{
assert(0, "AlignedMallocator.alignment is not a power of two "
~"multiple of (void*).sizeof, according to posix_memalign!");
}
else if (code != 0)
assert (0, "posix_memalign returned an unknown code!");

Expand Down
3 changes: 2 additions & 1 deletion std/experimental/ndslice/iteration.d
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,8 @@ template rotated(size_t dimensionA, size_t dimensionB)
}

/// ditto
Slice!(N, Range) rotated(size_t N, Range)(Slice!(N, Range) slice, size_t dimensionA, size_t dimensionB, sizediff_t k = 1)
Slice!(N, Range) rotated(size_t N, Range)(Slice!(N, Range) slice,
size_t dimensionA, size_t dimensionB, sizediff_t k = 1)
in{
{
alias dimension = dimensionA;
Expand Down
6 changes: 4 additions & 2 deletions std/file.d
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ private T cenforce(T)(T condition, lazy const(char)[] name, string file = __FILE

version (Windows)
@trusted
private T cenforce(T)(T condition, const(char)[] name, const(FSChar)* namez, string file = __FILE__, size_t line = __LINE__)
private T cenforce(T)(T condition, const(char)[] name, const(FSChar)* namez,
string file = __FILE__, size_t line = __LINE__)
{
if (condition)
return condition;
Expand All @@ -187,7 +188,8 @@ private T cenforce(T)(T condition, const(char)[] name, const(FSChar)* namez, str

version (Posix)
@trusted
private T cenforce(T)(T condition, const(char)[] name, const(FSChar)* namez, string file = __FILE__, size_t line = __LINE__)
private T cenforce(T)(T condition, const(char)[] name, const(FSChar)* namez,
string file = __FILE__, size_t line = __LINE__)
{
if (condition)
return condition;
Expand Down
18 changes: 12 additions & 6 deletions std/format.d
Original file line number Diff line number Diff line change
Expand Up @@ -1489,7 +1489,8 @@ unittest
assert(w.data == "1337");
}

private void formatIntegral(Writer, T, Char)(Writer w, const(T) val, const ref FormatSpec!Char fs, uint base, ulong mask)
private void formatIntegral(Writer, T, Char)(Writer w, const(T) val, const ref FormatSpec!Char fs,
uint base, ulong mask)
{
T arg = val;

Expand Down Expand Up @@ -2050,16 +2051,18 @@ unittest
formatTest( "%-r", "ab"w, ['a', 0 , 'b', 0 ] );
formatTest( "%-r", "ab"d, ['a', 0, 0, 0, 'b', 0, 0, 0] );
formatTest( "%-r", "日本語"c, ['\xe6', '\x97', '\xa5', '\xe6', '\x9c', '\xac', '\xe8', '\xaa', '\x9e'] );
formatTest( "%-r", "日本語"w, ['\xe5', '\x65', '\x2c', '\x67', '\x9e', '\x8a' ] );
formatTest( "%-r", "日本語"d, ['\xe5', '\x65', '\x00', '\x00', '\x2c', '\x67', '\x00', '\x00', '\x9e', '\x8a', '\x00', '\x00'] );
formatTest( "%-r", "日本語"w, ['\xe5', '\x65', '\x2c', '\x67', '\x9e', '\x8a']);
formatTest( "%-r", "日本語"d, ['\xe5', '\x65', '\x00', '\x00', '\x2c', '\x67',
'\x00', '\x00', '\x9e', '\x8a', '\x00', '\x00'] );

//Big Endian
formatTest( "%+r", "ab"c, [ 'a', 'b'] );
formatTest( "%+r", "ab"w, [ 0, 'a', 0, 'b'] );
formatTest( "%+r", "ab"d, [0, 0, 0, 'a', 0, 0, 0, 'b'] );
formatTest( "%+r", "日本語"c, ['\xe6', '\x97', '\xa5', '\xe6', '\x9c', '\xac', '\xe8', '\xaa', '\x9e'] );
formatTest( "%+r", "日本語"w, [ '\x65', '\xe5', '\x67', '\x2c', '\x8a', '\x9e'] );
formatTest( "%+r", "日本語"d, ['\x00', '\x00', '\x65', '\xe5', '\x00', '\x00', '\x67', '\x2c', '\x00', '\x00', '\x8a', '\x9e'] );
formatTest( "%+r", "日本語"w, ['\x65', '\xe5', '\x67', '\x2c', '\x8a', '\x9e'] );
formatTest( "%+r", "日本語"d, ['\x00', '\x00', '\x65', '\xe5', '\x00', '\x00',
'\x67', '\x2c', '\x00', '\x00', '\x8a', '\x9e'] );
}

/**
Expand Down Expand Up @@ -4384,7 +4387,10 @@ T unformatValue(T, Range, Char)(ref Range input, ref FormatSpec!Char spec)
{
// raw read
//enforce(input.length >= T.sizeof);
enforce(isSomeString!Range || ElementType!(Range).sizeof == 1, "Cannot parse input of type %s".format(Range.stringof));
enforce(
isSomeString!Range || ElementType!(Range).sizeof == 1,
"Cannot parse input of type %s".format(Range.stringof)
);
union X
{
ubyte[T.sizeof] raw;
Expand Down
3 changes: 2 additions & 1 deletion std/internal/math/biguintx86.d
Original file line number Diff line number Diff line change
Expand Up @@ -623,7 +623,8 @@ unittest
{
uint [] aa = [0xF0FF_FFFF, 0x1222_2223, 0x4555_5556, 0x8999_999A, 0xBCCC_CCCD, 0xEEEE_EEEE];
multibyteMul(aa[1..4], aa[1..4], 16, 0);
assert(aa[0] == 0xF0FF_FFFF && aa[1] == 0x2222_2230 && aa[2]==0x5555_5561 && aa[3]==0x9999_99A4 && aa[4]==0x0BCCC_CCCD);
assert(aa[0] == 0xF0FF_FFFF && aa[1] == 0x2222_2230 &&
aa[2]==0x5555_5561 && aa[3]==0x9999_99A4 && aa[4]==0x0BCCC_CCCD);
}

// The inner multiply-and-add loop, together with the Even entry point.
Expand Down
5 changes: 4 additions & 1 deletion std/internal/math/gammafunction.d
Original file line number Diff line number Diff line change
Expand Up @@ -951,7 +951,10 @@ unittest { // also tested by the normal distribution
assert(betaIncompleteInv(0.01, 8e-48, 9e-26) == 1-real.epsilon);

// Beware: a one-bit change in pow() changes almost all digits in the result!
assert(feqrel(betaIncompleteInv(0x1.b3d151fbba0eb18p+1, 1.2265e-19, 2.44859e-18), 0x1.c0110c8531d0952cp-1L) > 10);
assert(feqrel(
betaIncompleteInv(0x1.b3d151fbba0eb18p+1, 1.2265e-19, 2.44859e-18),
0x1.c0110c8531d0952cp-1L
) > 10);
// This next case uncovered a one-bit difference in the FYL2X instruction
// between Intel and AMD processors. This difference gets magnified by 2^^38.
// WolframAlpha crashes attempting to calculate this.
Expand Down
2,994 changes: 2,972 additions & 22 deletions std/internal/unicode_comp.d

Large diffs are not rendered by default.

5,311 changes: 5,289 additions & 22 deletions std/internal/unicode_decomp.d

Large diffs are not rendered by default.

303 changes: 283 additions & 20 deletions std/internal/unicode_grapheme.d

Large diffs are not rendered by default.

558 changes: 538 additions & 20 deletions std/internal/unicode_norm.d

Large diffs are not rendered by default.

8,979 changes: 8,843 additions & 136 deletions std/internal/unicode_tables.d

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions std/json.d
Original file line number Diff line number Diff line change
Expand Up @@ -989,7 +989,8 @@ if (isInputRange!T)
else
value.store.uinteger = parse!ulong(data);

value.type_tag = !isNegative && value.store.uinteger & (1UL << 63) ? JSON_TYPE.UINTEGER : JSON_TYPE.INTEGER;
value.type_tag = !isNegative && value.store.uinteger & (1UL << 63) ?
JSON_TYPE.UINTEGER : JSON_TYPE.INTEGER;
}
break;

Expand Down Expand Up @@ -1507,7 +1508,8 @@ unittest
`[12,"foo",true,false]`,
`{}`,
`{"a":1,"b":null}`,
`{"goodbye":[true,"or",false,["test",42,{"nested":{"a":23.54,"b":0.0012}}]],"hello":{"array":[12,null,{}],"json":"is great"}}`,
`{"goodbye":[true,"or",false,["test",42,{"nested":{"a":23.54,"b":0.0012}}]],`
~`"hello":{"array":[12,null,{}],"json":"is great"}}`,
];

version (MinGW)
Expand Down
4 changes: 3 additions & 1 deletion std/math.d
Original file line number Diff line number Diff line change
Expand Up @@ -4135,7 +4135,9 @@ real round(real x) @trusted nothrow @nogc
version (CRuntime_Microsoft)
{
auto old = FloatingPointControl.getControlState();
FloatingPointControl.setControlState((old & ~FloatingPointControl.ROUNDING_MASK) | FloatingPointControl.roundToZero);
FloatingPointControl.setControlState(
(old & ~FloatingPointControl.ROUNDING_MASK) | FloatingPointControl.roundToZero
);
x = rint((x >= 0) ? x + 0.5 : x - 0.5);
FloatingPointControl.setControlState(old);
return x;
Expand Down
5 changes: 4 additions & 1 deletion std/net/curl.d
Original file line number Diff line number Diff line change
Expand Up @@ -3903,7 +3903,10 @@ private struct CurlAPI
version (OSX)
static immutable names = ["libcurl.4.dylib"];
else version (Posix)
static immutable names = ["libcurl.so", "libcurl.so.4", "libcurl-gnutls.so.4", "libcurl-nss.so.4", "libcurl.so.3"];
{
static immutable names = ["libcurl.so", "libcurl.so.4",
"libcurl-gnutls.so.4", "libcurl-nss.so.4", "libcurl.so.3"];
}
else version (Windows)
static immutable names = ["libcurl.dll", "curl.dll"];

Expand Down
33 changes: 20 additions & 13 deletions std/net/isemail.d
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,8 @@ EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = CheckDns.no
break;

default:
throw new Exception("More text found where none is allowed, but unrecognised prior " ~
"context: " ~ to!(string)(contextPrior));
throw new Exception("More text found where none is allowed, but "
~"unrecognised prior context: " ~ to!(string)(contextPrior));
}
}

Expand All @@ -254,9 +254,11 @@ EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = CheckDns.no
{
case Token.openParenthesis:
if (elementLength == 0)
returnStatus ~= elementCount == 0 ? EmailStatusCode.deprecatedCommentFoldingWhitespaceNearAt
{
returnStatus ~= elementCount == 0 ?
EmailStatusCode.deprecatedCommentFoldingWhitespaceNearAt
: EmailStatusCode.deprecatedComment;

}
else
{
returnStatus ~= EmailStatusCode.comment;
Expand Down Expand Up @@ -316,9 +318,11 @@ EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = CheckDns.no
}

if (elementLength == 0)
returnStatus ~= elementCount == 0 ? EmailStatusCode.deprecatedCommentFoldingWhitespaceNearAt
{
returnStatus ~= elementCount == 0 ?
EmailStatusCode.deprecatedCommentFoldingWhitespaceNearAt
: EmailStatusCode.deprecatedFoldingWhitespace;

}
else
{
returnStatus ~= EmailStatusCode.foldingWhitespace;
Expand All @@ -345,8 +349,8 @@ EmailStatus isEmail (Char) (const(Char)[] email, CheckDns checkDNS = CheckDns.no
break;

default:
throw new Exception("More text found where none is allowed, but unrecognised prior " ~
"context: " ~ to!(string)(contextPrior));
throw new Exception("More text found where none is allowed, but "
~"unrecognised prior context: " ~ to!(string)(contextPrior));
}

}
Expand Down Expand Up @@ -1099,9 +1103,12 @@ unittest
assert(`test@[RFC-5322-domain-literal] (comment)`.isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
EmailStatusCode.rfc5322DomainLiteral);

assert("\u007F@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorExpectingText);
assert("test@\u007F.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorExpectingText);
assert("\"\u007F\"@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.deprecatedQuotedText);
assert("\u007F@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
EmailStatusCode.errorExpectingText);
assert("test@\u007F.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
EmailStatusCode.errorExpectingText);
assert("\"\u007F\"@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
EmailStatusCode.deprecatedQuotedText);

assert("\"\\\u007F\"@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
EmailStatusCode.deprecatedQuotedPair);
Expand All @@ -1115,8 +1122,8 @@ unittest
assert("\u000Dtest@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorCrNoLf,
`No LF after the CR`);

assert("\"\u000Dtest\"@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorCrNoLf
,`No LF after the CR`);
assert("\"\u000Dtest\"@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode ==
EmailStatusCode.errorCrNoLf, `No LF after the CR`);

assert("(\u000D)test@iana.org".isEmail(CheckDns.no, EmailStatusCode.any).statusCode == EmailStatusCode.errorCrNoLf,
`No LF after the CR`);
Expand Down
6 changes: 4 additions & 2 deletions std/process.d
Original file line number Diff line number Diff line change
Expand Up @@ -2871,14 +2871,16 @@ unittest

e = escapeShellCommand(helper ~ s) ~ ">" ~ escapeShellFileName(fn);
{
scope(failure) writefln("executeShell() with redirect failed.\nExpected:\t%s\nFilename:\t%s\nEncoded:\t%s", s, [fn], [e]);
scope(failure) writefln(
"executeShell() with redirect failed.\nExpected:\t%s\nFilename:\t%s\nEncoded:\t%s", s, [fn], [e]);
auto result = executeShell(e);
assert(result.status == 0, "std_process_unittest_helper failed");
assert(!result.output.length, "No output expected, got:\n" ~ result.output);
g = readText(fn).split("\0")[1..$];
}
remove(fn);
assert(s == g, format("executeShell() with redirect test failed.\nExpected:\t%s\nGot:\t\t%s\nEncoded:\t%s", s, g, [e]));
assert(s == g,
format("executeShell() with redirect test failed.\nExpected:\t%s\nGot:\t\t%s\nEncoded:\t%s", s, g, [e]));
}

while (true)
Expand Down
34 changes: 24 additions & 10 deletions std/random.d
Original file line number Diff line number Diff line change
Expand Up @@ -1060,12 +1060,18 @@ unittest

// Result from reference implementation.
auto checking = [
[2463534242UL, 901999875, 3371835698, 2675058524, 1053936272, 3811264849, 472493137, 3856898176, 2131710969, 2312157505],
[362436069UL, 2113136921, 19051112, 3010520417, 951284840, 1213972223, 3173832558, 2611145638, 2515869689, 2245824891],
[521288629UL, 1950277231, 185954712, 1582725458, 3580567609, 2303633688, 2394948066, 4108622809, 1116800180, 3357585673],
[88675123UL, 3701687786, 458299110, 2500872618, 3633119408, 516391518, 2377269574, 2599949379, 717229868, 137866584],
[5783321UL, 393427209, 1947109840, 565829276, 1006220149, 971147905, 1436324242, 2800460115, 1484058076, 3823330032],
[0UL, 246875399, 3690007200, 1264581005, 3906711041, 1866187943, 2481925219, 2464530826, 1604040631, 3653403911]
[2463534242UL, 901999875, 3371835698, 2675058524, 1053936272, 3811264849,
472493137, 3856898176, 2131710969, 2312157505],
[362436069UL, 2113136921, 19051112, 3010520417, 951284840, 1213972223,
3173832558, 2611145638, 2515869689, 2245824891],
[521288629UL, 1950277231, 185954712, 1582725458, 3580567609, 2303633688,
2394948066, 4108622809, 1116800180, 3357585673],
[88675123UL, 3701687786, 458299110, 2500872618, 3633119408, 516391518,
2377269574, 2599949379, 717229868, 137866584],
[5783321UL, 393427209, 1947109840, 565829276, 1006220149, 971147905,
1436324242, 2800460115, 1484058076, 3823330032],
[0UL, 246875399, 3690007200, 1264581005, 3906711041, 1866187943, 2481925219,
2464530826, 1604040631, 3653403911]
];

alias XorshiftTypes = std.meta.AliasSeq!(Xorshift32, Xorshift64, Xorshift96, Xorshift128, Xorshift160, Xorshift192);
Expand Down Expand Up @@ -2823,10 +2829,18 @@ unittest
/* Check that randomSample will throw an error if we claim more
* items are available than there actually are, or if we try to
* sample more items than are available. */
assert(collectExceptionMsg(randomSample(a, 5, 15)) == "RandomSample: specified 15 items as available when input contains only 10");
assert(collectExceptionMsg(randomSample(a, 15)) == "RandomSample: cannot sample 15 items when only 10 are available");
assert(collectExceptionMsg(randomSample(a, 9, 8)) == "RandomSample: cannot sample 9 items when only 8 are available");
assert(collectExceptionMsg(randomSample(TestInputRange(), 12, 11)) == "RandomSample: cannot sample 12 items when only 11 are available");
assert(collectExceptionMsg(
randomSample(a, 5, 15)
) == "RandomSample: specified 15 items as available when input contains only 10");
assert(collectExceptionMsg(
randomSample(a, 15)
) == "RandomSample: cannot sample 15 items when only 10 are available");
assert(collectExceptionMsg(
randomSample(a, 9, 8)
) == "RandomSample: cannot sample 9 items when only 8 are available");
assert(collectExceptionMsg(
randomSample(TestInputRange(), 12, 11)
) == "RandomSample: cannot sample 12 items when only 11 are available");

/* Check that sampling algorithm never accidentally overruns the end of
* the input range. If input is an InputRange without .length, this
Expand Down
3 changes: 2 additions & 1 deletion std/range/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -4293,7 +4293,8 @@ string lockstepReverseFailMixin(Ranges...)(bool withIndex)

if (withIndex)
{
message = "Indexed reverse iteration with lockstep is only supported if all ranges are bidirectional and have a length.\n";
message = "Indexed reverse iteration with lockstep is only supported"
~"if all ranges are bidirectional and have a length.\n";
}
else
{
Expand Down
3 changes: 2 additions & 1 deletion std/range/primitives.d
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,8 @@ void put(R, E)(ref R r, E e)
//Special optimization: If E is a narrow string, and r accepts characters no-wider than the string's
//Then simply feed the characters 1 by 1.
static if (isNarrowString!E && (
(is(E : const char[]) && is(typeof(doPut(r, char.max))) && !is(typeof(doPut(r, dchar.max))) && !is(typeof(doPut(r, wchar.max)))) ||
(is(E : const char[]) && is(typeof(doPut(r, char.max))) && !is(typeof(doPut(r, dchar.max))) &&
!is(typeof(doPut(r, wchar.max)))) ||
(is(E : const wchar[]) && is(typeof(doPut(r, wchar.max))) && !is(typeof(doPut(r, dchar.max)))) ) )
{
foreach (c; e)
Expand Down
8 changes: 6 additions & 2 deletions std/regex/internal/backtracking.d
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,9 @@ template BacktrackingMatcher(bool CTregex)
}
matcher.matches = matches[ms .. me];
matcher.backrefed = backrefed.empty ? matches : backrefed;
matcher.re.ir = re.ir[pc+IRL!(IR.LookaheadStart) .. pc+IRL!(IR.LookaheadStart)+len+IRL!(IR.LookaheadEnd)];
matcher.re.ir = re.ir[
pc+IRL!(IR.LookaheadStart) .. pc+IRL!(IR.LookaheadStart)+len+IRL!(IR.LookaheadEnd)
];
bool match = (matcher.matchImpl() != 0) ^ (re.ir[pc].code == IR.NeglookaheadStart);
s.reset(save);
next();
Expand Down Expand Up @@ -593,7 +595,9 @@ template BacktrackingMatcher(bool CTregex)
auto matcher = Matcher(re, s.loopBack(index), mem);
}
matcher.matches = matches[ms .. me];
matcher.re.ir = re.ir[pc + IRL!(IR.LookbehindStart) .. pc + IRL!(IR.LookbehindStart) + len + IRL!(IR.LookbehindEnd)];
matcher.re.ir = re.ir[
pc + IRL!(IR.LookbehindStart) .. pc + IRL!(IR.LookbehindStart) + len + IRL!(IR.LookbehindEnd)
];
matcher.backrefed = backrefed.empty ? matches : backrefed;
bool match = (matcher.matchImpl() != 0) ^ (re.ir[pc].code == IR.NeglookbehindStart);
if (!match)
Expand Down
17 changes: 11 additions & 6 deletions std/regex/internal/tests.d
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,8 @@ unittest
TestVectors( "[a-c~~b-f]+", "abcdef", "y", "$&", "a"),
//unicode blocks & properties:
TestVectors( `\P{Inlatin1suppl ement}`, "\u00c2!", "y", "$&", "!"),
TestVectors( `\p{InLatin-1 Supplement}\p{in-mathematical-operators}\P{Inlatin1suppl ement}`, "\u00c2\u2200\u00c3\u2203.", "y", "$&", "\u00c3\u2203."),
TestVectors( `\p{InLatin-1 Supplement}\p{in-mathematical-operators}\P{Inlatin1suppl ement}`,
"\u00c2\u2200\u00c3\u2203.", "y", "$&", "\u00c3\u2203."),
TestVectors( `[-+*/\p{in-mathematical-operators}]{2}`, "a+\u2212", "y", "$&", "+\u2212"),
TestVectors( `\p{Ll}+`, "XabcD", "y", "$&", "abc"),
TestVectors( `\p{Lu}+`, "абвГДЕ", "y", "$&", "ГДЕ"),
Expand All @@ -265,11 +266,11 @@ unittest
TestVectors( `[c-wф]фф`, "ффф", "y", "$&", "ффф"),
//case insensitive:
TestVectors( `^abcdEf$`, "AbCdEF", "y", "$&", "AbCdEF", "i"),
TestVectors( `Русский язык`, "рУсскИй ЯзЫк", "y", "$&", "рУсскИй ЯзЫк", "i"),
TestVectors( `Русский язык`, "рУсскИй ЯзЫк", "y", "$&", "рУсскИй ЯзЫк", "i"),
TestVectors( `ⒶⒷⓒ` , "ⓐⓑⒸ", "y", "$&", "ⓐⓑⒸ", "i"),
TestVectors( "\U00010400{2}", "\U00010428\U00010400 ", "y", "$&", "\U00010428\U00010400", "i"),
TestVectors( `[adzУ-Я]{4}`, "DzюЯ", "y", "$&", "DzюЯ", "i"),
TestVectors( `\p{L}\p{Lu}{10}`, "абвгдеЖЗИКЛ", "y", "$&", "абвгдеЖЗИКЛ", "i"),
TestVectors( `\p{L}\p{Lu}{10}`, "абвгдеЖЗИКЛ", "y", "$&", "абвгдеЖЗИКЛ", "i"),
TestVectors( `(?:Dåb){3}`, "DåbDÅBdÅb", "y", "$&", "DåbDÅBdÅb", "i"),
//escapes:
TestVectors( `\u0041\u005a\U00000065\u0001`, "AZe\u0001", "y", "$&", "AZe\u0001"),
Expand Down Expand Up @@ -383,7 +384,10 @@ unittest
{
auto m = matchFn(to!(String)(tvd.input), r);
i = !m.empty;
assert((c == 'y') ? i : !i, text(matchFn.stringof ~": failed to match pattern #", a ,": ", tvd.pattern));
assert(
(c == 'y') ? i : !i,
text(matchFn.stringof ~": failed to match pattern #", a ,": ", tvd.pattern)
);
if (c == 'y')
{
auto result = produceExpected(m, to!(String)(tvd.format));
Expand Down Expand Up @@ -689,8 +693,9 @@ unittest
== to!String("ack capacity"));
assert(std.regex.replace!(matchFn)(to!String("noon"), regex(to!String("^n")), to!String("[$&]"))
== to!String("[n]oon"));
assert(std.regex.replace!(matchFn)(to!String("test1 test2"), regex(to!String(`\w+`),"g"), to!String("$`:$'"))
== to!String(": test2 test1 :"));
assert(std.regex.replace!(matchFn)(
to!String("test1 test2"), regex(to!String(`\w+`),"g"), to!String("$`:$'")
) == to!String(": test2 test1 :"));
auto s = std.regex.replace!(baz!(Captures!(String)))(to!String("Strap a rocket engine on a chicken."),
regex(to!String("[ar]"), "g"));
assert(s == "StRAp A Rocket engine on A chicken.");
Expand Down
5 changes: 3 additions & 2 deletions std/regex/internal/thompson.d
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,9 @@ template ThompsonOps(E, S, bool withInput:true)
}
else
{
debug(std_regex_matcher) writefln("A thread(pc=%s) got merged there : %s ; GenCounter=%s mergetab=%s",
t.pc, index, genCounter, merge[re.ir[t.pc + 1].raw+t.counter] );
debug(std_regex_matcher)
writefln("A thread(pc=%s) got merged there : %s ; GenCounter=%s mergetab=%s",
t.pc, index, genCounter, merge[re.ir[t.pc + 1].raw+t.counter] );
return popState(e);
}
uint max = re.ir[t.pc+4].raw;
Expand Down
5 changes: 4 additions & 1 deletion std/regex/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,10 @@ private:
import core.stdc.stdlib;
if (n > smallString)
{
auto p = cast(Group!DataIndex*)enforce(calloc(Group!DataIndex.sizeof,n), "Failed to allocate Captures struct");
auto p = cast(Group!DataIndex*)enforce(
calloc(Group!DataIndex.sizeof,n),
"Failed to allocate Captures struct"
);
big_matches = p[0..n];
_refcount = 1;
}
Expand Down
12 changes: 8 additions & 4 deletions std/uni.d
Original file line number Diff line number Diff line change
Expand Up @@ -2379,10 +2379,12 @@ public:
assert(format("%d", unicode.Cyrillic) == unicode.Cyrillic.to!string);

assert(format("%#x", unicode.Cyrillic) ==
"[0x400..0x485) [0x487..0x528) [0x1d2b..0x1d2c) [0x1d78..0x1d79) [0x2de0..0x2e00) [0xa640..0xa698) [0xa69f..0xa6a0)");
"[0x400..0x485) [0x487..0x528) [0x1d2b..0x1d2c) [0x1d78..0x1d79) [0x2de0..0x2e00) "
~"[0xa640..0xa698) [0xa69f..0xa6a0)");

assert(format("%#X", unicode.Cyrillic) ==
"[0X400..0X485) [0X487..0X528) [0X1D2B..0X1D2C) [0X1D78..0X1D79) [0X2DE0..0X2E00) [0XA640..0XA698) [0XA69F..0XA6A0)");
"[0X400..0X485) [0X487..0X528) [0X1D2B..0X1D2C) [0X1D78..0X1D79) [0X2DE0..0X2E00) "
~"[0XA640..0XA698) [0XA69F..0XA6A0)");
}

unittest
Expand Down Expand Up @@ -5653,7 +5655,8 @@ template idxTypes(Key, size_t fullBits, Prefix...)

//============================================================================

@safe pure int comparePropertyName(Char1, Char2)(const(Char1)[] a, const(Char2)[] b) if (is(Char1 : dchar) && is(Char2 : dchar))
@safe pure int comparePropertyName(Char1, Char2)(const(Char1)[] a, const(Char2)[] b)
if (is(Char1 : dchar) && is(Char2 : dchar))
{
import std.ascii : toLower;
import std.algorithm : cmp, map, filter;
Expand All @@ -5668,7 +5671,8 @@ template idxTypes(Key, size_t fullBits, Prefix...)
assert(!comparePropertyName("foo-bar", "fooBar"));
}

bool propertyNameLess(Char1, Char2)(const(Char1)[] a, const(Char2)[] b) @safe pure if (is(Char1 : dchar) && is(Char2 : dchar))
bool propertyNameLess(Char1, Char2)(const(Char1)[] a, const(Char2)[] b) @safe pure
if (is(Char1 : dchar) && is(Char2 : dchar))
{
return comparePropertyName(a, b) < 0;
}
Expand Down
29 changes: 17 additions & 12 deletions std/utf.d
Original file line number Diff line number Diff line change
Expand Up @@ -1023,8 +1023,8 @@ body
return decodeImpl!(true, useReplacementDchar)(str, index);
}

dchar decode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(auto ref S str, ref size_t index) @trusted pure
if (isSomeString!S)
dchar decode(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(
auto ref S str, ref size_t index) @trusted pure if (isSomeString!S)
in
{
assert(index < str.length, "Attempted to decode past the end of a string");
Expand Down Expand Up @@ -1064,8 +1064,8 @@ body
type of range being used and how many code units had to be popped off
before the code point was determined to be invalid.
+/
dchar decodeFront(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(ref S str, out size_t numCodeUnits)
if (!isSomeString!S && isInputRange!S && isSomeChar!(ElementType!S))
dchar decodeFront(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(
ref S str, out size_t numCodeUnits) if (!isSomeString!S && isInputRange!S && isSomeChar!(ElementType!S))
in
{
assert(!str.empty);
Expand Down Expand Up @@ -1100,8 +1100,8 @@ body
}
}

dchar decodeFront(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(ref S str, out size_t numCodeUnits) @trusted pure
if (isSomeString!S)
dchar decodeFront(UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(
ref S str, out size_t numCodeUnits) @trusted pure if (isSomeString!S)
in
{
assert(!str.empty);
Expand Down Expand Up @@ -1164,8 +1164,9 @@ package template codeUnitLimit(S)
* Returns:
* decoded character
*/
private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(auto ref S str, ref size_t index)
if (is(S : const char[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == char)))
private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(
auto ref S str, ref size_t index) if (
is(S : const char[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == char)))
{
/* The following encodings are valid, except for the 5 and 6 byte
* combinations:
Expand Down Expand Up @@ -1393,7 +1394,8 @@ unittest
}
}

private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(auto ref S str, ref size_t index)
private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)
(auto ref S str, ref size_t index)
if (is(S : const wchar[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == wchar)))
{
static if (is(S : const wchar[]))
Expand Down Expand Up @@ -1511,7 +1513,8 @@ unittest
}
}

private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(auto ref S str, ref size_t index)
private dchar decodeImpl(bool canIndex, UseReplacementDchar useReplacementDchar = UseReplacementDchar.no, S)(
auto ref S str, ref size_t index)
if (is(S : const dchar[]) || (isInputRange!S && is(Unqual!(ElementEncodingType!S) == dchar)))
{
static if (is(S : const dchar[]))
Expand Down Expand Up @@ -1826,8 +1829,10 @@ unittest
static assert(isSafe!({ S str; size_t i = 0; decode(str, i); }));
static assert(isSafe!({ S str; size_t i = 0; decodeFront(str, i); }));
static assert(isSafe!({ S str; decodeFront(str); }));
static assert((functionAttributes!({ S str; size_t i = 0; decode(str, i); }) & FunctionAttribute.pure_) != 0);
static assert((functionAttributes!({ S str; size_t i = 0; decodeFront(str, i); }) & FunctionAttribute.pure_) != 0);
static assert((functionAttributes!({ S str; size_t i = 0; decode(str, i); }) & FunctionAttribute.pure_) != 0);
static assert((functionAttributes!({
S str; size_t i = 0; decodeFront(str, i);
}) & FunctionAttribute.pure_) != 0);
static assert((functionAttributes!({ S str; decodeFront(str); }) & FunctionAttribute.pure_) != 0);
}
});
Expand Down
5 changes: 3 additions & 2 deletions std/uuid.d
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,9 @@ public struct UUID
* Write the UUID into `result` as an ASCII string in the canonical form.
*/
@safe pure nothrow @nogc void toString(Range)(Range result) const
if (isRandomAccessRange!Range && hasAssignableElements!Range && hasLength!Range && (isSomeChar!(typeof(Range.init[0])) || isUnsigned!(typeof(Range.init[0])))
|| isSomeString!Range && isMutable!(typeof(Range.init[0])))
if (isRandomAccessRange!Range && hasAssignableElements!Range &&
hasLength!Range && (isSomeChar!(typeof(Range.init[0])) || isUnsigned!(typeof(Range.init[0]))) ||
isSomeString!Range && isMutable!(typeof(Range.init[0])))
in {
assert(result.length >= 36, "Result's length for UUID.toString must be greater or equal 36.");
}
Expand Down
6 changes: 5 additions & 1 deletion std/variant.d
Original file line number Diff line number Diff line change
Expand Up @@ -2246,7 +2246,11 @@ private auto visitImpl(bool Strict, VariantType, Handler...)(VariantType variant
static if (HandlerOverloadMap.exceptionFuncIdx != -1)
return Handler[ HandlerOverloadMap.exceptionFuncIdx ]();
else
throw new VariantException("variant holds value of type '" ~ T.stringof ~ "' but no visitor has been provided");
throw new VariantException(
"variant holds value of type '"
~ T.stringof ~
"' but no visitor has been provided"
);
}
}
else
Expand Down
5 changes: 4 additions & 1 deletion std/windows/registry.d
Original file line number Diff line number Diff line change
Expand Up @@ -1786,7 +1786,10 @@ unittest
string unittestKeyName = "Temporary key for a D UnitTest which can be deleted afterwards";
Key unittestKey = HKCU.createKey(unittestKeyName);
assert(unittestKey);
Key cityKey = unittestKey.createKey("CityCollection using foreign names with umlauts and accents: \u00f6\u00e4\u00fc\u00d6\u00c4\u00dc\u00e0\u00e1\u00e2\u00df");
Key cityKey = unittestKey.createKey(
"CityCollection using foreign names with umlauts and accents: "
~"\u00f6\u00e4\u00fc\u00d6\u00c4\u00dc\u00e0\u00e1\u00e2\u00df"
);
cityKey.setValue("K\u00f6ln", "Germany"); // Cologne
cityKey.setValue("\u041c\u0438\u043d\u0441\u043a", "Belarus"); // Minsk
cityKey.setValue("\u5317\u4eac", "China"); // Bejing
Expand Down