From 80572dbc49b774c6c2371075524970172dae7ab4 Mon Sep 17 00:00:00 2001 From: Cabo Juan Manuel Date: Mon, 25 Nov 2013 15:17:31 -0300 Subject: [PATCH 1/6] -unittest.bat: Automatic tests/*.d unittest compilation and execution for Windows. Exactly the same as unittest.sh, but ported to a batch file. --- unittest.bat | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 unittest.bat diff --git a/unittest.bat b/unittest.bat new file mode 100644 index 0000000..54079bf --- /dev/null +++ b/unittest.bat @@ -0,0 +1,42 @@ +@echo off +REM ___Builds and runs Orange unit tests___ + + +rem Test for 'delayed environment variable expansion': +set TESTVAR=before +if "%TESTVAR%" == "before" ( + set TESTVAR=after + if not "!TESTVAR!" == "after" ( + rem Enabling env var expansion with /V, to build the list of .d files: + cmd.exe /V /C unittest.sh.bat + exit /B + ) +) + + +rem Build list of .d files: +set dfiles= +for %%D in ( + orange\core + orange\serialization + orange\serialization\archives + orange\test + orange\util + orange\util\collection + orange\xml + tests +) do ( + for %%X in (%%D\*.d) do ( + set dfiles=!dfiles! %%X + ) +) + + +rem Compile: +dmd -unittest -ofunittest %dfiles% + + +rem Run (only if compilation succeded): +if "%errorlevel%" == "0" ( + .\unittest.exe +) \ No newline at end of file From 3d757876b0eefb4fd7753e37a11f9a00fed52f6a Mon Sep 17 00:00:00 2001 From: Cabo Juan Manuel Date: Mon, 25 Nov 2013 15:24:24 -0300 Subject: [PATCH 2/6] -Unittest 'Primitive' now passes in Windows. --- tests/Primitive.d | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/Primitive.d b/tests/Primitive.d index 58f2168..5ce9acf 100644 --- a/tests/Primitive.d +++ b/tests/Primitive.d @@ -103,7 +103,11 @@ unittest h.ushort_ = 1U; h.wchar_ = 'c'; +version(Windows) { + enum zero = "0x0.p+0"; +} else { enum zero = "0x0p+0"; +} describe("serialize primitives") in { it("should return serialized primitives") in { From 120c8c8935c61b4962258e420e6d8c0576fca973 Mon Sep 17 00:00:00 2001 From: Cabo Juan Manuel Date: Mon, 25 Nov 2013 15:25:39 -0300 Subject: [PATCH 3/6] -Fixed -inline and -release incompatibility with Orange (and unittests now pass). --- orange/serialization/archives/Archive.d | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/orange/serialization/archives/Archive.d b/orange/serialization/archives/Archive.d index 4aa210d..ba850a3 100644 --- a/orange/serialization/archives/Archive.d +++ b/orange/serialization/archives/Archive.d @@ -1348,7 +1348,9 @@ abstract class ArchiveBase (U) : Archive static if (isFloatingPoint!(T)) return floatingPointToData(value); - else + //Note: Inlining bug workaround: "if(true)" is necessary to prevent + // omission of "else" clause. Also works with: "if (!isFloatingPoint!(T))". + else if (true) return to!(Data)(value); } @@ -1383,7 +1385,9 @@ abstract class ArchiveBase (U) : Archive static if (is(T == wchar)) return toWchar(value); - else + //Note: Inlining bug workaround: "if(true)" is necessary to prevent + // omission of "else" clause. Also works with: "if (!isFloatingPoint!(T))". + else if (true) return to!(T)(value); } From 47e8eacbb4d00c3e8611fec2cea018d1550a1206 Mon Sep 17 00:00:00 2001 From: Cabo Juan Manuel Date: Mon, 25 Nov 2013 15:25:39 -0300 Subject: [PATCH 4/6] -Fixed -inline and -release incompatibility with Orange (and unittests now pass). --- Makefile | 2 +- Makefile.win | 2 +- orange/serialization/archives/Archive.d | 8 ++++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/Makefile b/Makefile index 33928ea..89eb677 100644 --- a/Makefile +++ b/Makefile @@ -1,7 +1,7 @@ LIBNAME=orange DC?=dmd PREFIX?=/usr/local -#Warning, unittests fail with VERSION=release +#Note: unittests now work well with -inline and -release VERSION?=standard LIBDIR=lib/$(MODEL) ARCH=$(shell arch || uname -m) diff --git a/Makefile.win b/Makefile.win index b1adaf2..daf742f 100644 --- a/Makefile.win +++ b/Makefile.win @@ -40,7 +40,7 @@ LIBNAME=orange PREFIX?=Install DC?=dmd -#Warning, unittests fail with VERSION=release +#Note: unittests now work well with -inline and -release VERSION?=standard LIBDIR=lib/$(MODEL) diff --git a/orange/serialization/archives/Archive.d b/orange/serialization/archives/Archive.d index 4aa210d..ba850a3 100644 --- a/orange/serialization/archives/Archive.d +++ b/orange/serialization/archives/Archive.d @@ -1348,7 +1348,9 @@ abstract class ArchiveBase (U) : Archive static if (isFloatingPoint!(T)) return floatingPointToData(value); - else + //Note: Inlining bug workaround: "if(true)" is necessary to prevent + // omission of "else" clause. Also works with: "if (!isFloatingPoint!(T))". + else if (true) return to!(Data)(value); } @@ -1383,7 +1385,9 @@ abstract class ArchiveBase (U) : Archive static if (is(T == wchar)) return toWchar(value); - else + //Note: Inlining bug workaround: "if(true)" is necessary to prevent + // omission of "else" clause. Also works with: "if (!isFloatingPoint!(T))". + else if (true) return to!(T)(value); } From f80a853c8086f1142cdc6e6e56f4d1a95a37288d Mon Sep 17 00:00:00 2001 From: Cabo Juan Manuel Date: Mon, 25 Nov 2013 15:42:30 -0300 Subject: [PATCH 5/6] -Typo in unittest.bat. --- unittest.bat | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/unittest.bat b/unittest.bat index 54079bf..8554e0c 100644 --- a/unittest.bat +++ b/unittest.bat @@ -8,7 +8,7 @@ if "%TESTVAR%" == "before" ( set TESTVAR=after if not "!TESTVAR!" == "after" ( rem Enabling env var expansion with /V, to build the list of .d files: - cmd.exe /V /C unittest.sh.bat + cmd.exe /V /C unittest.bat exit /B ) ) @@ -35,7 +35,7 @@ for %%D in ( rem Compile: dmd -unittest -ofunittest %dfiles% - + rem Run (only if compilation succeded): if "%errorlevel%" == "0" ( .\unittest.exe From 3f76ff58f11b5d91e7cf0a8c515c3d3b45614da6 Mon Sep 17 00:00:00 2001 From: Cabo Juan Manuel Date: Mon, 25 Nov 2013 17:45:50 -0300 Subject: [PATCH 6/6] -Fixed indentation&style in change to tests/Primitive.d. --- tests/Primitive.d | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/Primitive.d b/tests/Primitive.d index 5ce9acf..fcbb254 100644 --- a/tests/Primitive.d +++ b/tests/Primitive.d @@ -103,11 +103,10 @@ unittest h.ushort_ = 1U; h.wchar_ = 'c'; -version(Windows) { - enum zero = "0x0.p+0"; -} else { - enum zero = "0x0p+0"; -} + version(Windows) + enum zero = "0x0.p+0"; + else + enum zero = "0x0p+0"; describe("serialize primitives") in { it("should return serialized primitives") in {