Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include bjForth library in E2E tests #267

Merged
merged 5 commits into from
Dec 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

####################################################################################################

Expand Down
6 changes: 5 additions & 1 deletion bjforth/src/main/forth/bjForth.forth
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@

###################################################################################################

: NUMBER->STR # ( x width -- )
: NUM->STR # ( x width -- )
DUP
0<> IF
SWAP
Expand All @@ -227,3 +227,7 @@

###################################################################################################

: . ( x -- )
0
NUM->STR
;
2 changes: 1 addition & 1 deletion bjforth/src/test/e2e/e2e-expected-output.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Hello, world
Hello, world
24
Hello, world
BYE
00000019 220 BYE
5 changes: 3 additions & 2 deletions bjforth/src/test/e2e/e2e-test-runner.pl
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,18 @@
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> };
close($fh);

### 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}");
}
}
7 changes: 7 additions & 0 deletions bjforth/src/test/e2e/e2e-tests.forth
Original file line number Diff line number Diff line change
Expand Up @@ -62,3 +62,10 @@ PRINT-ME
;

." Hello, world ". NEW-STRING

###################################################################################################
# Printing numbers
###################################################################################################

25 8 HEX NUM->STR
220 .