diff --git a/Makefile b/Makefile index a2c7790d..584e0ef0 100644 --- a/Makefile +++ b/Makefile @@ -63,7 +63,8 @@ e2e-test : package @bjforth/src/test/e2e/e2e-test-runner.pl \ bjforth/build/libs/bjForth-$(VERSION).jar \ bjforth/src/test/e2e/e2e-expected-output.txt \ - bjforth/src/test/e2e/e2e-tests.forth + bjforth/src/test/e2e/e2e-tests.forth \ + bjforth/src/main/forth/bjForth.forth #################################################################################################### diff --git a/bjforth/src/main/forth/bjForth.forth b/bjforth/src/main/forth/bjForth.forth index 0024e37a..1035ec93 100644 --- a/bjforth/src/main/forth/bjForth.forth +++ b/bjforth/src/main/forth/bjForth.forth @@ -206,7 +206,7 @@ ################################################################################################### -: NUMBER->STR # ( x width -- ) +: NUM->STR # ( x width -- ) DUP 0<> IF SWAP @@ -227,3 +227,7 @@ ################################################################################################### +: . ( x -- ) + 0 + NUM->STR +; diff --git a/bjforth/src/test/e2e/e2e-expected-output.txt b/bjforth/src/test/e2e/e2e-expected-output.txt index 1a9dd10c..18155acd 100644 --- a/bjforth/src/test/e2e/e2e-expected-output.txt +++ b/bjforth/src/test/e2e/e2e-expected-output.txt @@ -9,4 +9,4 @@ Hello, world Hello, world 24 Hello, world -BYE +00000019 220 BYE diff --git a/bjforth/src/test/e2e/e2e-test-runner.pl b/bjforth/src/test/e2e/e2e-test-runner.pl index 4db86a03..7dc8487e 100755 --- a/bjforth/src/test/e2e/e2e-test-runner.pl +++ b/bjforth/src/test/e2e/e2e-test-runner.pl @@ -12,6 +12,7 @@ my $jarFile = shift or die("Path to JAR file not provided."); my $expectedOutputFile = shift or die("Path to expected output file not provided."); my $testCodeFile = shift or die("Path to test code not provided."); +my $libraryFile = shift or die("Path to bjForth.forth not provided."); open(my $fh, '<', $expectedOutputFile) or die("open(): $!"); my $expectedOutput = do { local($/); <$fh> }; @@ -19,10 +20,10 @@ ### End of stream should mean a graceful exit -my $actualOutput = qx/java -jar ${jarFile} 2>&1 < ${testCodeFile}/; +my $actualOutput = qx/cat ${libraryFile} ${testCodeFile} | java -jar ${jarFile} 2>&1/; if ($actualOutput eq $expectedOutput) { exit 0; } else { die("E2E tests failed.\nActual output is\n\n${actualOutput}"); -} \ No newline at end of file +} diff --git a/bjforth/src/test/e2e/e2e-tests.forth b/bjforth/src/test/e2e/e2e-tests.forth index b263ee9c..35452a9b 100644 --- a/bjforth/src/test/e2e/e2e-tests.forth +++ b/bjforth/src/test/e2e/e2e-tests.forth @@ -62,3 +62,10 @@ PRINT-ME ; ." Hello, world ". NEW-STRING + +################################################################################################### +# Printing numbers +################################################################################################### + +25 8 HEX NUM->STR +220 .