diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 0230d935..ad7950d9 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -37,18 +37,18 @@ jobs: run: | echo "C:\hostedtoolcache\windows\dc\ldc2-1.32.2\x64\ldc2-1.32.2-windows-multilib\lib32" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append - - run: dub test --arch=${{ matrix.arch }} + - run: dub test --debug=ae_unittest --arch=${{ matrix.arch }} - - run: dub test --arch=${{ matrix.arch }} :sys-net-test + - run: dub test --debug=ae_unittest --arch=${{ matrix.arch }} :sys-net-test - if: ${{ matrix.os == 'ubuntu-20.04' }} - run: dub test --arch=${{ matrix.arch }} :sqlite + run: dub test --debug=ae_unittest --arch=${{ matrix.arch }} :sqlite - if: ${{ matrix.os == 'ubuntu-20.04' && matrix.dc == 'dmd-2.100.0' }} # old Dub versions can't fetch packages - run: dub test --arch=${{ matrix.arch }} :libpng + run: dub test --debug=ae_unittest --arch=${{ matrix.arch }} :libpng - if: ${{ matrix.dc == 'dmd-2.100.0' }} - run: dub test --arch=${{ matrix.arch }} :windows + run: dub test --debug=ae_unittest --arch=${{ matrix.arch }} :windows compilation-test: timeout-minutes: 5 diff --git a/dub.sdl b/dub.sdl index a0365555..404196b9 100644 --- a/dub.sdl +++ b/dub.sdl @@ -66,11 +66,6 @@ excludedSourceFiles "utils/container/package.d" excludedSourceFiles "utils/serialization/*.d" excludedSourceFiles "utils/xmldom.d" - -configuration "unittest" { - versions "ae_unittest" -} - --------------------------- subPackage { diff --git a/net/asockets.d b/net/asockets.d index 33d89496..d183420c 100644 --- a/net/asockets.d +++ b/net/asockets.d @@ -1311,7 +1311,7 @@ class Duplex : IConnection @property void handleBufferFlushed(BufferFlushedHandler value) { writer.handleBufferFlushed = value; } } -version(ae_unittest) unittest { if (false) new Duplex(null, null); } +debug(ae_unittest) unittest { if (false) new Duplex(null, null); } // *************************************************************************** @@ -1899,7 +1899,7 @@ public: } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto server = new UdpConnection(); server.bind("127.0.0.1", 0); @@ -2216,7 +2216,7 @@ private: // *************************************************************************** -version(ae_unittest) unittest +debug(ae_unittest) unittest { void testTimer() { diff --git a/net/db/psql/package.d b/net/db/psql/package.d index 93bf9974..d0afbd0a 100644 --- a/net/db/psql/package.d +++ b/net/db/psql/package.d @@ -265,7 +265,7 @@ private: mixin DeclareException!q{PgSqlException}; version (HAVE_PSQL_SERVER) -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.process : environment; diff --git a/net/github/rest.d b/net/github/rest.d index 2eb57289..e680c651 100644 --- a/net/github/rest.d +++ b/net/github/rest.d @@ -182,7 +182,7 @@ struct GitHub return result; } - version(ae_unittest) unittest + debug(ae_unittest) unittest { auto header = `; rel="next", ` ~ `; rel="last"`; diff --git a/net/http/app/server.d b/net/http/app/server.d index 6869b1d6..791afbbd 100644 --- a/net/http/app/server.d +++ b/net/http/app/server.d @@ -14,7 +14,7 @@ module ae.net.http.app.server; -debug version(ae_unittest) version = SSL; +debug debug(ae_unittest) version = SSL; import std.algorithm.comparison; import std.algorithm.searching; @@ -499,7 +499,7 @@ private: } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias Test = Server!false; } diff --git a/net/http/client.d b/net/http/client.d index 9546a084..1212c7d4 100644 --- a/net/http/client.d +++ b/net/http/client.d @@ -726,13 +726,13 @@ void httpPost(string url, UrlParameters vars, void delegate(string) resultHandle } // https://issues.dlang.org/show_bug.cgi?id=7016 -version (ae_unittest) +debug (ae_unittest) { static import ae.net.http.server; static import ae.net.http.responseex; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.net.http.common : HttpRequest, HttpResponse; import ae.net.http.server : HttpServer, HttpServerConnection; diff --git a/net/http/common.d b/net/http/common.d index 2b2cc260..5d1fb1a7 100644 --- a/net/http/common.d +++ b/net/http/common.d @@ -380,7 +380,7 @@ public: .auniq(); } - version(ae_unittest) deprecated unittest + debug(ae_unittest) deprecated unittest { auto req = new HttpRequest(); assert(req.remoteHosts() == []); @@ -760,7 +760,7 @@ string[] parseItemList(string s) .amap!`a.str`(); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(parseItemList("a, b, c;q=0.5, d") == ["a", "b", "d", "c"]); } @@ -850,7 +850,7 @@ MultipartPart[] decodeMultipart(Data data, string boundary) return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto parts = [ MultipartPart(Headers(["Foo" : "bar"]), Data.init), diff --git a/net/http/exception.d b/net/http/exception.d index c8887a11..02bbaa5f 100644 --- a/net/http/exception.d +++ b/net/http/exception.d @@ -31,7 +31,7 @@ class HttpException : Exception } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.net.http.responseex : HttpResponseEx; auto response = new HttpResponseEx; diff --git a/net/http/fastcgi/app.d b/net/http/fastcgi/app.d index 60533a30..44d0de2d 100644 --- a/net/http/fastcgi/app.d +++ b/net/http/fastcgi/app.d @@ -529,7 +529,7 @@ class FastCGIResponderServer : FastCGIAppSocketServer } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { new FastCGIResponderServer; } diff --git a/net/http/server.d b/net/http/server.d index bef1c7a3..9e02fda3 100644 --- a/net/http/server.d +++ b/net/http/server.d @@ -665,9 +665,9 @@ string formatAddress(string protocol, Address address, string vhost = null, usho (port is null || port == "80" ? "" : ":" ~ port); } -version (ae_unittest) import ae.net.http.client; -version (ae_unittest) import ae.net.http.responseex; -version(ae_unittest) unittest +debug (ae_unittest) import ae.net.http.client; +debug (ae_unittest) import ae.net.http.responseex; +debug(ae_unittest) unittest { int[] replies; int closeAfter; @@ -771,7 +771,7 @@ b=7654321").asBytes)); } // Test form-data -version(ae_unittest) unittest +debug(ae_unittest) unittest { // Temporarily disabled due to DMD regression // https://issues.dlang.org/show_bug.cgi?id=24050 diff --git a/net/ietf/headerparse.d b/net/ietf/headerparse.d index f7de9ef9..f741a755 100644 --- a/net/ietf/headerparse.d +++ b/net/ietf/headerparse.d @@ -119,7 +119,7 @@ Headers parseHeadersImpl(bool FIRST_LINE)(string headerData, out string firstLin return headers; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { void test(string message) { diff --git a/net/ietf/headers.d b/net/ietf/headers.d index 6646f420..c4a23881 100644 --- a/net/ietf/headers.d +++ b/net/ietf/headers.d @@ -192,7 +192,7 @@ struct Headers } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { Headers headers; headers["test"] = "test"; @@ -253,7 +253,7 @@ string normalizeHeaderName(string header) pure return s; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(normalizeHeaderName("X-ORIGINATING-IP") == "X-Originating-IP"); } diff --git a/net/ietf/message.d b/net/ietf/message.d index 9aed650a..5ac6456d 100644 --- a/net/ietf/message.d +++ b/net/ietf/message.d @@ -567,7 +567,7 @@ class Rfc850Message } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto post = new Rfc850Message("From: msonke at example.org (=?ISO-8859-1?Q?S=F6nke_Martin?=)\n\nText"); assert(post.author == "Sönke Martin"); @@ -681,7 +681,7 @@ string encodeRfc1522Chunk(string str) pure return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto text = "В лесу родилась ёлочка"; assert(decodeRfc1522(encodeRfc1522(text)) == text); diff --git a/net/ietf/url.d b/net/ietf/url.d index bc204d6f..968fc54b 100644 --- a/net/ietf/url.d +++ b/net/ietf/url.d @@ -46,7 +46,7 @@ string applyRelativeURL(string base, string rel) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(applyRelativeURL("http://example.com/", "index.html") == "http://example.com/index.html"); assert(applyRelativeURL("http://example.com/index.html", "page.html") == "http://example.com/page.html"); @@ -66,7 +66,7 @@ string fileNameFromURL(string url) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(fileNameFromURL("http://example.com/index.html") == "index.html"); assert(fileNameFromURL("http://example.com/dir/index.html") == "index.html"); @@ -137,7 +137,7 @@ import std.ascii; /// except `'-'` and `'_'`. alias encodeUrlParameter = encodeUrlPart!(c => isAlphaNum(c) || c=='-' || c=='_'); -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(encodeUrlParameter("abc?123") == "abc%3F123"); } @@ -198,7 +198,7 @@ UrlParameters decodeUrlParameters(string qs) return dic; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(decodeUrlParameters("").length == 0); } diff --git a/net/ietf/wrap.d b/net/ietf/wrap.d index e2c069a8..adc95b1a 100644 --- a/net/ietf/wrap.d +++ b/net/ietf/wrap.d @@ -295,7 +295,7 @@ string wrapText(Paragraph[] paragraphs, int margin = DEFAULT_WRAP_LENGTH) return lines.join("\n"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { // Space-stuffing assert(wrapText(unwrapText(" Hello", WrapFormat.fixed)) == " Hello"); diff --git a/net/irc/common.d b/net/irc/common.d index e5f329c9..b6d70501 100644 --- a/net/irc/common.d +++ b/net/irc/common.d @@ -73,7 +73,7 @@ string rfc1459toUpper(string name) pure return name.byChar.map!rfc1459toUpper.array; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(rfc1459toLower("{}|[]\\") == "{}|{}|"); assert(rfc1459toUpper("{}|[]\\") == "[]\\[]\\"); @@ -85,7 +85,7 @@ int rfc1459cmp(in char[] a, in char[] b) return cmp(a.byChar.map!rfc1459toUpper, b.byChar.map!rfc1459toUpper); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(rfc1459cmp("{}|[]\\", "[]\\[]\\") == 0); assert(rfc1459cmp("a", "b") == -1); diff --git a/net/oauth/common.d b/net/oauth/common.d index 145297b3..bd9781af 100644 --- a/net/oauth/common.d +++ b/net/oauth/common.d @@ -115,7 +115,7 @@ struct OAuthSession return Base64.encode(digest); } - version(ae_unittest) unittest + debug(ae_unittest) unittest { // Example from https://dev.twitter.com/oauth/overview/creating-signatures diff --git a/net/ssl/openssl.d b/net/ssl/openssl.d index e05c1eae..548b633e 100644 --- a/net/ssl/openssl.d +++ b/net/ssl/openssl.d @@ -715,7 +715,7 @@ T sslEnforce(T)(T v, string message = null) // *************************************************************************** -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto p = new OpenSSLProvider; auto sc = p.createContext(SSLContext.Kind.server); @@ -751,5 +751,5 @@ version(ae_unittest) unittest assert(ok); } -version (ae_unittest) import ae.net.ssl.test; -version(ae_unittest) unittest { testSSL(new OpenSSLProvider); } +debug (ae_unittest) import ae.net.ssl.test; +debug(ae_unittest) unittest { testSSL(new OpenSSLProvider); } diff --git a/net/sync.d b/net/sync.d index 9c644754..6195c422 100644 --- a/net/sync.d +++ b/net/sync.d @@ -168,7 +168,7 @@ public: } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { // keep socketManager running - // ThreadAnchor sockets are daemon diff --git a/sys/btrfs/clone_range.d b/sys/btrfs/clone_range.d index a4b589e7..32123dfa 100644 --- a/sys/btrfs/clone_range.d +++ b/sys/btrfs/clone_range.d @@ -53,7 +53,7 @@ void cloneRange( errnoEnforce(ret >= 0, "ioctl(BTRFS_IOC_CLONE_RANGE)"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { if (!checkBtrfs()) return; diff --git a/sys/btrfs/common.d b/sys/btrfs/common.d index 8b6c48c6..44c92982 100644 --- a/sys/btrfs/common.d +++ b/sys/btrfs/common.d @@ -19,7 +19,7 @@ package: enum BTRFS_IOCTL_MAGIC = 0x94; -version (ae_unittest) +debug (ae_unittest) { import ae.sys.file; import std.stdio : stderr; diff --git a/sys/btrfs/extent_same.d b/sys/btrfs/extent_same.d index 091b6f5c..2b294ccf 100644 --- a/sys/btrfs/extent_same.d +++ b/sys/btrfs/extent_same.d @@ -120,7 +120,7 @@ SameExtentResult sameExtent(in Extent[] extents, ulong length) return result; } /// ditto -version(ae_unittest) unittest +debug(ae_unittest) unittest { if (!checkBtrfs()) return; diff --git a/sys/cmd.d b/sys/cmd.d index cb674190..ae9e16fb 100644 --- a/sys/cmd.d +++ b/sys/cmd.d @@ -205,7 +205,7 @@ if (!hasIndirections!T) return pipe(input, args, params); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { if (false) // Instantiation test { @@ -241,7 +241,7 @@ string iconv(const(void)[] data, string inputEncoding) } version (HAVE_UNIX) -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(iconv("Hello"w, "UTF-16LE") == "Hello"); } @@ -254,7 +254,7 @@ string sha1sum(const(void)[] data) } version (HAVE_UNIX) -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(sha1sum("") == "da39a3ee5e6b4b0d3255bfef95601890afd80709"); assert(sha1sum("a b\nc\r\nd") == "667c71ffe2ac8a4fe500e3b96435417e4c5ec13b"); @@ -302,7 +302,7 @@ string expandWindowsEnvVars(alias getenv = environment.get)(string s) return buf.data; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { std.process.environment[`FOOTEST`] = `bar`; assert("a%FOOTEST%b".expandWindowsEnvVars() == "abarb"); diff --git a/sys/d/cache.d b/sys/d/cache.d index 2df794fc..31663217 100644 --- a/sys/d/cache.d +++ b/sys/d/cache.d @@ -431,7 +431,7 @@ DCache createCache(string name, string cacheDir, ICacheHost cacheHost) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { void testEngine(string name) { diff --git a/sys/d/manager.d b/sys/d/manager.d index b082c6cd..2ed6fc13 100644 --- a/sys/d/manager.d +++ b/sys/d/manager.d @@ -798,7 +798,7 @@ EOF"); return str.replaceAll(re!`\\([^\\ ]*? [^\\]*)(?=\\)`, `\"$1"`); } - version(ae_unittest) unittest + debug(ae_unittest) unittest { assert(dDoTestEscape(`C:\Foo boo bar\baz quuz\derp.exe`) == `C:\"Foo boo bar"\"baz quuz"\derp.exe`); } diff --git a/sys/data.d b/sys/data.d index 8fd8cbab..0dd0aa1b 100644 --- a/sys/data.d +++ b/sys/data.d @@ -773,7 +773,7 @@ public: // } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import core.exception : AssertError; import core.memory : GC; @@ -1119,7 +1119,7 @@ version(ae_unittest) unittest // pure/@safe/nothrow/@nogc compilation test // No pure due to https://issues.dlang.org/show_bug.cgi?id=23959 -version(ae_unittest) /*pure*/ @safe nothrow @nogc unittest +debug(ae_unittest) /*pure*/ @safe nothrow @nogc unittest { TData!ubyte d; d.enter((scope contents) { ubyte[] _ = contents; }); @@ -1152,7 +1152,7 @@ version(ae_unittest) /*pure*/ @safe nothrow @nogc unittest }); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.format : format; assert(format!"%s"(TData!char("hello")) == "hello"); diff --git a/sys/dataset.d b/sys/dataset.d index eb5127d2..618de2dd 100644 --- a/sys/dataset.d +++ b/sys/dataset.d @@ -64,7 +64,7 @@ if (is(ElementType!R == TData!T, T)) return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(([TData!int([1]), TData!int([2])].joinData().unsafeContents) == [1, 2]); assert(cast(int[])([Data([1].asBytes), Data([2].asBytes)].joinData().unsafeContents) == [1, 2]); @@ -82,7 +82,7 @@ if (is(ElementType!R == TData!T, T)) return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(([TData!int([1]), TData!int([2])].joinToGC()) == [1, 2]); assert(cast(int[])([Data([1].asBytes), Data([2].asBytes)].joinToGC()) == [1, 2]); @@ -92,7 +92,7 @@ deprecated @property void[] joinToHeap(R)(auto ref R data) if (is(ElementType!R == Data)) { return data.joinToGC(); } -version(ae_unittest) deprecated unittest +debug(ae_unittest) deprecated unittest { assert(cast(int[])([Data([1].asBytes), Data([2].asBytes)].joinToHeap()) == [1, 2]); } @@ -179,7 +179,7 @@ struct DataSetBytes } /// } -version(ae_unittest) unittest +debug(ae_unittest) unittest { DataVec ds; string s; diff --git a/sys/file.d b/sys/file.d index 0fb6e27e..8355083b 100644 --- a/sys/file.d +++ b/sys/file.d @@ -964,7 +964,7 @@ public: private alias InlineStr = InlineArr!(char, 255); // ditto -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto tmpDir = deleteme ~ "-dir"; if (tmpDir.exists) tmpDir.removeRecurse(); @@ -1333,7 +1333,7 @@ alias collectNotFoundError = collectOSError!( ); /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto fn = deleteme; if (fn.exists) fn.removeRecurse(); @@ -1354,7 +1354,7 @@ alias collectFileExistsError = collectOSError!( ); /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto fn = deleteme; foreach (dg; [ @@ -1489,13 +1489,13 @@ void forceDelete(Flag!"atomic" atomic=Yes.atomic)(string fn, Flag!"recursive" re deprecated void forceDelete(bool atomic)(string fn, bool recursive = false) { forceDelete!(cast(Flag!"atomic")atomic)(fn, cast(Flag!"recursive")recursive); } //deprecated void forceDelete()(string fn, bool recursive) { forceDelete!(Yes.atomic)(fn, cast(Flag!"recursive")recursive); } -version(ae_unittest) deprecated unittest +debug(ae_unittest) deprecated unittest { mkdir("testdir"); touch("testdir/b"); forceDelete!(false )("testdir", true); mkdir("testdir"); touch("testdir/b"); forceDelete!(true )("testdir", true); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { mkdir("testdir"); touch("testdir/b"); forceDelete ("testdir", Yes.recursive); mkdir("testdir"); touch("testdir/b"); forceDelete!(No .atomic)("testdir", Yes.recursive); @@ -1614,7 +1614,7 @@ ulong getFileID()(string fn) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto base = deleteme; touch(base ~ "a"); @@ -1747,9 +1747,9 @@ version (Windows) else alias std.file.symlink dirLink; /// `std.file.symlink` is used to implement `dirLink` on POSIX. -version(Windows) version(ae_unittest) static mixin(importWin32!q{winnt}); +version(Windows) debug(ae_unittest) static mixin(importWin32!q{winnt}); -version(ae_unittest) unittest +debug(ae_unittest) unittest { // Wine's implementation of symlinks/junctions is incomplete version (Windows) @@ -1815,7 +1815,7 @@ version (Posix) alias deleteHardLink = remove; /// `std.file.remove` is used to implement `deleteHardLink` on POSIX. } -version(ae_unittest) unittest +debug(ae_unittest) unittest { write("a", "foo"); scope(exit) remove("a"); hardLink("a", "b"); @@ -1903,7 +1903,7 @@ version (linux) return result; } - version(ae_unittest) unittest + debug(ae_unittest) unittest { assert(unescapeMountString(`a\040b\040c`) == "a b c"); assert(unescapeMountString(`\040`) == " "); @@ -1935,7 +1935,7 @@ version (linux) ); } - version(ae_unittest) unittest + debug(ae_unittest) unittest { auto mi = parseMountInfo(`drvfs /mnt/c 9p rw,dirsync,noatime,aname=drvfs;path=C:\;uid=1000;gid=1000;symlinkroot=/mnt/,mmap,access=client,msize=262144,trans=virtio 0 0`); assert(mi == MountInfo("drvfs", "/mnt/c", "9p", `rw,dirsync,noatime,aname=drvfs;path=C:\;uid=1000;gid=1000;symlinkroot=/mnt/,mmap,access=client,msize=262144,trans=virtio`, 0, 0)); @@ -2096,7 +2096,7 @@ version (linux) } /// - version(ae_unittest) unittest + debug(ae_unittest) unittest { if (!xAttrs(".").supported) { @@ -2184,11 +2184,11 @@ uint hardLinkCount(string fn) } // https://issues.dlang.org/show_bug.cgi?id=7016 -version (ae_unittest) +debug (ae_unittest) version (Windows) import ae.sys.windows.misc : getWineVersion; -version(ae_unittest) unittest +debug(ae_unittest) unittest { // FindFirstFileNameW not implemented in Wine version (Windows) @@ -2298,7 +2298,7 @@ File openFile()(string fn, string mode = "rb") return f; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { enum Existence { any, mustExist, mustNotExist } enum Pos { none /* not readable/writable */, start, end, empty } @@ -2454,7 +2454,7 @@ void truncate(File f, ulong length) ftruncate(f.fileno, length.to!off_t); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { write("test.txt", "abcde"); auto f = File("test.txt", "r+b"); @@ -2499,7 +2499,7 @@ template mdFile() } version (HAVE_WIN32) -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.digest : toHexString; write("test.txt", "Hello, world!"); @@ -2526,7 +2526,7 @@ template mdFileCached() } version (HAVE_WIN32) -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.digest : toHexString; write("test.txt", "Hello, world!"); @@ -2545,7 +2545,7 @@ ubyte[] readFile(File f) return result.data; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto s = "0123456789".replicate(10_000); write("test.txt", s); @@ -2890,7 +2890,7 @@ auto atomicDg(size_t targetIndexA = size_t.max, Impl, Args...)(Impl impl, Args a deprecated alias safeUpdate = atomic; -version(ae_unittest) unittest +debug(ae_unittest) unittest { enum fn = "atomic.tmp"; scope(exit) if (fn.exists) fn.remove(); @@ -2945,7 +2945,7 @@ private void copy2(string source, string target) { std.file.copy(source, target) /// with another file's, atomically. alias atomic!copy2 atomicCopy; -version(ae_unittest) unittest +debug(ae_unittest) unittest { enum fn = "cached.tmp"; scope(exit) if (fn.exists) fn.remove(); diff --git a/sys/git.d b/sys/git.d index 40108941..e85abdd8 100644 --- a/sys/git.d +++ b/sys/git.d @@ -265,7 +265,7 @@ struct Git return buf[].idup; } - version(ae_unittest) unittest + debug(ae_unittest) unittest { OID oid; oid.sha1 = [0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67]; @@ -794,7 +794,7 @@ struct Git .chomp(".git"); } - version(ae_unittest) unittest + debug(ae_unittest) unittest { assert(repositoryNameFromURL("https://github.com/CyberShadow/ae.git") == "ae"); assert(repositoryNameFromURL("git@example.com:ae.git") == "ae"); @@ -810,7 +810,7 @@ deprecated Git.Authorship parseAuthorship(string authorship) { return Git.Author deprecated Git.CommitID toCommitHash(in char[] hash) { return Git.CommitID(Git.OID(hash)); } -version(ae_unittest) deprecated unittest +debug(ae_unittest) deprecated unittest { assert(toCommitHash("0123456789abcdef0123456789ABCDEF01234567").oid.sha1 == [0x01, 0x23, 0x45, 0x67, 0x89, 0xab, 0xcd, 0xef, 0x01, 0x23, 0x45, 0x67, 0x89, 0xAB, 0xCD, 0xEF, 0x01, 0x23, 0x45, 0x67]); } diff --git a/sys/inotify.d b/sys/inotify.d index 3a9e18e1..a9f91f86 100644 --- a/sys/inotify.d +++ b/sys/inotify.d @@ -154,7 +154,7 @@ private: INotify iNotify; /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.file, ae.sys.file; diff --git a/sys/log.d b/sys/log.d index 9a784468..ce4170ad 100644 --- a/sys/log.d +++ b/sys/log.d @@ -297,7 +297,7 @@ shared static this() Logger createLogger(string name) { Logger result; - version (ae_unittest) + debug (ae_unittest) result = consoleLogger(name); else { diff --git a/sys/memory.d b/sys/memory.d index ba6d98cb..8a59ee1a 100644 --- a/sys/memory.d +++ b/sys/memory.d @@ -58,7 +58,7 @@ bool onStack(const(void)* p) return p0 <= p && p <= p1; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { /* .......... */ int l; auto pl = &l; static /* ... */ int s; auto ps = &s; @@ -97,7 +97,7 @@ bool inCollect() @nogc return false; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(!inCollect()); diff --git a/sys/net/test.d b/sys/net/test.d index 32d3269f..dfbf3289 100644 --- a/sys/net/test.d +++ b/sys/net/test.d @@ -93,7 +93,7 @@ void test(string moduleName, string className)() } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { // Don't do network requests on the project tester. // See: diff --git a/sys/persistence/core.d b/sys/persistence/core.d index 26ff6fa4..d840346b 100644 --- a/sys/persistence/core.d +++ b/sys/persistence/core.d @@ -202,7 +202,7 @@ struct FileCache(alias DataGetter, alias DataPutter = None, FlushPolicy flushPol } // Sleep between writes to make sure timestamps differ -version(ae_unittest) import core.thread; +debug(ae_unittest) import core.thread; package version (Windows) @@ -220,7 +220,7 @@ else } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.file; static void[] readProxy(string fn) { return std.file.read(fn); } diff --git a/sys/persistence/json.d b/sys/persistence/json.d index a1d8c0b1..f7bed39d 100644 --- a/sys/persistence/json.d +++ b/sys/persistence/json.d @@ -37,7 +37,7 @@ template JsonFileCache(T, FlushPolicy flushPolicy = FlushPolicy.none) alias JsonFileCache = FileCache!(getJson!T, putJson!T, flushPolicy); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.file; @@ -49,7 +49,7 @@ version(ae_unittest) unittest assert(cache.length == 0); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.file; @@ -65,7 +65,7 @@ version(ae_unittest) unittest assert(cache2["foo"] == "bar"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.file; diff --git a/sys/persistence/keyvalue.d b/sys/persistence/keyvalue.d index 15c2a2ad..76617137 100644 --- a/sys/persistence/keyvalue.d +++ b/sys/persistence/keyvalue.d @@ -236,7 +236,7 @@ struct KeyValueDatabase alias _getSQLite this; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.file; @@ -284,7 +284,7 @@ version(ae_unittest) unittest assert(store.keys == ["key2"]); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { if (false) { @@ -293,7 +293,7 @@ version(ae_unittest) unittest } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { if (false) { @@ -302,7 +302,7 @@ version(ae_unittest) unittest } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { if (false) { @@ -314,7 +314,7 @@ version(ae_unittest) unittest } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.file; diff --git a/sys/persistence/mapped.d b/sys/persistence/mapped.d index 38ada312..6a9d0fcf 100644 --- a/sys/persistence/mapped.d +++ b/sys/persistence/mapped.d @@ -48,7 +48,7 @@ struct Mapped(T) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct S { diff --git a/sys/persistence/memoize.d b/sys/persistence/memoize.d index cc11756a..e769f775 100644 --- a/sys/persistence/memoize.d +++ b/sys/persistence/memoize.d @@ -47,7 +47,7 @@ struct PersistentMemoized(alias fun, FlushPolicy flushPolicy = FlushPolicy.atThr } /// } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.file : exists, remove; diff --git a/sys/persistence/stringset.d b/sys/persistence/stringset.d index 46da6994..f0324222 100644 --- a/sys/persistence/stringset.d +++ b/sys/persistence/stringset.d @@ -71,7 +71,7 @@ struct PersistentStringSet } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.file, std.conv, core.thread; diff --git a/sys/pidfile.d b/sys/pidfile.d index 4c63aded..be46f1fd 100644 --- a/sys/pidfile.d +++ b/sys/pidfile.d @@ -65,7 +65,7 @@ string defaultPidFilePath() return tempDir; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { createPidFile(); diff --git a/sys/process.d b/sys/process.d index 579de2a0..8e3fe2c8 100644 --- a/sys/process.d +++ b/sys/process.d @@ -75,9 +75,9 @@ void asyncWait(Pid pid, void delegate(int status) dg) addSignalHandler(SIGCHLD, &handler); } -version(ae_unittest) import ae.sys.timing, ae.net.asockets; +debug(ae_unittest) import ae.sys.timing, ae.net.asockets; -version(ae_unittest) unittest +debug(ae_unittest) unittest { string order; diff --git a/sys/sendinput.d b/sys/sendinput.d index 245494b4..781373cf 100644 --- a/sys/sendinput.d +++ b/sys/sendinput.d @@ -82,6 +82,19 @@ version (linux) enforce(spawnProcess(["xdotool", "mousemove", text(x), text(y)]).wait() == 0, "xdotool failed"); } + int[2] getMousePos() + { + // TODO static if (haveX11) + import ae.sys.cmd : query; + import std.algorithm.searching : skipOver; + auto s = query(["xdotool", "getmouselocation"]); + auto t = s.split(); + enforce(t.length == 4); + enforce(t[0].skipOver("x:")); + enforce(t[1].skipOver("y:")); + return [t[0].to!int, t[1].to!int]; + } + /// Type used for window IDs. static if (haveX11) alias Window = deimos.X11.X.Window; diff --git a/sys/sqlite3.d b/sys/sqlite3.d index 3c690e43..eacd0002 100644 --- a/sys/sqlite3.d +++ b/sys/sqlite3.d @@ -292,7 +292,7 @@ final class SQLite static assert(0, "Can't get column with type " ~ T.stringof); } - version(ae_unittest) unittest + debug(ae_unittest) unittest { PreparedStatement s; if (false) diff --git a/sys/timing.d b/sys/timing.d index 29d7937a..5ae90106 100644 --- a/sys/timing.d +++ b/sys/timing.d @@ -405,9 +405,9 @@ bool throttle(ref MonoTime last, Duration span) } // https://issues.dlang.org/show_bug.cgi?id=7016 -version(ae_unittest) static import ae.utils.array; +debug(ae_unittest) static import ae.utils.array; -version(ae_unittest) unittest +debug(ae_unittest) unittest { import core.thread : Thread; diff --git a/sys/vfs/curl.d b/sys/vfs/curl.d index 00ac90e4..008d5d6d 100644 --- a/sys/vfs/curl.d +++ b/sys/vfs/curl.d @@ -70,7 +70,7 @@ class CurlVFS : VFS } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { if (false) { diff --git a/sys/vfs/net.d b/sys/vfs/net.d index 3e11507e..a218ebdc 100644 --- a/sys/vfs/net.d +++ b/sys/vfs/net.d @@ -37,7 +37,7 @@ class NetVFS : VFS override void write(string path, const(void)[] data) { assert(false, "NetVFS is read-only"); } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { if (false) { diff --git a/sys/vfs/package.d b/sys/vfs/package.d index 29feba9e..f588f3c8 100644 --- a/sys/vfs/package.d +++ b/sys/vfs/package.d @@ -259,7 +259,7 @@ class FS : VFS } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { testVFS(""); } diff --git a/sys/windows/dll.d b/sys/windows/dll.d index 9796b6d9..fa1a7de4 100644 --- a/sys/windows/dll.d +++ b/sys/windows/dll.d @@ -63,10 +63,10 @@ mixin template DynamicLoadMulti(string DLL, FUNCS...) } } -version(ae_unittest) mixin(importWin32!q{winuser}); +debug(ae_unittest) mixin(importWin32!q{winuser}); /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { mixin DynamicLoad!(GetVersion, "kernel32.dll"); GetVersion(); // called via GetProcAddress diff --git a/ui/audio/source/memory.d b/ui/audio/source/memory.d index 4edc0053..6bf9a222 100644 --- a/ui/audio/source/memory.d +++ b/ui/audio/source/memory.d @@ -72,7 +72,7 @@ MemorySoundSource!Sample memorySoundSource(Sample)(Sample[] samples, uint sample return new MemorySoundSource!Sample(samples, sampleRate); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto w = memorySoundSource([short.max, short.min], 44100); } diff --git a/ui/audio/source/wave.d b/ui/audio/source/wave.d index 7eda00b5..302402c9 100644 --- a/ui/audio/source/wave.d +++ b/ui/audio/source/wave.d @@ -71,7 +71,7 @@ WaveSoundSource!Wave waveSoundSource(Wave)(Wave wave, uint sampleRate) return new WaveSoundSource!Wave(wave, sampleRate); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto w = waveSoundSource([short.max, short.min], 44100); } diff --git a/ui/video/bmfont.d b/ui/video/bmfont.d index a3dd3301..4bde5f33 100644 --- a/ui/video/bmfont.d +++ b/ui/video/bmfont.d @@ -62,7 +62,7 @@ protected: } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { // Test instantiation if (false) diff --git a/ui/video/software/common.d b/ui/video/software/common.d index 64892809..fd62632b 100644 --- a/ui/video/software/common.d +++ b/ui/video/software/common.d @@ -75,7 +75,7 @@ mixin template SoftwareRenderer() } /// } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.utils.graphics.color; import ae.utils.graphics.image; diff --git a/utils/aa.d b/utils/aa.d index 6131f1c8..22f8f513 100644 --- a/utils/aa.d +++ b/utils/aa.d @@ -32,7 +32,7 @@ ref V require(K, V)(ref V[K] aa, K key, lazy V value = V.init) return aa[key] = value; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { int[int] aa; aa.require(1, 2); @@ -137,7 +137,7 @@ ref V getOrAdd(K, V)(ref V[K] aa, auto ref K key) return getOrAdd(aa, key, V.init); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { int[int] aa; aa.getOrAdd(1, 2) = 3; @@ -157,7 +157,7 @@ bool addNew(K, V)(ref V[K] aa, auto ref K key, auto ref V value) return added; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { int[int] aa; assert( aa.addNew(1, 2)); @@ -165,7 +165,7 @@ version(ae_unittest) unittest assert(aa[1] == 2); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { OrderedMap!(int, int) aa; assert( aa.addNew(1, 2)); @@ -213,7 +213,7 @@ V[K] merge(K, V)(auto ref V[K] target, V[K] source) return target; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { int[int] target; int[int] source = [2:4]; @@ -227,7 +227,7 @@ version(ae_unittest) unittest assert(merge([1:1], [2:2]) == [1:1, 2:2]); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { ubyte[][string] a, b; merge(a, b); @@ -255,7 +255,7 @@ auto toAA(R)(R r) return r.map!(el => tuple(el.tupleof)).toAA(); } -version(ae_unittest) deprecated unittest +debug(ae_unittest) deprecated unittest { assert([[2, 4]].toAA() == [2:4]); assert([2:4].pairs.toAA() == [2:4]); @@ -272,7 +272,7 @@ V[K] nonNull(K, V)(V[K] aa) return aa; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { int[int] aa; assert(aa is null); @@ -1348,7 +1348,7 @@ public: /// An associative array which retains the order in which elements were added. alias OrderedMap(K, V) = HashCollection!(K, V, true, false); -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias M = OrderedMap!(string, int); M m; @@ -1409,7 +1409,7 @@ version(ae_unittest) unittest assert(v == -1); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { OrderedMap!(string, int) m; m["a"] = 1; @@ -1418,7 +1418,7 @@ version(ae_unittest) unittest assert(m["b"] == 2); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { OrderedMap!(string, int) m; m["a"] = 1; @@ -1428,7 +1428,7 @@ version(ae_unittest) unittest assert(m["a"] == 1); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { OrderedMap!(string, int) m; m["a"] = 1; @@ -1438,14 +1438,14 @@ version(ae_unittest) unittest assert(m2["a"] == 1); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { class C {} const OrderedMap!(string, C) m; cast(void)m.byKeyValue; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { OrderedMap!(int, int) m; m.update(10, @@ -1461,7 +1461,7 @@ version(ae_unittest) unittest } // https://issues.dlang.org/show_bug.cgi?id=18606 -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S { @@ -1475,27 +1475,27 @@ version(ae_unittest) unittest } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { OrderedMap!(string, int) m; static assert(is(typeof(m.keys))); static assert(is(typeof(m.values))); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { OrderedMap!(string, int) m; foreach (k, v; m) k = k ~ k; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S { @disable this(); } const OrderedMap!(string, S) m; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { class C {} OrderedMap!(string, C) m; @@ -1519,20 +1519,20 @@ if (is(typeof(input.front.key)) && is(typeof(input.front.value)) && !is(typeof(i return OrderedMap!(K, V)(input); } /// ditto -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto map = 3.iota.map!(n => tuple(n, n + 1)).orderedMap; assert(map.length == 3 && map[1] == 2); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { OrderedMap!(string, int) m; m = m.byKeyValue.orderedMap; m = m.byPair.orderedMap; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { OrderedMap!(string, int) m; const(char)[] s; @@ -1544,7 +1544,7 @@ version(ae_unittest) unittest /// Helper/wrapper for void[0][T] alias HashSet(T) = HashCollection!(T, void, false, false); -version(ae_unittest) unittest +debug(ae_unittest) unittest { HashSet!int s; assert(!s); @@ -1575,7 +1575,7 @@ version(ae_unittest) unittest assert(!t.remove(5)); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S { int[int] aa; } HashSet!S set; @@ -1591,28 +1591,28 @@ auto toSet(R)(R r) return HashSet!E(r); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto set = [1, 2, 3].toSet(); assert(2 in set); assert(4 !in set); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { HashSet!int m; const int i; m.remove(i); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { HashSet!Object m; Object o; m.remove(o); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S { @@ -1628,7 +1628,7 @@ version(ae_unittest) unittest /// the order in which elements are added. alias OrderedSet(T) = HashCollection!(T, void, true, false); -version(ae_unittest) unittest +debug(ae_unittest) unittest { OrderedSet!int set; @@ -1703,7 +1703,7 @@ auto orderedSet(R)(R r) /// through iteration alias MultiAA(K, V) = HashCollection!(K, V, false, true); -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias MASS = MultiAA!(string, int); MASS aa; @@ -1719,7 +1719,7 @@ version(ae_unittest) unittest aa["a"] = i; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { MultiAA!(int, int) m; int[][int] a; @@ -1785,7 +1785,7 @@ auto staticAA(alias aa)() return StaticMap(); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static immutable aa = staticAA!([ "foo" : 1, diff --git a/utils/aa_test.d b/utils/aa_test.d index 6637e419..39cd2de5 100644 --- a/utils/aa_test.d +++ b/utils/aa_test.d @@ -4,7 +4,7 @@ package(ae): import ae.utils.array; -version(ae_unittest) unittest +debug(ae_unittest) unittest { int[int] aa; aa.update(1, diff --git a/utils/alloc.d b/utils/alloc.d index 51cbb9bc..7ae54c3e 100644 --- a/utils/alloc.d +++ b/utils/alloc.d @@ -725,7 +725,7 @@ struct HybridBufferAllocator(size_t SIZE, BASE_TYPE=ubyte, alias ALLOCATOR=heapA } static if (haveFieldAliasBinding) -version(ae_unittest) unittest +debug(ae_unittest) unittest { static class C { int x=2; this() {} this(int p) { x = p; } } diff --git a/utils/appender.d b/utils/appender.d index 7df6607c..2451cc68 100644 --- a/utils/appender.d +++ b/utils/appender.d @@ -292,7 +292,7 @@ public: } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.meta : AliasSeq; import std.experimental.allocator.mallocator; diff --git a/utils/array.d b/utils/array.d index 11c3f14d..7a95d971 100644 --- a/utils/array.d +++ b/utils/array.d @@ -51,7 +51,7 @@ deprecated T[] toArray(T)(ref T v) { return v.asSlice; } return (&v)[0..1]; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { int[1] arr = 1.asUnitStaticArray; int i; @@ -74,7 +74,7 @@ template toStaticArray(size_t n) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto a = [1, 2, 3]; assert(a.toStaticArray!3 == [1, 2, 3]); @@ -103,7 +103,7 @@ version(ae_unittest) unittest deprecated @property inout(ubyte)[] bytes(T)(ref inout(T) value) if (!hasIndirections!T) { return value.asBytes; } deprecated @property inout(ubyte)[] bytes(T)(inout(T) value) if (is(T U : U[]) && !hasIndirections!U) { return value.asBytes; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { ubyte b = 5; assert(b.asBytes == [5]); @@ -139,7 +139,7 @@ inout(T) as(T)(inout(ubyte)[] bytes) deprecated ref inout(T) fromBytes(T)(inout(ubyte)[] bytes) if (!hasIndirections!T) { return bytes.as!T; } deprecated inout(T) fromBytes(T)(inout(ubyte)[] bytes) if (is(T U == U[]) && !hasIndirections!U) { return bytes.as!T; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { { ubyte b = 5; assert(b.asBytes.as!ubyte == 5); } { const ubyte b = 5; assert(b.asBytes.as!ubyte == 5); } @@ -147,7 +147,7 @@ version(ae_unittest) unittest { ubyte b = 5; assert(b.asBytes.as!S == S(5)); } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S { ubyte a, b; } ubyte[] arr = [1, 2]; @@ -170,7 +170,7 @@ version(ae_unittest) unittest return *cast(inout(ubyte)[T.sizeof]*)&value; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { ubyte[4] arr = 1.asStaticBytes; @@ -193,7 +193,7 @@ auto emptySlice(T)() pure @trusted return p[0..0]; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { int[] arr = emptySlice!int; assert(arr.ptr); @@ -213,7 +213,7 @@ bool isIdentical(T)(auto ref T a, auto ref T b) return a.asStaticBytes == b.asStaticBytes; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { float nan; assert(isIdentical(nan, nan)); @@ -300,7 +300,7 @@ ptrdiff_t indexOf(T)(in T[] arr, in T[] val) /// ditto return arr.countUntil(val); } /// ditto -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert("abc".indexOf('b') == 1); assert("abc".indexOf("b") == 1); @@ -330,7 +330,7 @@ ptrdiff_t lastIndexOf(T)(in T[] arr, in T[] val) /// ditto return -1; } /// ditto -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert("abc".lastIndexOf('b') == 1); assert("abc".lastIndexOf("b") == 1); @@ -368,7 +368,7 @@ if (is(Unqual!T == Unqual!U)) return str._indexOf(what) >= 0; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert( "abc".contains('b')); assert(!"abc".contains('x')); @@ -383,7 +383,7 @@ bool containsAt(T)(in T[] haystack, in T[] needle, size_t offset) && haystack[offset..offset+needle.length] == needle; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert( "abracadabra".containsAt("ada", 5)); assert(!"abracadabra".containsAt("ada", 6)); @@ -465,7 +465,7 @@ size_t elementIndex(T)(const(T)[] arr, ref const T element) @trusted return p - start; } -version(ae_unittest) @safe unittest +debug(ae_unittest) @safe unittest { auto arr = [1, 2, 3]; assert(arr.elementIndex(arr[1]) == 1); @@ -521,7 +521,7 @@ H[] splitWithSuffix(H, S)(H haystack, S separator) return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert("a\nb".splitWithSuffix('\n') == ["a\n", "b"]); assert([1, 0, 2].splitWithSuffix(0) == [[1, 0], [2]]); @@ -547,7 +547,7 @@ H[] splitWithPrefix(H, S)(H haystack, S separator) return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert("a\nb".splitWithPrefix('\n') == ["a", "\nb"]); assert([1, 0, 2].splitWithPrefix(0) == [[1], [0, 2]]); @@ -575,7 +575,7 @@ S[] splitWithPrefixAndSuffix(S)(S haystack, S prefix, S suffix) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto s = q"EOF Section 1: @@ -617,7 +617,7 @@ template mapNull(alias dg) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(string.init.mapNull!(s => s ) is null); assert(string.init.mapNull!(s => "" ) is null); @@ -632,7 +632,7 @@ auto ref sample(T)(T[] arr) return arr[uniform(0, $)]; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert([7, 7, 7].sample == 7); auto s = ["foo", "bar"].sample(); // Issue 13807 @@ -650,7 +650,7 @@ T pluck(T)(ref T[] arr) return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto arr = [1, 2, 3]; auto res = [arr.pluck, arr.pluck, arr.pluck]; @@ -674,7 +674,7 @@ bool removeFirst(T, alias eq = binaryFun!"a == b", SwapStrategy swapStrategy = S return false; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { int[] arr = [1, 2, 3, 2]; arr.removeFirst(2); @@ -690,7 +690,7 @@ size_t removeAll(T, alias eq = binaryFun!"a == b", SwapStrategy swapStrategy = S return oldLength - arr.length; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { int[] arr = [1, 2, 3, 2]; arr.removeAll(2); @@ -749,7 +749,7 @@ void countSort(alias orderPred = "a", T)(T[] arr) countSort!orderPred(arr, valuesBuf, countsBuf); } /// ditto -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto arr = [3, 2, 5, 2, 1]; arr.countSort(); @@ -804,7 +804,7 @@ T[N] shift(size_t N, T)(ref T[] arr) { T[N] result = cast(T[N])(arr[0..N]); arr void unshift(T)(ref T[] arr, T value) { arr.insertInPlace(0, value); } void unshift(T)(ref T[] arr, T[] value) { arr.insertInPlace(0, value); } /// ditto -version(ae_unittest) unittest +debug(ae_unittest) unittest { int[] arr = [1, 2, 3]; assert(arr.shift == 1); @@ -922,7 +922,7 @@ template skipWhile(alias pred) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.ascii : isDigit; @@ -949,7 +949,7 @@ template eatUntil(OnEof onEof = OnEof.throwException) } } -version(ae_unittest) deprecated unittest +debug(ae_unittest) deprecated unittest { string s; @@ -1003,14 +1003,14 @@ template afilter(alias pred) { auto afilter(T)(T[] arr) { return array(filter!pr auto auniq(T)(T[] arr) { return array(uniq(arr)); } /// ditto auto asort(alias pred, T)(T[] arr) { sort!pred(arr); return arr; } /// ditto -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert([1, 2, 3].amap!`a*2`() == [2, 4, 6]); assert([1, 2, 3].amap!(n => n*n)() == [1, 4, 9]); assert([1, 2, 3].staticArray.amap!(n => n*n)() == [1, 4, 9].staticArray); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct NC { @@ -1024,7 +1024,7 @@ version(ae_unittest) unittest assert(3.iota.amap!(i => NC(i))[1].i == 1); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.range : iota; immutable(int)[] arr; @@ -1093,7 +1093,7 @@ auto list(Args...)(auto ref Args args) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { string name, value; list(name, null, value) = "NAME=VALUE".findSplit("="); @@ -1101,7 +1101,7 @@ version(ae_unittest) unittest } version(LittleEndian) -version(ae_unittest) unittest +debug(ae_unittest) unittest { uint onlyValue; ubyte[] data = [ubyte(42), 0, 0, 0]; diff --git a/utils/bitmanip.d b/utils/bitmanip.d index 32838c5c..af8fedba 100644 --- a/utils/bitmanip.d +++ b/utils/bitmanip.d @@ -42,7 +42,7 @@ struct LittleEndian(T) alias NetworkByteOrder = BigEndian; /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { union U { @@ -63,13 +63,13 @@ version(ae_unittest) unittest assert(u.le == 0x7856); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { enum E : uint { e } BigEndian!E be; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { const e = BigEndian!int(1); assert(e == 1); @@ -193,7 +193,7 @@ if (is(E == enum)) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.algorithm.comparison : equal; diff --git a/utils/container/hashtable.d b/utils/container/hashtable.d index 99b8c92a..7e16d772 100644 --- a/utils/container/hashtable.d +++ b/utils/container/hashtable.d @@ -159,7 +159,7 @@ struct HashTable(K, V, uint SIZE, alias ALLOCATOR, alias HASHFUNC="k") } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.utils.alloc; diff --git a/utils/container/list.d b/utils/container/list.d index 2acfa901..ad4c8d90 100644 --- a/utils/container/list.d +++ b/utils/container/list.d @@ -90,7 +90,7 @@ template SEDList(T) alias List!(T, true, false) SEDList; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { DList!int l; auto i1 = l.pushBack(1); diff --git a/utils/container/listnode.d b/utils/container/listnode.d index 4480567c..e82f30bc 100644 --- a/utils/container/listnode.d +++ b/utils/container/listnode.d @@ -223,7 +223,7 @@ template SEDListContainer(T) alias ListContainer!(T, true, false) SEDListContainer; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { class C { diff --git a/utils/container/set.d b/utils/container/set.d index a6d4efb4..5abced3d 100644 --- a/utils/container/set.d +++ b/utils/container/set.d @@ -39,7 +39,7 @@ struct Set(T, uint INITSIZE=64) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { Set!int s; s ~= 1; diff --git a/utils/digest.d b/utils/digest.d index f476dc40..3555be36 100644 --- a/utils/digest.d +++ b/utils/digest.d @@ -229,7 +229,7 @@ deprecated ("Use std.digest.murmurhash") return format("%08X%08X%08X%08X", digest[0], digest[1], digest[2], digest[3]); } - version(ae_unittest) unittest + debug(ae_unittest) unittest { assert(murmurHash3_32("The quick brown fox jumps over the lazy dog") == 0x2e4ff723); assert(murmurHash3_32("The quick brown fox jumps over the lazy cog") == 0xf08200fc); @@ -288,7 +288,7 @@ template getDigestString(Digest) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(getDigestString!MD5("abc") == "900150983CD24FB0D6963F7D28E17F72"); } @@ -339,7 +339,7 @@ deprecated("Use std.digest.hmac") auto HMAC_SHA1 ()(in ubyte[] key, in ubyte[] message) { import std.digest.sha; return HMAC!(SHA1 , 64)(key, message); } auto HMAC_SHA256 ()(in ubyte[] key, in ubyte[] message) { import std.digest.sha; return HMAC!(SHA256, 64)(key, message); } - version(ae_unittest) unittest + debug(ae_unittest) unittest { import std.string : representation; import std.conv : hexString; diff --git a/utils/exception.d b/utils/exception.d index 3b573113..d3eb9d40 100644 --- a/utils/exception.d +++ b/utils/exception.d @@ -52,7 +52,7 @@ mixin template DeclareException(string NAME, BASE = Exception) })); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { mixin DeclareException!q{OutOfCheeseException}; try @@ -95,7 +95,7 @@ string exceptionContext(string messageExpr, string name = text(__LINE__)) }); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { try { @@ -143,7 +143,7 @@ template assertOp(string op) } alias assertEqual = assertOp!"=="; /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { assertThrown!AssertError(assertEqual(1, 2)); } diff --git a/utils/functor/algorithm.d b/utils/functor/algorithm.d index c098818a..b5c14cfa 100644 --- a/utils/functor/algorithm.d +++ b/utils/functor/algorithm.d @@ -41,7 +41,7 @@ private: } /// -version(ae_unittest) @nogc unittest +debug(ae_unittest) @nogc unittest { import std.algorithm.comparison : equal; import std.range : iota, only; diff --git a/utils/functor/composition.d b/utils/functor/composition.d index bd63792b..9fb46967 100644 --- a/utils/functor/composition.d +++ b/utils/functor/composition.d @@ -26,7 +26,7 @@ enum isFunctor(f...) = f.length == 1 && ( isCallable!f || __traits(hasMember, f, "opCall") ); -version(ae_unittest) unittest +debug(ae_unittest) unittest { static assert(isFunctor!(typeof(() => 5))); int i; @@ -57,7 +57,7 @@ if (isFunctor!T && isFunctor!F) { return select(cond.valueFunctor, t, f); } /// ditto /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(select(true , 5.valueFunctor, 7.valueFunctor)() == 5); assert(select(false, 5.valueFunctor, 7.valueFunctor)() == 7); @@ -82,7 +82,7 @@ if (allSatisfy!(isFunctor, Functors)) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto addFive = functor!(p => *p += 5)(); auto addThree = functor!(p => *p += 3)(); diff --git a/utils/functor/primitives.d b/utils/functor/primitives.d index 74277248..cdd1b401 100644 --- a/utils/functor/primitives.d +++ b/utils/functor/primitives.d @@ -76,7 +76,7 @@ template functor(alias fun, State...) } /// -version(ae_unittest) @safe pure @nogc nothrow unittest +debug(ae_unittest) @safe pure @nogc nothrow unittest { auto getFive = functor!(() => 5)(); assert(getFive() == 5); @@ -96,7 +96,7 @@ version(ae_unittest) @safe pure @nogc nothrow unittest } /// -version(ae_unittest) @safe pure nothrow unittest +debug(ae_unittest) @safe pure nothrow unittest { // Regular D closures are still supported. Not @nogc! @@ -109,7 +109,7 @@ version(ae_unittest) @safe pure nothrow unittest assert(addMul(5) == 17); } -version(ae_unittest) @safe pure @nogc nothrow unittest +debug(ae_unittest) @safe pure @nogc nothrow unittest { struct NC { @@ -127,7 +127,7 @@ version(ae_unittest) @safe pure @nogc nothrow unittest }); } -version(ae_unittest) @safe pure @nogc nothrow unittest +debug(ae_unittest) @safe pure @nogc nothrow unittest { immutable int i = 2; auto f = functor!((a, b) => a + b)(i); @@ -143,7 +143,7 @@ auto valueFunctor(alias value)() { return .functor!(() => value)(); } auto valueFunctor(Value)(Value value) { return functor!(v => v)(value); } /// -version(ae_unittest) @safe pure @nogc nothrow unittest +debug(ae_unittest) @safe pure @nogc nothrow unittest { assert(valueFunctor(5)() == 5); assert(valueFunctor!5()() == 5); diff --git a/utils/funopt.d b/utils/funopt.d index fe15235f..9bb84250 100644 --- a/utils/funopt.d +++ b/utils/funopt.d @@ -317,7 +317,7 @@ if (isCallable!FUN) return FUN(values); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { void f1(bool verbose, Option!int tries, string filename) { @@ -519,7 +519,7 @@ string optionWrap(string text, string firstIndent, size_t indentWidth) return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { void f1( Switch!("Enable verbose logging", 'v') verbose, @@ -796,7 +796,7 @@ string generateManPage(alias FUN)( return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { @(`Frobnicates whatsits.`) void f1( @@ -909,7 +909,7 @@ string funoptDispatchUsage(alias Actions)() return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { @(`Test program.`) struct Actions diff --git a/utils/geometry.d b/utils/geometry.d index 332481d8..4f28d69c 100644 --- a/utils/geometry.d +++ b/utils/geometry.d @@ -72,7 +72,7 @@ struct Rect(T) } auto rect(T...)(T args) { return Rect!(CommonType!T)(args); } /// ditto -version(ae_unittest) unittest +debug(ae_unittest) unittest { Rect!int rint; } diff --git a/utils/graphics/color.d b/utils/graphics/color.d index 558bdd9b..d18a7b39 100644 --- a/utils/graphics/color.d +++ b/utils/graphics/color.d @@ -327,7 +327,7 @@ version(all) alias Color!(double , "r", "g", "b" ) RGBd ; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static assert(RGB.sizeof == 3); RGB[2] arr; @@ -351,7 +351,7 @@ version(ae_unittest) unittest static assert(RGB.min == RGB( 0, 0, 0)); static assert(RGB.max == RGB(255, 255, 255)); -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.conv; @@ -361,7 +361,7 @@ version(ae_unittest) unittest assert(r == L8(150), text(r)); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.conv; @@ -380,7 +380,7 @@ version(ae_unittest) unittest assert(r == LA(100, 255), text(r)); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.conv; @@ -399,12 +399,12 @@ version(ae_unittest) unittest assert(r == L8(100), text(r)); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { Color!(real, "r", "g", "b") c; } -version(ae_unittest) deprecated unittest +debug(ae_unittest) deprecated unittest { const RGB c; RGB x = cast(RGB)c; @@ -478,7 +478,7 @@ alias ExpandChannelTypeSigned(COLOR, int BYTES) = static assert(is(ExpandChannelType!(RGB, 1) == RGB16)); -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias RGBf = ChangeChannelType!(RGB, float); auto rgb = RGB(1, 2, 3); @@ -540,7 +540,7 @@ if (!is(expr == struct)) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { // Effortlessly reordering channels with no modification. assert(RGB(1, 2, 3).channelMap!BGR == BGR(3, 2, 1)); @@ -658,7 +658,7 @@ struct Gradient(Value, Color) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { Gradient!(int, L8) grad; grad.points = [ @@ -673,7 +673,7 @@ version(ae_unittest) unittest assert(grad.get(15) == L8(100)); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { Gradient!(float, L8) grad; grad.points = [ diff --git a/utils/graphics/draw.d b/utils/graphics/draw.d index 91b0878d..2438c6b0 100644 --- a/utils/graphics/draw.d +++ b/utils/graphics/draw.d @@ -22,7 +22,7 @@ import ae.utils.graphics.color : solidStorageUnit; import ae.utils.math; import ae.utils.meta : structFields, SignedBitsType, UnsignedBitsType; -version(ae_unittest) import ae.utils.graphics.image; +debug(ae_unittest) import ae.utils.graphics.image; // Constraints could be simpler if this was fixed: // https://issues.dlang.org/show_bug.cgi?id=12386 @@ -39,7 +39,7 @@ COLOR safeGet(V, COLOR)(auto ref V v, xy_t x, xy_t y, COLOR def) return def; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto v = onePixel(7); assert(v.safeGet(0, 0, 0) == 7); @@ -55,7 +55,7 @@ void safePut(V, COLOR)(auto ref V v, xy_t x, xy_t y, COLOR value) v[x, y] = value; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto v = Image!int(1, 1); v.safePut(0, 0, 7); @@ -75,7 +75,7 @@ void putPixel(bool CHECKED, V, COLOR)(auto ref V v, xy_t x, xy_t y, COLOR value) v[x, y] = value; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto v = Image!int(1, 1); v.putPixel!false(0, 0, 7); @@ -90,7 +90,7 @@ if (isDirectView!V && is(typeof(&v.scanline(0)[0][0]))) return &v.scanline(y)[x][0]; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto v = Image!xy_t(1, 1); v[0, 0] = 7; @@ -118,7 +118,7 @@ void fill(V, COLOR)(auto ref V v, COLOR c) } deprecated alias clear = fill; -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto i = onePixel(0).copy(); i.fill(1); @@ -735,7 +735,7 @@ void aaLine(bool CHECKED=true, V, COLOR, frac)(auto ref V v, float x1, float y1, v.aaPutPixel!CHECKED(itpl(x1, x2, y, y1, y2), y, color, alpha); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { // Test instantiation import ae.utils.graphics.color; diff --git a/utils/graphics/fonts/draw.d b/utils/graphics/fonts/draw.d index 76a4502a..ab0f92ae 100644 --- a/utils/graphics/fonts/draw.d +++ b/utils/graphics/fonts/draw.d @@ -43,13 +43,13 @@ void drawText(V, FONT, S, COLOR)(auto ref V v, xy_t x, xy_t y, S s, ref FONT fon } } -version(ae_unittest) +debug(ae_unittest) { import ae.utils.graphics.image; import ae.utils.graphics.fonts.font8x8; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto v = Image!ubyte(100, 8); v.drawText(0, 0, "Hello World!", font8x8, ubyte(255)); diff --git a/utils/graphics/gamma.d b/utils/graphics/gamma.d index 61d82d78..501527e5 100644 --- a/utils/graphics/gamma.d +++ b/utils/graphics/gamma.d @@ -125,7 +125,7 @@ ref auto gammaRamp(LUM_BASETYPE, PIX_BASETYPE, alias value)() return S.ramp; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { // test instantiation auto lum = onePixel(RGB16(1, 2, 3)); diff --git a/utils/graphics/gdi.d b/utils/graphics/gdi.d index 1d34b7c2..2e6ae608 100644 --- a/utils/graphics/gdi.d +++ b/utils/graphics/gdi.d @@ -109,7 +109,7 @@ struct GDICanvas(COLOR) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias RGB = ae.utils.graphics.color.RGB; @@ -139,7 +139,7 @@ version(ae_unittest) unittest // i.savePNM("gditest.pnm"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto b = GDICanvas!bool(100, 100); b.fill(true); diff --git a/utils/graphics/hls.d b/utils/graphics/hls.d index 2f2881a4..6e8ab174 100644 --- a/utils/graphics/hls.d +++ b/utils/graphics/hls.d @@ -119,7 +119,7 @@ static: } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.utils.graphics.color; HLS!RGB hls; @@ -130,7 +130,7 @@ version(ae_unittest) unittest assert(h==0 && l==120 && s==240); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.utils.graphics.color; enum MAX = 30_000; diff --git a/utils/graphics/im_convert.d b/utils/graphics/im_convert.d index ed70e875..b412a30a 100644 --- a/utils/graphics/im_convert.d +++ b/utils/graphics/im_convert.d @@ -54,7 +54,7 @@ auto parseViaIMConvert(C = TargetColor, TARGET)(const(void)[] data, auto ref TAR return data.parseViaIMConvert!(ViewColor!TARGET)(transformations).copy(target); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { if (false) { @@ -77,7 +77,7 @@ auto encodeViaIMConvert(SRC)(auto ref SRC src, string format, string[] transform .pipe(["convert".imageMagickBinary()] ~ convertFlags ~ ["-[0]"] ~ transformations ~ [format ~ ":-"]); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { if (false) { @@ -209,7 +209,7 @@ deprecated alias VideoStream = DecodeStream; DecodeStream!COLOR streamViaIMConvert(COLOR)(File f) { return DecodeStream!COLOR(f); } DecodeStream!COLOR streamViaIMConvert(COLOR)(string fn) { return DecodeStream!COLOR(fn); } /// ditto -version(ae_unittest) unittest +debug(ae_unittest) unittest { if (false) { diff --git a/utils/graphics/image.d b/utils/graphics/image.d index b2d3bc7a..35851d6d 100644 --- a/utils/graphics/image.d +++ b/utils/graphics/image.d @@ -45,7 +45,7 @@ struct ImageRef(COLOR, StorageType = PlainStorageUnit!COLOR) mixin DirectView; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static assert(isDirectView!(ImageRef!ubyte)); } @@ -60,7 +60,7 @@ ImageRef!(ViewColor!SRC) toRef(SRC)(auto ref SRC src) src.scanline(0).ptr); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto i = Image!ubyte(1, 1); auto r = i.toRef(); @@ -116,7 +116,7 @@ struct Image(COLOR, StorageType = PlainStorageUnit!COLOR) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static assert(isDirectView!(Image!ubyte)); } @@ -151,7 +151,7 @@ auto copy(SRC)(auto ref SRC src) return src.copy(target); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto v = onePixel(0); auto i = v.copy(); @@ -211,7 +211,7 @@ auto vjoin(R)(R images) return images.vjoin(target); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto h = 10 .iota @@ -314,7 +314,7 @@ template downscale(int HRX, int HRY=HRX) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { onePixel(RGB.init).nearestNeighbor(4, 4).copy.downscale!(2, 2)(); // onePixel(RGBA.init).nearestNeighbor(4, 4).copy.downscale!(2, 2)(); @@ -392,7 +392,7 @@ if (isView!SRC) return src.downscaleTo(target); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { onePixel(RGB.init).nearestNeighbor(4, 4).copy.downscaleTo(2, 2); // onePixel(RGBA.init).nearestNeighbor(4, 4).copy.downscaleTo(2, 2); @@ -527,7 +527,7 @@ auto parsePBM(COLOR)(const(void)[] vdata) return vdata.parsePBM(target); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.conv : hexString; auto data = "P6\n2\n2\n255\n" ~ @@ -538,7 +538,7 @@ version(ae_unittest) unittest assert(i[0, 1] == RGB.fromHex("000FFF")); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.conv : hexString; auto data = "P5\n2\n2\n255\n" ~ @@ -571,7 +571,7 @@ ubyte[] toPBM(SRC)(auto ref SRC src) return data; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.conv : hexString; assert(onePixel(RGB(1,2,3)).toPBM == "P6\n1 1 255\n" ~ hexString!"01 02 03"); @@ -603,7 +603,7 @@ auto fromPixels(C = InputColor, INPUT)(INPUT[] input, xy_t w, xy_t h) return fromPixels!COLOR(input, w, h, target); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.conv : hexString; Image!L8 i; @@ -778,7 +778,7 @@ auto parseBMP(COLOR)(const(void)[] data) return data.parseBMP(target); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias parseBMP!BGR parseBMP24; if (false) @@ -840,7 +840,7 @@ ubyte[] toBMP(SRC)(auto ref SRC src) return data; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { Image!BGR output; onePixel(BGR(1,2,3)).toBMP().parseBMP!BGR(output); @@ -999,7 +999,7 @@ ubyte[] makePNG(PNGChunk[] chunks) return data; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { onePixel(RGB(1,2,3)).toPNG(); onePixel(5).toPNG(); diff --git a/utils/graphics/libpng.d b/utils/graphics/libpng.d index fa9a107f..170bb886 100644 --- a/utils/graphics/libpng.d +++ b/utils/graphics/libpng.d @@ -357,7 +357,7 @@ Image!COLOR decodePNG(COLOR)(ubyte[] data, bool strict = true) return img; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct BitWriter { diff --git a/utils/graphics/view.d b/utils/graphics/view.d index 9e481ee3..a3c4a826 100644 --- a/utils/graphics/view.d +++ b/utils/graphics/view.d @@ -131,7 +131,7 @@ auto onePixel(COLOR)(COLOR c) return solid(c, 1, 1); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(onePixel(42)[0, 0] == 42); } @@ -256,7 +256,7 @@ auto crop(V)(auto ref V src, xy_t x0, xy_t y0, xy_t x1, xy_t y1) return Crop(src, x0, y0, x1, y1); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto g = procedural!((x, y) => y)(1, 256); auto c = g.crop(0, 10, 1, 20); @@ -284,7 +284,7 @@ auto tile(V)(auto ref V src, xy_t w, xy_t h) return Tile(src, w, h); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto i = onePixel(4); auto t = i.tile(100, 100); @@ -311,7 +311,7 @@ auto nearestNeighbor(V)(auto ref V src, xy_t w, xy_t h) return NearestNeighbor(src, w, h); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto g = procedural!((x, y) => x+10*y)(10, 10); auto n = g.nearestNeighbor(100, 100); @@ -411,7 +411,7 @@ alias vflip = warp!(q{x}, q{h-y-1}); /// Return a view of src with both coordinates inverted. alias flip = warp!(q{w-x-1}, q{h-y-1}); -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.utils.graphics.image; auto vband = procedural!((x, y) => y)(1, 256).copy(); @@ -435,7 +435,7 @@ auto rotateCCW(V)(auto ref V src) return src.flipXY().vflip(); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto g = procedural!((x, y) => x+10*y)(10, 10); xy_t[] corners(V)(V v) { return [v[0, 0], v[9, 0], v[0, 9], v[9, 9]]; } @@ -505,7 +505,7 @@ auto vjoiner(V)(V[] views) return VJoiner(views); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.algorithm : map; import std.array : array; @@ -570,7 +570,7 @@ auto border(V, COLOR)(auto ref V src, xy_t x0, xy_t y0, xy_t x1, xy_t y1, COLOR .overlay(src, x0, y0); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto g = procedural!((x, y) => cast(int)(x+10*y))(10, 10); auto b = g.border(5, 5, 5, 5, 42); @@ -615,7 +615,7 @@ auto blend(SRCS...)(SRCS sources) return Blend(sources); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.utils.graphics.color : LA; auto v0 = onePixel(LA( 0, 255)); @@ -690,9 +690,9 @@ auto rotate(V, COLOR)(auto ref V src, double angle, } // https://issues.dlang.org/show_bug.cgi?id=7016 -version(ae_unittest) static import ae.utils.geometry; +debug(ae_unittest) static import ae.utils.geometry; -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.utils.graphics.image; import ae.utils.geometry; @@ -768,7 +768,7 @@ template colorMap(alias getFun, alias setFun) // TODO: skip alpha and padding alias invert = colorMap!(c => ~c, c => ~c); -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.utils.graphics.color; import ae.utils.graphics.image; @@ -777,7 +777,7 @@ version(ae_unittest) unittest assert(i.invert[0, 0].l == 254); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { // Mutable colorMap with just getFun import ae.utils.graphics.image : Image; @@ -877,7 +877,7 @@ template parallel(alias fun) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.utils.graphics.image; auto g = procedural!((x, y) => x+10*y)(10, 10); diff --git a/utils/gzip.d b/utils/gzip.d index 9941fbf7..e915a936 100644 --- a/utils/gzip.d +++ b/utils/gzip.d @@ -53,7 +53,7 @@ if (is(ElementType!R : const(Data))) return *cast(uint*)result.ptr; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(crc32([Data("ab".asBytes), Data("c".asBytes)]) == 0x352441C2); } @@ -124,7 +124,7 @@ DataVec uncompress(scope Data[] data) Data uncompress(Data input) { return uncompress(input.asSlice).joinData(); } /// ditto -version(ae_unittest) unittest +debug(ae_unittest) unittest { void testRoundtrip(ubyte[] src) { diff --git a/utils/iconv.d b/utils/iconv.d index 94867cc4..4460020b 100644 --- a/utils/iconv.d +++ b/utils/iconv.d @@ -130,7 +130,7 @@ shared static this() codepages["ascii8"] = "€‚ƒ„…†‡ˆ‰Š‹ŒŽ‘’“”•–—˜™š›œžŸ ¡¢£¤¥¦§¨©ª«¬­®¯°±²³´µ¶·¸¹º»¼½¾¿ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûüýþÿ"w; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { foreach (name, chars; codepages) assert(chars.length == 128); diff --git a/utils/json.d b/utils/json.d index 87dc3cd8..e73a85a4 100644 --- a/utils/json.d +++ b/utils/json.d @@ -389,7 +389,7 @@ string toJson(T)(auto ref T v) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct X { int a; string b; } X x = {17, "aoeu"}; @@ -403,7 +403,7 @@ version(ae_unittest) unittest assert(toJson(tuple(42, "banana")) == `[42,"banana"]`); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct A { @@ -431,7 +431,7 @@ string toPrettyJson(T)(T v) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct X { int a; string b; int[] c, d; } X x = {17, "aoeu", [1, 2, 3]}; @@ -990,7 +990,7 @@ T jsonParse(T, C)(C[] s) return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S { int i; S[] arr; S* p0, p1; } S s = S(42, [S(1), S(2)], null, new S(15)); @@ -1006,7 +1006,7 @@ version(ae_unittest) unittest assert(jsonParse!(string[string])(`null`) is null); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct T { string s; wstring w; dstring d; } T t; @@ -1026,13 +1026,13 @@ version(ae_unittest) unittest jsonParse!T(s.to!dstring); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { jsonParse!(int[2])(`[ 1 , 2 ]`); } // NaNs and infinities are serialized as strings. -version(ae_unittest) unittest +debug(ae_unittest) unittest { void check(double f, string s) { @@ -1052,7 +1052,7 @@ void jsonParse(T, C)(C[] s, ref T result) parser.read!T(result); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S { int a, b; } S s; @@ -1093,13 +1093,13 @@ private template doSkipSerialize(T, string member) enum bool doSkipSerialize = __traits(hasMember, T, member ~ "_nonSerialized"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct Point { int x, y, z; mixin NonSerialized!(x, z); } assert(jsonParse!Point(toJson(Point(1, 2, 3))) == Point(0, 2, 0)); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { enum En { one, two } assert(En.one.toJson() == `"one"`); @@ -1114,7 +1114,7 @@ version(ae_unittest) unittest assert(s.en == En.two); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias B = Nullable!bool; B b; @@ -1138,13 +1138,13 @@ version(ae_unittest) unittest assert(NS.init.toJson == "null"); } -version(ae_unittest) unittest // Issue 49 +debug(ae_unittest) unittest // Issue 49 { immutable bool b; assert(toJson(b) == "false"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.utils.aa : OrderedMap; alias M = OrderedMap!(string, int); @@ -1156,38 +1156,38 @@ version(ae_unittest) unittest assert(j.jsonParse!M == m); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(string.init.toJson.jsonParse!string is null); assert("" .toJson.jsonParse!string !is null); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { char[] s = "{}".dup; assert(s.jsonParse!(string[string]) == null); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { typeof(null) n; assert(n.toJson.jsonParse!(typeof(null)) is null); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { double f = 1.5; assert(f.toJson() == "1.5"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { dchar c = '😸'; assert(c.toJson() == `"😸"`); } /// `fromJSON` / `toJSON` can be added to a type to control their serialized representation. -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct S { @@ -1200,7 +1200,7 @@ version(ae_unittest) unittest assert(s.toJson.jsonParse!S == s); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct S { @@ -1216,7 +1216,7 @@ version(ae_unittest) unittest /// `fromJSON` / `toJSON` can also accept/return a `JSONFragment`, /// which allows full control over JSON serialization. -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct BigInt { @@ -1248,20 +1248,20 @@ private template getJsonName(S, string FIELD) /// User-defined attribute - only serialize this field if its value is different from its .init value. struct JSONOptional {} -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct S { @JSONOptional bool a=true, b=false; } assert(S().toJson == `{}`, S().toJson); assert(S(false, true).toJson == `{"a":false,"b":true}`); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct S { @JSONOptional float f; } assert(S().toJson == `{}`, S().toJson); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct S { @JSONOptional int[1] a; } assert(S().toJson == `{}`, S().toJson); @@ -1272,7 +1272,7 @@ version(ae_unittest) unittest /// User-defined attribute - skip unknown fields when deserializing. struct JSONPartial {} -version(ae_unittest) unittest +debug(ae_unittest) unittest { @JSONPartial static struct S { int b; } assert(`{"a":1,"b":2,"c":3.4,"d":[5,"x"],"de":[],"e":{"k":"v"},"ee":{},"f":true,"g":false,"h":null}`.jsonParse!S == S(2)); @@ -1291,7 +1291,7 @@ struct JSONFragment bool opCast(T)() const if (is(T==bool)) { return !!json; } /// } -version(ae_unittest) unittest +debug(ae_unittest) unittest { JSONFragment[] arr = [JSONFragment(`1`), JSONFragment(`true`), JSONFragment(`"foo"`), JSONFragment(`[55]`)]; assert(arr.toJson == `[1,true,"foo",[55]]`); diff --git a/utils/mapset/mapset.d b/utils/mapset/mapset.d index 425689da..75aafab0 100644 --- a/utils/mapset/mapset.d +++ b/utils/mapset/mapset.d @@ -1016,7 +1016,7 @@ struct MapSet(DimName, DimValue, DimValue nullValue = DimValue.init) } /// } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.algorithm.sorting : sort; diff --git a/utils/mapset/vars.d b/utils/mapset/vars.d index 66c273db..acc88f6f 100644 --- a/utils/mapset/vars.d +++ b/utils/mapset/vars.d @@ -329,7 +329,7 @@ struct MapSetVars( /// An example. /// Note that, unlike the similar Visitor test case, this iterates only once, /// thanks to the opBinary support. -version(ae_unittest) unittest +debug(ae_unittest) unittest { // Setup @@ -364,7 +364,7 @@ version(ae_unittest) unittest assert(results.all(VarName.z) == [11, 12, 13, 21, 22, 23, 31, 32, 33]); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { enum VarName : uint { tempVarStart = 100, tempVarEnd = 200 } MapSetVars!(VarName, int) v; @@ -378,7 +378,7 @@ version(ae_unittest) unittest assert(b.resolve == 5); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { enum VarName : uint { tempVarStart = 100, tempVarEnd = 200 } MapSetVars!(VarName, int) v; @@ -394,7 +394,7 @@ version(ae_unittest) unittest assert(a.resolve == 7); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { enum VarName : uint { tempVarStart = 100, tempVarEnd = 200 } MapSetVars!(VarName, int) v; @@ -413,7 +413,7 @@ if (is(T : Value)) return index.map(value => array[value]); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { enum VarName : uint { tempVarStart = 100, tempVarEnd = 200 } MapSetVars!(VarName, int) v; @@ -453,7 +453,7 @@ template varCall(alias fun) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static int fun(int i) { return i + 1; } diff --git a/utils/mapset/visitor.d b/utils/mapset/visitor.d index 2111599c..4d09396b 100644 --- a/utils/mapset/visitor.d +++ b/utils/mapset/visitor.d @@ -560,7 +560,7 @@ struct MapSetVisitor(A, V, V nullValue = V.init) /// An algorithm which divides two numbers. /// When the divisor is zero, we don't even query the dividend, /// therefore processing all dividends in one iteration. -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias M = MapSet!(string, int); M m = M.unitSet @@ -587,7 +587,7 @@ version(ae_unittest) unittest assert(results.get("divisor", 0).count == 0); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.algorithm.sorting : sort; @@ -599,7 +599,7 @@ version(ae_unittest) unittest assert(v.currentSubset.all("x").dup.sort.release == [2, 4, 6]); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias M = MapSet!(string, int); M m = M.unitSet.cartesianProduct("x", [1, 2, 3]); @@ -612,7 +612,7 @@ version(ae_unittest) unittest } // Test that initialVarState does not interfere with flushing -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias M = MapSet!(string, int); M m = M.unitSet.cartesianProduct("x", [1]); @@ -625,7 +625,7 @@ version(ae_unittest) unittest } // Test resolving the same variable several times -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias M = MapSet!(string, int); M m = M.unitSet.cartesianProduct("x", [10, 20, 30]); @@ -642,7 +642,7 @@ version(ae_unittest) unittest } // Same, with `copy`. -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias M = MapSet!(string, int); M m = M.unitSet; @@ -663,7 +663,7 @@ version(ae_unittest) unittest } // targetTransform -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.algorithm.sorting : sort; @@ -677,7 +677,7 @@ version(ae_unittest) unittest } // multiTransform -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias M = MapSet!(string, int); M m = M.unitSet.cartesianProduct("x", [1, 2, 3, 4, 5]); diff --git a/utils/math/combinatorics.d b/utils/math/combinatorics.d index 2fa64e0d..8d1b6f0b 100644 --- a/utils/math/combinatorics.d +++ b/utils/math/combinatorics.d @@ -27,12 +27,12 @@ R binomialCoefficient(T, R=T)(T n, T k) return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(binomialCoefficient(3067L, 3) == 4803581405); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.bigint : BigInt; assert(binomialCoefficient!(int, BigInt)(3067, 3) == 4803581405); @@ -44,7 +44,7 @@ R multisetCoefficient(T, R=T)(T n, T k) return binomialCoefficient!(T, R)(n + k - 1, k); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(multisetCoefficient(3067L, 3) == 4812987894); } @@ -81,7 +81,7 @@ struct BinomialCoefficientTable(T, T maxN, T maxK) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(BinomialCoefficientTable!(ulong, 5000, 3).generate().binomialCoefficient(3067, 3) == 4803581405); } @@ -212,7 +212,7 @@ static: } static if (__VERSION__ >= 2_096) -version(ae_unittest) unittest +debug(ae_unittest) unittest { enum N = 3; enum cardinality = 10; diff --git a/utils/math/distribution.d b/utils/math/distribution.d index 6a30c5a5..d9b6ac76 100644 --- a/utils/math/distribution.d +++ b/utils/math/distribution.d @@ -123,14 +123,14 @@ Range!T range(T)(T lo, T hi) { return Range!T(lo, hi, (lo + hi) / 2, true); } // Range!T range(T)(T val) { return Range!T(val, val, val, true); } /// ditto /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(range(1, 2) + 1 == range(2, 3)); assert(1 + range(1, 2) == range(2, 3)); } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto a = range(10, 20); auto b = range(10, 20); @@ -138,7 +138,7 @@ version(ae_unittest) unittest assert(c.avg == 225); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto a = range(10, 20); a = a.fuzzyAssign(25); @@ -239,7 +239,7 @@ if (op.isOneOf("<", "<=", ">", ">=")) return Probability(p); } - version(ae_unittest) unittest // int unittest + debug(ae_unittest) unittest // int unittest { auto a = range(1, 2); foreach (b; 0..4) @@ -268,7 +268,7 @@ if (op.isOneOf("<", "<=", ">", ">=")) return .cmp!(">" ~ op[1..$])(b, a); } - version(ae_unittest) unittest + debug(ae_unittest) unittest { auto b = range(1, 2); foreach (a; 0..4) @@ -353,7 +353,7 @@ if (op.isOneOf("<", "<=", ">", ">=")) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(cmp!">"(0, 1).p == 0 ); assert(cmp!">"(1, 0).p == 1 ); @@ -362,7 +362,7 @@ version(ae_unittest) unittest assert(cmp!"<"(0, 1).p == 1 ); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto a = range(1.0, 3.0); assert(cmp!"<"(a, 0.0).p == 0 ); @@ -374,7 +374,7 @@ version(ae_unittest) unittest assert(cmp!">"(a, 5.0).p == 0 ); } -version(ae_unittest) unittest // number-to-range, int +debug(ae_unittest) unittest // number-to-range, int { auto a = range(1, 2); @@ -391,7 +391,7 @@ version(ae_unittest) unittest // number-to-range, int alias ge = cmp!">="; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(cmp!"<" (range(0.), range(1.)).p == 1); assert(cmp!"<" (range(1.), range(0.)).p == 0); @@ -475,7 +475,7 @@ version (none) } } - version(ae_unittest) unittest + debug(ae_unittest) unittest { import std.random : Random, uniform, uniform01; import std.math.operations : isClose; diff --git a/utils/math/longmul.d b/utils/math/longmul.d index addae47a..f7296d06 100644 --- a/utils/math/longmul.d +++ b/utils/math/longmul.d @@ -117,7 +117,7 @@ if (is(T : long) && T.sizeof >= 2) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(longMul(1, 1) == LongInt!int(1, 0)); assert(longMul(1, 2) == LongInt!int(2, 0)); @@ -200,7 +200,7 @@ if (is(T : long) && T.sizeof >= 2 && is(L == LongInt!T)) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(longDiv(LongInt!int(1, 0), 1) == DivResult!int(1, 0)); assert(longDiv(LongInt!int(5, 0), 2) == DivResult!int(2, 1)); diff --git a/utils/math/mixed_radix.d b/utils/math/mixed_radix.d index 95af3b6b..7ff81cd7 100644 --- a/utils/math/mixed_radix.d +++ b/utils/math/mixed_radix.d @@ -116,7 +116,7 @@ template MixedRadixCoder( } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias Coder = MixedRadixCoder!(uint, uint, true); Coder.Encoder!2 encoder; @@ -130,7 +130,7 @@ version(ae_unittest) unittest assert(decoder.empty); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.meta : AliasSeq; import std.traits : EnumMembers; @@ -346,7 +346,7 @@ template SerializationCoder(alias Coder, S) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct WithMax(T, T max_) { @@ -374,7 +374,7 @@ version(ae_unittest) unittest } static if (is(SumType!int)) -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct A {} struct B { bool v; } diff --git a/utils/math/package.d b/utils/math/package.d index aa0f3792..376db263 100644 --- a/utils/math/package.d +++ b/utils/math/package.d @@ -82,7 +82,7 @@ T rangeIntersection(T)(T a0, T a1, T b0, T b1) return x0 < x1 ? x1 - x0 : 0; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(rangeIntersection(0, 2, 1, 3) == 1); assert(rangeIntersection(0, 1, 2, 3) == 0); @@ -107,7 +107,7 @@ template unary(char op) /// Like the ~ operator, but without int-promotion. alias flipBits = unary!'~'; -version(ae_unittest) unittest +debug(ae_unittest) unittest { ubyte b = 0x80; auto b2 = b.flipBits; @@ -163,7 +163,7 @@ ubyte ilog2(T)(T n) return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(ilog2(0) == 0); assert(ilog2(1) == 0); @@ -179,7 +179,7 @@ ubyte bitsFor(T)(T n) return cast(ubyte)(ilog2(n)+1); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(bitsFor( int.max) == 31); assert(bitsFor(uint.max) == 32); @@ -227,7 +227,7 @@ if (is(typeof({ import std.algorithm.comparison : max; v = max(v, args); }))) v = max(v, args); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { int i = 5; i.minimize(2); assert(i == 2); diff --git a/utils/meta/args.d b/utils/meta/args.d index 4e06817a..b0593749 100644 --- a/utils/meta/args.d +++ b/utils/meta/args.d @@ -56,7 +56,7 @@ if (is(typeof(fun) == function)) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { static int fun(int a=1, int b=2, int c=3, int d=4, int e=5) { @@ -72,7 +72,7 @@ version(ae_unittest) unittest } /// Mixing named and positional arguments -version(ae_unittest) unittest +debug(ae_unittest) unittest { static int fun(int a, int b=2, int c=3, int d=4, int e=5) { @@ -111,7 +111,7 @@ if (is(S == struct)) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct S { @@ -127,7 +127,7 @@ version(ae_unittest) unittest static assert(!is(typeof(args!(S, x=>42)))); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S { diff --git a/utils/meta/binding.d b/utils/meta/binding.d index fed49968..ad2f4c69 100644 --- a/utils/meta/binding.d +++ b/utils/meta/binding.d @@ -76,7 +76,7 @@ struct BoundFunctorOf(R, alias f) } static if (haveChildTrait) -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct Test { diff --git a/utils/meta/binding_v1.d b/utils/meta/binding_v1.d index d8b10acf..f54b44af 100644 --- a/utils/meta/binding_v1.d +++ b/utils/meta/binding_v1.d @@ -91,7 +91,7 @@ version(none) } static if (haveChildTrait && haveFieldAliasBinding) -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct A() { @@ -271,7 +271,7 @@ struct BoundDgPointer(Dg) } static if (haveMethodAliasBinding) -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct A { @@ -393,7 +393,7 @@ struct DispatchToFirstArg(T) } static if (haveMethodAliasBinding) -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct Consumer { diff --git a/utils/meta/chain.d b/utils/meta/chain.d index ab3f8935..02d271e5 100644 --- a/utils/meta/chain.d +++ b/utils/meta/chain.d @@ -29,7 +29,7 @@ import ae.utils.meta.caps; /// static if (haveAliasStructBinding) -version(ae_unittest) unittest +debug(ae_unittest) unittest { int a = 2; int x; @@ -38,7 +38,7 @@ version(ae_unittest) unittest } static if (haveAliasStructBinding) -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct X { @@ -81,7 +81,7 @@ auto chainIterator(Next)(Next next) return ChainIterator!Next(next); } /// ditto -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S { @@ -112,7 +112,7 @@ auto chainFunctor(alias fun)() /// static if (haveAliasStructBinding) -version(ae_unittest) unittest +debug(ae_unittest) unittest { int[] results; auto fn = chainFunctor!(n => results ~= cast(int)n); @@ -169,7 +169,7 @@ alias chainFirst = chainControl!true; /// Stop iteration after this element /// static if (haveAliasStructBinding) -version(ae_unittest) unittest +debug(ae_unittest) unittest { int a = 2; int b = 3; @@ -202,7 +202,7 @@ template chainMap(alias pred) } /// ditto /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { int result; chainMap!(n => n+1)(chainMap!(n => n * 2)((int n) { result = n; return false; }))(2); diff --git a/utils/meta/package.d b/utils/meta/package.d index 907cd7ca..dbad08c0 100644 --- a/utils/meta/package.d +++ b/utils/meta/package.d @@ -70,7 +70,7 @@ template arrayToTuple(alias arr, Elements...) } deprecated alias ArrayToTuple = arrayToTuple; -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias X = arrayToTuple!"abc"; static assert(X[0] == 'a' && X[2] == 'c'); @@ -94,7 +94,7 @@ template expand(alias arr, size_t offset = 0) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { int[3] arr = [1, 2, 3]; void test(int a, int b, int c) {} @@ -110,7 +110,7 @@ auto tupleMap(alias pred, Values...)(auto ref Values values) return tuple(pred(values[0]), tupleMap!pred(values[1 .. $]).expand); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(tuple(2, 3.0).expand.tupleMap!(n => n + 1) == tuple(3, 4.0)); } @@ -128,7 +128,7 @@ template CTIterate(alias A) alias CTIterate = A; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { foreach (c; CTIterate!"abc") {} string s; @@ -157,7 +157,7 @@ mixin template FieldList(Fields...) mixin(_GenFieldList!(-1, 0)); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S { @@ -193,7 +193,7 @@ template isValueOfTypeInTuple(X, T...) enum bool isValueOfTypeInTuple = isValueOfTypeInTuple!(X, T[0..$/2]) || isValueOfTypeInTuple!(X, T[$/2..$]); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static assert( isValueOfTypeInTuple!(int, valueTuple!("a", 42))); static assert(!isValueOfTypeInTuple!(int, valueTuple!("a", 42.42))); @@ -216,7 +216,7 @@ template findValueOfTypeInTuple(X, T...) enum findValueOfTypeInTuple = findValueOfTypeInTuple!(X, T[1..$]); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static assert(findValueOfTypeInTuple!(int, valueTuple!("a", 42))==42); static assert(findValueOfTypeInTuple!(int, "a", int, Object, 42)==42); @@ -231,7 +231,7 @@ if (X.length == 1) alias AllMembers = staticMap!(GetMember, __traits(allMembers, X)); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.typetuple : AliasSeq; @@ -258,7 +258,7 @@ deprecated alias EnumLength = enumLength; return iota(T.init, enumLength!T); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.algorithm.comparison : equal; enum E { a, b, c } @@ -305,7 +305,7 @@ auto has(E)(ref E e) if (is(E == enum)) { return Has!(E, true)(&e); } auto has(E)( E e) if (is(E == enum)) { return Has!(E, false)(e); } /// ditto /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { enum E { @@ -396,7 +396,7 @@ if (is(T == void)) return Result(); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.typetuple : AliasSeq; @@ -516,7 +516,7 @@ static size_t findParameter()(string[] searchedNames, string soughtNames, string } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static void fun(int a, int b, int c) {} @@ -549,7 +549,7 @@ template structFun(S) }()); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct Test { @@ -599,7 +599,7 @@ if (args.length == 1 || args.length == 2) }()); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static void fun(string a, int b = 42) {} alias S = StructFromParams!fun; @@ -607,7 +607,7 @@ version(ae_unittest) unittest static assert(S.init.b == 42); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static void fun(string, int = 42) {} alias Fun = typeof(&fun); @@ -634,7 +634,7 @@ template apply(alias dg) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { int i = 7; int j = i.apply!((ref v) => v++); @@ -651,7 +651,7 @@ Args[$-1] progn(Args...)(lazy Args args) return args[$-1]; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { // Test that expressions are correctly evaluated exactly once. int a, b, c, d; @@ -661,7 +661,7 @@ version(ae_unittest) unittest assert(a==2 && b==2 && c == 2 && d == 2); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { // Test void expressions. int a, b; @@ -680,7 +680,7 @@ Args[0] prog1(Args...)(lazy Args args) return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { int a = 10, b = 20, c = 30; int d = prog1(a++, b++, c++); @@ -704,7 +704,7 @@ if (haveCommonType!Args) return args[$-1]; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(or(0, 7, 5) == 7); assert(or(0, 0, 0) == 0); @@ -725,7 +725,7 @@ if (haveCommonType!Args) return args[$-1]; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(and(7, 5, 0) == 0); assert(and(7, 5, 3) == 3); @@ -786,7 +786,7 @@ static if (haveUDA) enum T getAttribute = findValueOfTypeInTuple!(T, __traits(getAttributes, D)); } - version(ae_unittest) unittest + debug(ae_unittest) unittest { struct Attr { int i; } @@ -850,7 +850,7 @@ mixin template GenerateConstructorProxies() deprecated alias GenerateContructorProxies = GenerateConstructorProxies; -version(ae_unittest) unittest +debug(ae_unittest) unittest { class A { @@ -889,7 +889,7 @@ version(ae_unittest) unittest return instance; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static class C { @@ -927,7 +927,7 @@ version(ae_unittest) unittest return instance; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { int n; int gen(int _ = 0) @@ -1112,7 +1112,7 @@ if (is(T == class)) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { class C { int n = 42; } assert(classInit!C.n == 42); @@ -1136,7 +1136,7 @@ template functor(alias fun) } static if (haveAliasStructBinding) -version(ae_unittest) unittest +debug(ae_unittest) unittest { static void caller(F)(F fun) { diff --git a/utils/meta/proxy.d b/utils/meta/proxy.d index 3ebbeebb..942d873a 100644 --- a/utils/meta/proxy.d +++ b/utils/meta/proxy.d @@ -112,7 +112,7 @@ template ScopeProxy(alias a) } static if (haveChildTrait && haveFieldAliasBinding) -version(ae_unittest) unittest +debug(ae_unittest) unittest { // Can't declare template at statement level static struct Dummy diff --git a/utils/meta/rcclass.d b/utils/meta/rcclass.d index 7f0799fa..3824187d 100644 --- a/utils/meta/rcclass.d +++ b/utils/meta/rcclass.d @@ -138,7 +138,7 @@ if (is(C == class)) } /// Constructors -version(ae_unittest) unittest +debug(ae_unittest) unittest { void ctorTest(bool haveArglessCtor, bool haveArgCtor)() { @@ -190,7 +190,7 @@ version(ae_unittest) unittest } /// Lifetime -version(ae_unittest) unittest +debug(ae_unittest) unittest { static class C { @@ -210,7 +210,7 @@ version(ae_unittest) unittest } /// Inheritance -version(ae_unittest) unittest +debug(ae_unittest) unittest { static class Base { @@ -230,7 +230,7 @@ version(ae_unittest) unittest } /// Non-static opCall -version(ae_unittest) unittest +debug(ae_unittest) unittest { static class C { @@ -245,7 +245,7 @@ version(ae_unittest) unittest } /// Casting -version(ae_unittest) unittest +debug(ae_unittest) unittest { static class A {} static class B : A {} diff --git a/utils/meta/reference.d b/utils/meta/reference.d index dc7d44fb..104a2c58 100644 --- a/utils/meta/reference.d +++ b/utils/meta/reference.d @@ -96,7 +96,7 @@ T dereference(T)(T v) return v; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { Object o = new Object; assert(o.reference is o); diff --git a/utils/meta/tuplerange.d b/utils/meta/tuplerange.d index 279f1e03..4bfac104 100644 --- a/utils/meta/tuplerange.d +++ b/utils/meta/tuplerange.d @@ -24,7 +24,7 @@ module ae.utils.meta.tuplerange; /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { int a = 2; int offset = 1; @@ -40,7 +40,7 @@ import std.meta; import ae.utils.meta.caps; -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct X { @@ -102,7 +102,7 @@ auto trOnly(T...)(T values) return Result(values); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static int fun() { @@ -118,7 +118,7 @@ version(ae_unittest) unittest static assert(fun() == 3); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static int fun() { @@ -135,7 +135,7 @@ version(ae_unittest) unittest static assert(fun() == 3); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S { @@ -179,7 +179,7 @@ auto trFilter(alias pred, R)(auto ref R r) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { int a = 2; int b = 3; @@ -221,7 +221,7 @@ auto trCTFilter(alias pred, R)(auto ref R r) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { enum isNumeric(T) = is(typeof(cast(int)T.init)); int[] results; @@ -256,7 +256,7 @@ auto trMap(alias pred, R)(auto ref R r) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { int result; (2) @@ -332,7 +332,7 @@ auto trJoiner(R)(auto ref R r) return Result(r); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { int[] values; trOnly( @@ -362,7 +362,7 @@ auto trIter(R)(auto ref R r) return Result(r); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { int[] values; trOnly( diff --git a/utils/meta/x.d b/utils/meta/x.d index 56a27865..8bfc80f7 100644 --- a/utils/meta/x.d +++ b/utils/meta/x.d @@ -47,7 +47,7 @@ private string xImpl(string x) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { enum VAR = "aoeu"; int aoeu; diff --git a/utils/parallelism.d b/utils/parallelism.d index 45320e61..256ee7b7 100644 --- a/utils/parallelism.d +++ b/utils/parallelism.d @@ -13,10 +13,14 @@ module ae.utils.parallelism; +import ae.utils.array : amap; + import std.algorithm.comparison : min; +import std.algorithm.iteration; import std.algorithm.mutation; import std.algorithm.searching; import std.algorithm.sorting; +import std.array; import std.parallelism; import std.range : chunks, iota; import std.range.primitives; @@ -38,7 +42,7 @@ auto parallelSort(alias less = "a < b", R)(R r) return impl(r); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert([3, 1, 2].parallelSort.release == [1, 2, 3]); } @@ -59,7 +63,7 @@ auto parallelEagerMap(R, Pred)(R input, Pred pred, size_t workUnitSize = 0) return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert([1, 2, 3].parallelEagerMap((int n) => n + 1) == [2, 3, 4]); } @@ -84,7 +88,7 @@ bool parallelEqual(T)(T[] a, T[] b) return chunkEqual.all!(a => a)(); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.array : array; auto a = 1024.iota.array; @@ -94,6 +98,13 @@ version(ae_unittest) unittest assert(!parallelEqual(a, b)); } +// ************************************************************************ + +private auto parallelChunkOffsets(size_t length) +{ + size_t numChunks = min(length, totalCPUs); + return (numChunks + 1).iota.map!(chunkIndex => chunkIndex * length / numChunks); +} /// Split a range into chunks, processing each chunk in parallel. /// Returns a dynamic array containing the result of calling `fun` on each chunk. @@ -101,14 +112,11 @@ version(ae_unittest) unittest T[] parallelChunks(R, T)(R range, scope T delegate(R) fun) if (isRandomAccessRange!R) { - auto total = range.length; - size_t numChunks = min(total, totalCPUs); + auto offsets = parallelChunkOffsets(range.length); + size_t numChunks = offsets.length - 1; auto result = new T[numChunks]; foreach (chunkIndex; numChunks.iota.parallel(1)) - result[chunkIndex] = fun(range[ - (chunkIndex + 0) * total / numChunks .. - (chunkIndex + 1) * total / numChunks - ]); + result[chunkIndex] = fun(range[offsets[chunkIndex] .. offsets[chunkIndex + 1]]); return result; } @@ -116,13 +124,11 @@ if (isRandomAccessRange!R) T[] parallelChunks(N, T)(N total, scope T delegate(N start, N end) fun) if (is(N : ulong)) { - size_t numChunks = min(total, totalCPUs); + auto offsets = parallelChunkOffsets(total); + size_t numChunks = offsets.length - 1; auto result = new T[numChunks]; foreach (chunkIndex; numChunks.iota.parallel(1)) - result[chunkIndex] = fun( - cast(N)((chunkIndex + 0) * total / numChunks), - cast(N)((chunkIndex + 1) * total / numChunks), - ); + result[chunkIndex] = fun(cast(N)offsets[chunkIndex], cast(N)offsets[chunkIndex + 1]); return result; } @@ -131,14 +137,11 @@ auto parallelChunks(alias fun, R)(R range) if (isRandomAccessRange!R) { alias T = typeof(fun(range[0..0])); - auto total = range.length; - size_t numChunks = min(total, totalCPUs); + auto offsets = parallelChunkOffsets(range.length); + size_t numChunks = offsets.length - 1; auto result = new T[numChunks]; foreach (chunkIndex; numChunks.iota.parallel(1)) - result[chunkIndex] = fun(range[ - (chunkIndex + 0) * total / numChunks .. - (chunkIndex + 1) * total / numChunks - ]); + result[chunkIndex] = fun(range[offsets[chunkIndex] .. offsets[chunkIndex + 1]]); return result; } @@ -147,17 +150,15 @@ auto parallelChunks(alias fun, N)(N total) if (is(N : ulong)) { alias T = typeof(fun(N.init, N.init)); - size_t numChunks = min(total, totalCPUs); + auto offsets = parallelChunkOffsets(total); + size_t numChunks = offsets.length - 1; auto result = new T[numChunks]; foreach (chunkIndex; numChunks.iota.parallel(1)) - result[chunkIndex] = fun( - cast(N)((chunkIndex + 0) * total / numChunks), - cast(N)((chunkIndex + 1) * total / numChunks), - ); + result[chunkIndex] = fun(cast(N)offsets[chunkIndex], cast(N)offsets[chunkIndex + 1]); return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.algorithm.iteration : sum; assert([1, 2, 3].parallelChunks((int[] arr) => arr.sum).sum == 6); @@ -166,6 +167,42 @@ version(ae_unittest) unittest assert(4.parallelChunks!((low, high) => iota(low, high).sum).sum == 6); } +// ************************************************************************ + +/// Filters `input` in parallel. +/// This version calls `fun` only once per `input` element +/// (at the expense of additional used memory). +auto parallelCachedFilter(alias fun, R)(R input) +if (isInputRange!R && is(typeof(fun(input.front)))) +{ + import ae.utils.functor.primitives : functor; + + auto inputOffsets = parallelChunkOffsets(input.length); + + bool[][] wantedChunks = input.parallelChunks!(chunk => chunk.map!fun.array); + auto numChunks = wantedChunks.length; + auto outputCounts = wantedChunks.parallelEagerMap(functor!((bool[] chunk) => chunk.reduce!((a, b) => size_t(a) + size_t(b)))); + auto outputOffsets = 0 ~ outputCounts.cumulativeFold!((a, b) => a + b).array; + auto outputTotal = outputOffsets[$-1]; + auto output = new typeof(input.front)[outputTotal]; + foreach (chunkIndex; numChunks.iota.parallel) + { + auto chunkOutputIndex = outputOffsets[chunkIndex]; + auto chunkInputOffset = inputOffsets[chunkIndex]; + foreach (chunkInputIndex, wanted; wantedChunks[chunkIndex]) + if (wanted) + output[chunkOutputIndex++] = input[chunkInputOffset + chunkInputIndex]; + } + return output; +} + +unittest +{ + assert([1, 2, 3].parallelCachedFilter!(x => x % 2 == 0) == [2]); +} + +// ************************************************************************ + template parallelReduce(alias fun) { auto parallelReduce(R)(R range) @@ -177,7 +214,7 @@ template parallelReduce(alias fun) // alias parallelSum = parallelReduce!((a, b) => a + b); -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.algorithm.iteration : sum; assert([1, 2, 3].parallelReduce!((a, b) => a + b) == 6); @@ -189,7 +226,7 @@ auto parallelSum(R)(R range) return range.parallelChunks!sum.sum; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.algorithm.iteration : sum; assert([1, 2, 3].parallelSum == 6); diff --git a/utils/path.d b/utils/path.d index 1ed62465..677c239c 100644 --- a/utils/path.d +++ b/utils/path.d @@ -42,7 +42,7 @@ string relPath(string path, string base) deprecated alias fastRelativePath = relPath; -version(ae_unittest) unittest +debug(ae_unittest) unittest { version(Windows) { @@ -86,7 +86,7 @@ bool pathStartsWith(in char[] path, in char[] prefix) (path.length == prefix.length || isDirSeparator(path[prefix.length])); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert( "/foo/bar" .pathStartsWith("/foo/bar")); assert( "/foo/bar/baz".pathStartsWith("/foo/bar")); diff --git a/utils/promise/await.d b/utils/promise/await.d index 48ed2f11..ddc0ff3d 100644 --- a/utils/promise/await.d +++ b/utils/promise/await.d @@ -83,7 +83,7 @@ T await(T, E)(Promise!(T, E) p) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.net.asockets : socketManager; @@ -98,7 +98,7 @@ version(ae_unittest) unittest assert(sum == 3); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { if (false) { diff --git a/utils/promise/concurrency.d b/utils/promise/concurrency.d index 8a90e2b2..2bbf0afa 100644 --- a/utils/promise/concurrency.d +++ b/utils/promise/concurrency.d @@ -67,7 +67,7 @@ if (!is(T == return)) return threadAsync(value.toDelegate); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.net.asockets : socketManager; @@ -170,7 +170,7 @@ if (is(ReturnType!fun == Promise!(T, E), T, E)) static assert(false, "Not a function: " ~ __traits(identifier, fun)); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { Promise!void funImpl() { return resolve(); } alias fun = globallyMemoized!funImpl; @@ -260,7 +260,7 @@ private: } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.net.asockets : socketManager; diff --git a/utils/promise/package.d b/utils/promise/package.d index 98a0b152..0062b706 100644 --- a/utils/promise/package.d +++ b/utils/promise/package.d @@ -472,7 +472,7 @@ private void callSoon(void delegate() dg) @safe nothrow { socketManager.onNextTi // This is just a simple instantiation test. // The full test suite (D translation of the Promises/A+ conformance // test) is here: https://github.com/CyberShadow/ae-promises-tests -version(ae_unittest) nothrow unittest +debug(ae_unittest) nothrow unittest { static bool never; if (never) { @@ -491,7 +491,7 @@ version(ae_unittest) nothrow unittest } // Non-Exception based errors -version(ae_unittest) unittest +debug(ae_unittest) unittest { static bool never; if (never) { @@ -511,7 +511,7 @@ version(ae_unittest) unittest } // Following -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto p = new Promise!void; bool ok; @@ -628,7 +628,7 @@ if (is(P == Promise!(T, E), T, E)) return allPromise; } -version(ae_unittest) nothrow unittest +debug(ae_unittest) nothrow unittest { import std.exception : assertNotThrown; int result; @@ -644,7 +644,7 @@ version(ae_unittest) nothrow unittest assert(result == 6); } -version(ae_unittest) nothrow unittest +debug(ae_unittest) nothrow unittest { import std.exception : assertNotThrown; int called; @@ -662,7 +662,7 @@ version(ae_unittest) nothrow unittest assert(called); } -version(ae_unittest) nothrow unittest +debug(ae_unittest) nothrow unittest { import std.exception : assertNotThrown; Promise!void[] promises; @@ -759,7 +759,7 @@ if (allSatisfy!(isPromise, Promises)) return allPromise; } -version(ae_unittest) nothrow unittest +debug(ae_unittest) nothrow unittest { import std.exception : assertNotThrown; import ae.utils.meta : I; @@ -780,7 +780,7 @@ version(ae_unittest) nothrow unittest assert(result == 4); } -version(ae_unittest) nothrow unittest +debug(ae_unittest) nothrow unittest { bool ok; import std.exception : assertNotThrown; @@ -807,7 +807,7 @@ Promise!(T, E) require(T, E)(ref Promise!(T, E) p, lazy Promise!(T, E) lp) return p; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { Promise!int p; int work; @@ -861,7 +861,7 @@ struct PromiseQueue(T, E = Exception) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { PromiseQueue!int q; q.fulfillOne(1); @@ -873,7 +873,7 @@ version(ae_unittest) unittest assert(result == [1, 2]); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { PromiseQueue!int q; int[] result; diff --git a/utils/promise/range.d b/utils/promise/range.d index d3070485..aa55b699 100644 --- a/utils/promise/range.d +++ b/utils/promise/range.d @@ -60,7 +60,7 @@ if (isInputRange!R) return p; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.algorithm.iteration : map; import ae.sys.timing : setTimeout; diff --git a/utils/random.d b/utils/random.d index 33eeeb24..b02a4f04 100644 --- a/utils/random.d +++ b/utils/random.d @@ -65,7 +65,7 @@ auto incrementalRandomShuffle(Range)(Range range) if (isInputRange!Range) { return incrementalRandomShuffle(range, rndGen); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto shuffled = [1, 2].incrementalRandomShuffle; assert(shuffled.equal([1, 2]) || shuffled.equal([2, 1])); diff --git a/utils/range.d b/utils/range.d index 093994c2..cfb6988c 100644 --- a/utils/range.d +++ b/utils/range.d @@ -85,7 +85,7 @@ T[] ptrSlice(T)(T* a, T* b) return a[0..b-a]; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { FastArrayRange!ubyte r; auto x = r.save; @@ -108,7 +108,7 @@ auto nullTerminatedPtrRange(E)(E* ptr) } /// ditto /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { void test(S)(S s) { @@ -141,7 +141,7 @@ template pairwise(alias pred) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.algorithm.comparison : equal; assert(equal(pairwise!"a+b"([1, 2, 3]), [3, 5])); @@ -210,7 +210,7 @@ static assert(isForwardRange!(typeof(onlyLazy(1)))); static assert(isBidirectionalRange!(typeof(onlyLazy(1)))); static assert(isRandomAccessRange!(typeof(onlyLazy(1)))); -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.algorithm.comparison; import std.range; @@ -249,7 +249,7 @@ auto lazyInitRange(R)(R delegate() constructor) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.algorithm.iteration; import std.range; @@ -305,7 +305,7 @@ auto fastCartesianProduct(R...)(R ranges) return Product(0, end, ranges); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.algorithm.comparison : equal; assert(fastCartesianProduct().length == 1); @@ -327,7 +327,7 @@ auto average(R)(R range) if (hasLength!R) return sum(range) / range.length; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert([1, 2, 3].average == 2); } diff --git a/utils/regex.d b/utils/regex.d index c87fc836..c163e357 100644 --- a/utils/regex.d +++ b/utils/regex.d @@ -39,7 +39,7 @@ Regex!char re(string pattern, alias flags = [])() return r; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert( "123".match(re!`^\d+$`)); assert(!"abc".match(re!`^\d+$`)); @@ -65,7 +65,7 @@ bool matchInto(S, R, Args...)(S s, R r, ref Args args) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { string name, fruit; int count; @@ -89,7 +89,7 @@ bool matchCaptures(S, R, Ret, Args...)(S s, R r, Ret delegate(Args args) fun) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert("Mary has 5 apples" .matchCaptures(`^(\w+) has (\d+) (\w+)$`, @@ -146,7 +146,7 @@ if (isSomeString!S) } /// ditto /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto s = "One 2 three 42"; auto r = `(\d+)`; @@ -155,7 +155,7 @@ version(ae_unittest) unittest } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto s = "2.3 4.56 78.9"; auto r = `(\d+)\.(\d+)`; @@ -340,7 +340,7 @@ private Transformation[] splitRETransformation(string s) return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto actual = splitRETransformation("s/from/to/"); Transformation expected = { type : Transformation.Type.replace, replace : { search : "from", replacement : "to", flags : "" } }; @@ -365,7 +365,7 @@ string applyRE()(string str, string transformation) return str; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto transformation = buildReplaceTransformation(`(?<=\d)(?=(\d\d\d)+\b)`, `,`, "g"); assert("12000 + 42100 = 54100".applyRE(transformation) == "12,000 + 42,100 = 54,100"); diff --git a/utils/serialization/json.d b/utils/serialization/json.d index e626596a..91fca0e3 100644 --- a/utils/serialization/json.d +++ b/utils/serialization/json.d @@ -525,7 +525,7 @@ S toJson(S = string, T)(auto ref T v) // *************************************************************************** -version(ae_unittest) unittest +debug(ae_unittest) unittest { static string jsonToJson(string s) { diff --git a/utils/serialization/sini.d b/utils/serialization/sini.d index 3c2d3526..cc359fae 100644 --- a/utils/serialization/sini.d +++ b/utils/serialization/sini.d @@ -111,7 +111,7 @@ T parseIni(T, R)(R r) return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct File { @@ -139,7 +139,7 @@ version(ae_unittest) unittest assert(f.s.a==["foo":1, "bar":2]); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.utils.serialization.serialization; import std.conv; diff --git a/utils/serialization/store.d b/utils/serialization/store.d index 7b9c2344..d4a6b427 100644 --- a/utils/serialization/store.d +++ b/utils/serialization/store.d @@ -320,14 +320,14 @@ struct SerializedObject(C) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { SerializedObject!(immutable(char)) s1, s2; s1 = "aoeu"; s1.read(&s2); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.utils.serialization.json; auto s = jsonParse!(SerializedObject!(immutable(char)))(`null`); diff --git a/utils/sini.d b/utils/sini.d index 8e9b10d0..6a80d8d2 100644 --- a/utils/sini.d +++ b/utils/sini.d @@ -193,7 +193,7 @@ IniHandler!S iniHandler(S)(void delegate(S, S) leafHandler, IniThickLeafHandler! } -version(ae_unittest) unittest +debug(ae_unittest) unittest { int count; @@ -377,7 +377,7 @@ void parseIniInto(R, T)(R r, ref T result) parseIni(r, result.makeIniHandler!(ElementType!R)); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct File { @@ -405,7 +405,7 @@ version(ae_unittest) unittest assert(f.s.a==["foo":1, "bar":2]); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct Custom { @@ -438,9 +438,9 @@ version(ae_unittest) unittest assert(c == Custom([Custom.Section("one", ["a" : "a"]), Custom.Section("two", ["b" : "b"])])); } -version(ae_unittest) static import ae.utils.aa; +debug(ae_unittest) static import ae.utils.aa; -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.utils.aa; @@ -458,7 +458,7 @@ version(ae_unittest) unittest assert(o["a"]=="a" && o["b"] == "b"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.utils.aa; @@ -478,7 +478,7 @@ version(ae_unittest) unittest assert(o["a"].x == "a" && o["b"].x == "b"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct S { string x, y; } @@ -494,7 +494,7 @@ version(ae_unittest) unittest assert(r["a"].x == "x" && r["a"].y == "y"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct S { string x, y; } static struct T { S* s; } @@ -513,7 +513,7 @@ version(ae_unittest) unittest } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto r = parseIni!(string[string]) ( @@ -525,7 +525,7 @@ version(ae_unittest) unittest assert(r == ["a.b.c" : "d.e.f"]); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S {} auto r = parseIni!(S[string]) @@ -538,7 +538,7 @@ version(ae_unittest) unittest assert(r == ["a" : S()]); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S { Nullable!bool a, b, c; } auto r = parseIni!S @@ -607,7 +607,7 @@ struct IniFragment(S) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct File { @@ -778,7 +778,7 @@ S formatIni(S = string, T)( return writer.writer.get().prettifyIni; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S { int i; S* next; } assert(formatIni(S(1, new S(2))) == q"EOF @@ -789,14 +789,14 @@ i=2 EOF"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(formatIni(["one" : 1]) == q"EOF one=1 EOF"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(formatIni(["one" : 1]) == q"EOF one=1 @@ -877,7 +877,7 @@ void updateIni(S)(ref S[] lines, S name, S value) lines = lines[0..valueLine] ~ lines[valueLine+1..$]; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto ini = q"< a=1 @@ -888,7 +888,7 @@ version(ae_unittest) unittest assert(parseIni!S(ini).a == 3); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto ini = q"< a=1 @@ -909,7 +909,7 @@ version(ae_unittest) unittest >".strip.splitLines.map!strip), text(ini)); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto ini = q"< [s] @@ -927,7 +927,7 @@ version(ae_unittest) unittest >".strip.splitLines.map!strip)); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto ini = q"< a=1 @@ -948,7 +948,7 @@ void updateIniFile(S)(string fileName, S name, S value) lines.map!(l => chain(l.byCodeUnit, only(typeof(S.init[0])('\n')))).joiner.toFile(fileName); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.file; enum fn = "temp.ini"; @@ -981,7 +981,7 @@ void updateIni(S, T)(ref S[] lines, auto ref T value) visitWithPath!(visitor, S)(null, value); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S { int a, b, c; } auto ini = q"< diff --git a/utils/sound/asound.d b/utils/sound/asound.d index 6d6940fb..8b2c668e 100644 --- a/utils/sound/asound.d +++ b/utils/sound/asound.d @@ -88,7 +88,7 @@ void playWave(Wave)(Wave wave, int sampleRate = 44100) enforce(pid.wait() == 0, "aplay failed"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { if (false) playWave(iota(100)); diff --git a/utils/statequeue.d b/utils/statequeue.d index e1a66269..42b0201b 100644 --- a/utils/statequeue.d +++ b/utils/statequeue.d @@ -153,7 +153,7 @@ public: } // Test changing the goal multiple times per tick -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.utils.promise.timing : sleep; @@ -177,7 +177,7 @@ version(ae_unittest) unittest } // Test incremental transitions towards the goal -version(ae_unittest) unittest +debug(ae_unittest) unittest { import ae.utils.promise.timing : sleep; diff --git a/utils/text/ascii.d b/utils/text/ascii.d index 5f0e95f7..c9eed558 100644 --- a/utils/text/ascii.d +++ b/utils/text/ascii.d @@ -64,7 +64,7 @@ template decimalSize(T : ulong) deprecated alias DecimalSize = decimalSize; -version(ae_unittest) unittest +debug(ae_unittest) unittest { template decimalSize2(T : ulong) { @@ -153,7 +153,7 @@ string toDec(T : ulong)(T n) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.conv : to; assert(toDec(42) == "42"); @@ -187,7 +187,7 @@ char[U] toDecFixed(size_t U, N : ulong)(N n) return buf; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(toDecFixed!6(12345u) == "012345"); } @@ -221,7 +221,7 @@ T fromDec(T)(string s) return n; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(fromDec!int("456") == 456); assert(fromDec!int("-42") == -42); diff --git a/utils/text/functor.d b/utils/text/functor.d index f8ea426e..1bc6e6ba 100644 --- a/utils/text/functor.d +++ b/utils/text/functor.d @@ -57,7 +57,7 @@ template formattingFunctor( } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.array : appender; import std.format : singleSpec; @@ -69,7 +69,7 @@ version(ae_unittest) unittest } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.array : appender; auto a = appender!string; @@ -139,7 +139,7 @@ if (isFunctor!F) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.conv : text; auto f = (void delegate(const(char)[]) sink) => sink("Hello"); @@ -157,7 +157,7 @@ auto formatted(string fmt = null, T...)(auto ref T values) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.conv : text; import std.format : format; @@ -181,7 +181,7 @@ template stringifiable(alias fun, T...) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias humanSize = stringifiable!( (size, sink) @@ -228,7 +228,7 @@ if (isFunctor!T && isFunctor!F) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.conv : text; assert(fmtIf(true , () => 5, () => "apple").text == "5"); @@ -252,7 +252,7 @@ auto fmtSeq(string fmt = "%s", Values...)(Values values) @nogc .stringifiable; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.conv : text; assert(fmtSeq(5, " ", "apple").text == "5 apple"); diff --git a/utils/text/package.d b/utils/text/package.d index 8e1eb369..a070d2e9 100644 --- a/utils/text/package.d +++ b/utils/text/package.d @@ -49,7 +49,7 @@ string formatAs(T)(auto ref T obj, string fmt) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(5.formatAs("%03d") == "005"); } @@ -72,7 +72,7 @@ deprecated template eatLine(OnEof onEof) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { string s = "Hello\nworld"; assert(s.eatLine() == "Hello"); @@ -206,7 +206,7 @@ T[] fastReplace(T)(T[] what, T[] from, T[] to) return what; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.array; void test(string haystack, string from, string to) @@ -289,7 +289,7 @@ T[][] splitAsciiLines(T)(T[] text) return lines; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(splitAsciiLines("a\nb\r\nc\r\rd\n\re\r\n\nf") == ["a", "b", "c\r\rd", "\re", "", "f"]); assert(splitAsciiLines(string.init) == splitLines(string.init)); @@ -326,7 +326,7 @@ T[][] asciiSplit(T)(T[] text) return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { foreach (s; ["", " ", "a", " a", "a ", "a b", " a b", "a b ", " a b ", " ", " a", "a ", "a b", "a b ", "a b c"]) @@ -345,7 +345,7 @@ T[] asciiStrip(T)(T[] s) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { string s = "Hello, world!"; assert(asciiStrip(s) is s); @@ -397,7 +397,7 @@ ascii normalizeWhitespace(ascii s) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(normalizeWhitespace(" Mary had\ta\nlittle\r\n\tlamb") == "Mary had a little lamb"); } @@ -421,7 +421,7 @@ string[] splitByCamelCase(string s) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(splitByCamelCase("parseIPString") == ["parse", "IP", "String"]); assert(splitByCamelCase("IPString") == ["IP", "String"]); @@ -438,7 +438,7 @@ string camelCaseJoin(string[] arr) return result; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert("parse-IP-string".split('-').camelCaseJoin() == "parseIPString"); } @@ -542,7 +542,7 @@ string verbatimWrap( alias CIAsciiString = NormalizedArray!(immutable(char), s => s.byCodeUnit.map!(std.ascii.toLower)); /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { CIAsciiString s = "test"; assert(s == "TEST"); @@ -560,7 +560,7 @@ import std.uni : toLower; alias CIUniString = NormalizedArray!(immutable(char), s => s.map!(toLower)); /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { CIUniString s = "привет"; assert(s == "ПРИВЕТ"); @@ -598,7 +598,7 @@ ascii UTF8ToRaw(in char[] r) pure return s[0..i]; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { char[1] c; for (int i=0; i<256; i++) @@ -649,7 +649,7 @@ C[] fromZArray(C)(C[] arr) return arr[0 .. p<0 ? $ : p]; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { char[4] arr = "ab\0d"; assert(arr.fromZArray == "ab"); @@ -657,7 +657,7 @@ version(ae_unittest) unittest assert(arr.fromZArray == "abcd"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { string arr = "ab\0d"; assert(arr.fromZArray == "ab"); @@ -805,7 +805,7 @@ if (is(Hex == char[N*2])) ); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { foreach (checked; TypeTuple!(false, true)) foreach (lower; TypeTuple!(false, true)) @@ -912,13 +912,13 @@ template toHex(alias digits = hexDigits) alias toLowerHex = toHex!lowerHexDigits; /// ditto -version(ae_unittest) unittest +debug(ae_unittest) unittest { ubyte[] bytes = [0x12, 0x34]; assert(toHex(bytes) == "1234"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { ubyte[] bytes = [0x12, 0x34]; char[] buf = new char[4]; @@ -926,19 +926,19 @@ version(ae_unittest) unittest assert(buf == "1234"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { char[8] buf; toHex(0x01234567, buf); assert(buf == "01234567"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(toHex(0x01234567) == "01234567"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { ubyte[2] bytes = [0x12, 0x34]; auto buf = bytes.toLowerHex(); @@ -946,7 +946,7 @@ version(ae_unittest) unittest assert(buf == "1234"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { import core.exception : AssertError; @@ -1147,7 +1147,7 @@ template fpToString(F) } static if (!is(Unqual!F == real)) - version(ae_unittest) unittest + debug(ae_unittest) unittest { union U { @@ -1181,14 +1181,14 @@ template fpToString(F) alias doubleToString = fpToString!double; /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { alias floatToString = fpToString!float; alias realToString = fpToString!real; alias crealToString = fpToString!(const(real)); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(2.3841857910156251e-07.doubleToString == "2.384185791015625e-07"); assert(1.3e-07.doubleToString == "1.3e-07"); @@ -1228,7 +1228,7 @@ struct FPAsString(T) FPAsString!T fpAsString(T)(T f) { return FPAsString!T(f); } /// ditto @safe //nothrow @nogc -version(ae_unittest) unittest +debug(ae_unittest) unittest { StaticBuf!(char, 1024) buf; buf.formattedWrite!"%s"(fpAsString(0.1)); diff --git a/utils/text/parsefp.d b/utils/text/parsefp.d index 76f56f55..34ac7493 100644 --- a/utils/text/parsefp.d +++ b/utils/text/parsefp.d @@ -566,7 +566,7 @@ if (is(Target == string) && } /// -version(ae_unittest) @safe unittest +debug(ae_unittest) @safe unittest { import std.math : isClose; auto str = "123.456"; @@ -574,7 +574,7 @@ version(ae_unittest) @safe unittest assert(parse!double(str).isClose(123.456)); } -version(ae_unittest) @safe unittest +debug(ae_unittest) @safe unittest { if (inCI()) return; @@ -664,7 +664,7 @@ version(ae_unittest) @safe unittest } // Tests for the double implementation -version(ae_unittest) @system unittest +debug(ae_unittest) @system unittest { // @system because strtod is not @safe. static if (real.mant_dig == 53) @@ -738,7 +738,7 @@ version(ae_unittest) @system unittest } } -version(ae_unittest) @system unittest +debug(ae_unittest) @system unittest { import core.stdc.errno; import core.stdc.stdlib; @@ -810,14 +810,14 @@ version(ae_unittest) @system unittest } // Fails on some CI services (not reproducible locally even with Travis CI docker image) -version (ae_unittest) +debug (ae_unittest) { private @property bool haveEnvVarImpl(string s) { import std.process; return !!environment.get(s); } private @property bool haveEnvVar(string s) pure @trusted nothrow @nogc { return (cast(bool function(string) pure nothrow @nogc)&haveEnvVarImpl)(s); } private bool inCI() pure @safe nothrow @nogc { return (haveEnvVar("TRAVIS") || haveEnvVar("GITHUB_ACTIONS") || haveEnvVar("BUILDKITE_AGENT_NAME")); } } -version(ae_unittest) @safe pure unittest +debug(ae_unittest) @safe pure unittest { if (inCI()) return; diff --git a/utils/textout.d b/utils/textout.d index 51057dbe..064b14a7 100644 --- a/utils/textout.d +++ b/utils/textout.d @@ -33,14 +33,14 @@ alias FastAppender! char StringBuffer ; /// Reusable variant. static assert(isStringSink!StringBuilder); static assert(isStringSink!StringBuffer); -version(ae_unittest) unittest +debug(ae_unittest) unittest { StringBuilder sb; sb.put("Hello", ' ', "world!"); assert(sb.get() == "Hello world!"); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { StringBuilder sb; foreach (n; 0..4096) @@ -97,9 +97,9 @@ struct BlindWriter(T) static assert(isStringSink!(BlindWriter!char)); -version(ae_unittest) import ae.utils.time; +debug(ae_unittest) import ae.utils.time; -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.datetime; @@ -164,7 +164,7 @@ void put(S)(ref S sink, dchar c) sink.put(buf[0..size]); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { StringBuilder sb; put(sb, 'Я'); @@ -188,7 +188,7 @@ void putDecimal(S, N)(ref S sink, N n) sink.put(toDec(n, buf)); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { void test(N)(N n) { diff --git a/utils/time/format.d b/utils/time/format.d index c1f4e1d3..4dfa3243 100644 --- a/utils/time/format.d +++ b/utils/time/format.d @@ -302,7 +302,7 @@ if (isFormattableTime!Time) putToken!(c, context, sink)(); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(SysTime.fromUnixTime(0, UTC()).formatTime!(TimeFormats.STD_DATE) == "Thu Jan 01 00:00:00 GMT+0000 1970"); assert(SysTime(0, new immutable(SimpleTimeZone)(Duration.zero)).formatTime!"T" == "+00:00"); diff --git a/utils/time/fpdur.d b/utils/time/fpdur.d index e0fa943a..b1798274 100644 --- a/utils/time/fpdur.d +++ b/utils/time/fpdur.d @@ -50,7 +50,7 @@ alias hnsecs = dur!"hnsecs"; /// Ditto alias nsecs = dur!"nsecs"; /// Ditto /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { import core.time : msecs; static assert(1.5.seconds == 1500.msecs); @@ -64,7 +64,7 @@ if (is(F : real)) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { import core.time : seconds, msecs; assert(durScale(1.seconds, 1.5) == 1500.msecs); @@ -77,7 +77,7 @@ T fracTotal(string units, T = real)(Duration d) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { import core.time : seconds, msecs; assert(1500.msecs.fracTotal!"seconds" == 1.5); diff --git a/utils/time/package.d b/utils/time/package.d index 4c4d432b..11a0b8ce 100644 --- a/utils/time/package.d +++ b/utils/time/package.d @@ -20,7 +20,7 @@ public import ae.utils.time.parse; public import ae.utils.time.parsedur; public import ae.utils.time.types; -version(ae_unittest) unittest +debug(ae_unittest) unittest { import core.stdc.time : time_t; @@ -34,7 +34,7 @@ version(ae_unittest) unittest // *************************************************************************** // fpdur conflict test -version(ae_unittest) unittest +debug(ae_unittest) unittest { import std.datetime; import ae.utils.time.fpdur; diff --git a/utils/time/parse.d b/utils/time/parse.d index 6289969e..b5c4a555 100644 --- a/utils/time/parse.d +++ b/utils/time/parse.d @@ -412,9 +412,9 @@ alias parseTime = parseTimeLike!SysTime; /// This version parses fmt at runtime. alias parseTimeUsing = parseTimeLikeUsing!SysTime; -version(ae_unittest) import ae.utils.time.format; +debug(ae_unittest) import ae.utils.time.format; -version(ae_unittest) unittest +debug(ae_unittest) unittest { const s0 = "Tue Jun 07 13:23:19 GMT+0100 2011"; //enum t = s0.parseTime!(TimeFormats.STD_DATE); // https://issues.dlang.org/show_bug.cgi?id=12042 @@ -425,13 +425,13 @@ version(ae_unittest) unittest assert(t == t1); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { "Tue, 21 Nov 2006 21:19:46 +0000".parseTime!(TimeFormats.RFC2822); "Tue, 21 Nov 2006 21:19:46 +0000".parseTimeUsing(TimeFormats.RFC2822); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { const char[] s = "Tue, 21 Nov 2006 21:19:46 +0000"; auto d = s.parseTime!(TimeFormats.RFC2822); @@ -439,7 +439,7 @@ version(ae_unittest) unittest } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { enum buildTime = __TIMESTAMP__.parseTime!(TimeFormats.CTIME).stdTime; } @@ -485,7 +485,7 @@ alias parseDateTime = parseTimeLike!DateTime; /// or milliseconds, are parsed but silently discarded. alias parseDateTimeUsing = parseTimeLikeUsing!DateTime; -version(ae_unittest) unittest +debug(ae_unittest) unittest { const char[] s = "Tue, 21 Nov 2006 21:19:46 +0000"; auto d = s.parseDateTime!(TimeFormats.RFC2822); @@ -504,7 +504,7 @@ alias parseDate = parseTimeLike!Date; /// or time of day, are parsed but silently discarded. alias parseDateUsing = parseTimeLikeUsing!Date; -version(ae_unittest) unittest +debug(ae_unittest) unittest { const char[] s = "Tue, 21 Nov 2006 21:19:46 +0000"; auto d = s.parseDate!(TimeFormats.RFC2822); @@ -523,7 +523,7 @@ alias parseTimeOfDay = parseTimeLike!TimeOfDay; /// year/month/day or timezone, are parsed but silently discarded. alias parseTimeOfDayUsing = parseTimeLikeUsing!TimeOfDay; -version(ae_unittest) unittest +debug(ae_unittest) unittest { const char[] s = "Tue, 21 Nov 2006 21:19:46 +0000"; auto d = s.parseTimeOfDay!(TimeFormats.RFC2822); @@ -542,7 +542,7 @@ alias parseAbsTime = parseTimeLike!AbsTime; /// are parsed but silently discarded. alias parseAbsTimeUsing = parseTimeLikeUsing!AbsTime; -version(ae_unittest) unittest +debug(ae_unittest) unittest { const char[] s = "Tue, 21 Nov 2006 21:19:46 +0000"; auto d = s.parseAbsTime!(TimeFormats.RFC2822); diff --git a/utils/time/parsedur.d b/utils/time/parsedur.d index 689c9e03..0cc8e993 100644 --- a/utils/time/parsedur.d +++ b/utils/time/parsedur.d @@ -129,7 +129,7 @@ Duration parseDuration(string s) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(parseDuration("1 day, 1 hour and 30 minutes") == 1.days + 1.hours + 30.minutes); assert(parseDuration("0.5 hours") == 30.minutes); diff --git a/utils/time/types.d b/utils/time/types.d index fe75edb8..889239c6 100644 --- a/utils/time/types.d +++ b/utils/time/types.d @@ -104,7 +104,7 @@ struct AbsTime return days; } - version(ae_unittest) @safe unittest // As in SysTime + debug(ae_unittest) @safe unittest // As in SysTime { import std.datetime.date : DateTime; diff --git a/utils/typecons.d b/utils/typecons.d index 690527d7..198c4631 100644 --- a/utils/typecons.d +++ b/utils/typecons.d @@ -27,7 +27,7 @@ ref T require(T)(ref Nullable!T value, lazy T defaultValue) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { Nullable!int i; assert(i.require(3) == 3); @@ -36,7 +36,7 @@ version(ae_unittest) unittest deprecated alias map = std.typecons.apply; -version(ae_unittest) deprecated unittest +debug(ae_unittest) deprecated unittest { assert(Nullable!int( ).map!(n => n+1).isNull); assert(Nullable!int(1).map!(n => n+1).get() == 2); @@ -52,7 +52,7 @@ Nullable!T flatten(T)(Nullable!(Nullable!T) value) } /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto i = 3.nullable.nullable; assert(i.flatten.get == 3); diff --git a/utils/vec.d b/utils/vec.d index c50cbc54..337e530c 100644 --- a/utils/vec.d +++ b/utils/vec.d @@ -228,7 +228,7 @@ private: } // Test object lifetime -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S { @@ -256,7 +256,7 @@ version(ae_unittest) unittest } // Test iteration -version(ae_unittest) unittest +debug(ae_unittest) unittest { // Ensure iterating twice over a Vec does not consume it. auto v = Vec!int(1, 2, 3); @@ -267,7 +267,7 @@ version(ae_unittest) unittest } // Test non-copyable elements -version(ae_unittest) unittest +debug(ae_unittest) unittest { struct S { diff --git a/utils/xml/entities.d b/utils/xml/entities.d index 179c7f89..02d227c1 100644 --- a/utils/xml/entities.d +++ b/utils/xml/entities.d @@ -402,7 +402,7 @@ public string decodeEntities(string str) deprecated alias decodeEntities convertEntities; -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert(encodeEntities(`The "lock'n'load"`) == `The <Smith & Wesson> "lock'n'load"`); assert(encodeAllEntities("©,€") == "©,€"); diff --git a/utils/xml/lite.d b/utils/xml/lite.d index 5c72e6f2..2f92ec6c 100644 --- a/utils/xml/lite.d +++ b/utils/xml/lite.d @@ -691,7 +691,7 @@ string readUntil(ref StringStream s, char until) return start[0..len]; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { enum xmlText = `` ~ @@ -704,7 +704,7 @@ version(ae_unittest) unittest assert(doc.toString() == xmlText, doc.toString()); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { string testOne(bool preserve)(string s) { @@ -731,7 +731,7 @@ version(ae_unittest) unittest } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct ParseConfig { @@ -747,7 +747,7 @@ version(ae_unittest) unittest } // Parsing naked tags while preserving whitespace -version(ae_unittest) unittest +debug(ae_unittest) unittest { static struct ParseConfig { diff --git a/utils/xmlbuild.d b/utils/xmlbuild.d index 608eba6f..42a3f665 100644 --- a/utils/xmlbuild.d +++ b/utils/xmlbuild.d @@ -117,10 +117,10 @@ struct XmlBuildInfo XmlBuildNode[] children; } -version(ae_unittest) import std.array : split; -version(ae_unittest) import std.algorithm.sorting : sort; +debug(ae_unittest) import std.array : split; +debug(ae_unittest) import std.algorithm.sorting : sort; -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto svg = newXml().svg(); svg.xmlns = "http://www.w3.org/2000/svg"; diff --git a/utils/xmldom.d b/utils/xmldom.d index acbf6be3..40a89720 100644 --- a/utils/xmldom.d +++ b/utils/xmldom.d @@ -225,7 +225,7 @@ struct NoopStringFilter auto handleXmlString(S)(S s) { return s; } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { // Test instantiation XmlDom!string dom; diff --git a/utils/xmlparser.d b/utils/xmlparser.d index b3930a2d..4d5528ee 100644 --- a/utils/xmlparser.d +++ b/utils/xmlparser.d @@ -171,7 +171,7 @@ template SliceType(INPUT) alias typeof(ptrSlice(T.init.ptr, T.init.ptr)) SliceType; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { // Just test compilation with a dummy receiver static struct DummyOutput @@ -228,7 +228,7 @@ S getXmlDecodedString(S)(S s) return s; } -version(ae_unittest) unittest +debug(ae_unittest) unittest { auto s0 = "<"; auto s1 = s0.getXmlDecodedString(); @@ -272,7 +272,7 @@ bool[256] genTable(string COND)() immutable bool[256] xmlWhiteChars = genTable!q{isWhite (c) }(); immutable bool[256] xmlWordChars = genTable!q{isAlphaNum(c) || c=='-' || c=='_' || c==':'}(); -version(ae_unittest) unittest +debug(ae_unittest) unittest { assert( xmlIsWhite(' ')); assert(!xmlIsWhite('a')); diff --git a/utils/xmlsel.d b/utils/xmlsel.d index fc67446c..6bc0e51e 100644 --- a/utils/xmlsel.d +++ b/utils/xmlsel.d @@ -121,7 +121,7 @@ XmlNode[] findAll(XmlNode roots, string selector) } /// ditto /// -version(ae_unittest) unittest +debug(ae_unittest) unittest { enum xmlText = `` ~ diff --git a/utils/xmlwriter.d b/utils/xmlwriter.d index 59d0f3ab..d9a4df8a 100644 --- a/utils/xmlwriter.d +++ b/utils/xmlwriter.d @@ -321,7 +321,7 @@ private struct Escapes(EscapeScope escapeScope) } } -version(ae_unittest) unittest +debug(ae_unittest) unittest { string[string] quotes; quotes["Alan Perlis"] = "When someone says, \"I want a programming language in which I need only say what I want done,\" give him a lollipop."; diff --git a/utils/zlib.d b/utils/zlib.d index d1e89da9..f7dfa4bf 100644 --- a/utils/zlib.d +++ b/utils/zlib.d @@ -231,7 +231,7 @@ Data compress(Data input, int level) return compress(input, ZlibOptions(level)); } -version(ae_unittest) unittest +debug(ae_unittest) unittest { void testRoundtrip(ubyte[] src) {