From c9a4b814666af38ed7a0d06e221a43e76fb1a6d6 Mon Sep 17 00:00:00 2001 From: mgcaret Date: Wed, 8 Jan 2020 18:16:28 -0800 Subject: [PATCH] test runner: add ability to match line of output against string or regex --- platforms/GoSXB/run-tests.rb | 15 +++++++++++++++ test/7.3.4.fs | 14 +++++++------- test/7.3.5.fs | 22 +++++++++------------- 3 files changed, 31 insertions(+), 20 deletions(-) diff --git a/platforms/GoSXB/run-tests.rb b/platforms/GoSXB/run-tests.rb index 41e65fa..aaf96e0 100755 --- a/platforms/GoSXB/run-tests.rb +++ b/platforms/GoSXB/run-tests.rb @@ -141,6 +141,21 @@ def run_suite(suite, outfile = nil) @coverage[word.downcase] += 1 unless colons[word.downcase] end end + if prevline =~ /expect:\s*\"(.+)\"\s*$/ + unless line.chomp == $1 + STDERR.puts prevline + STDERR.puts "Unexpected: #{line.chomp.inspect}" + errors += 1 + end + elsif prevline =~ /expect:\s*\/(.+)\/\s*$/ + rexp = Regexp.new($1) + unless line.chomp =~ rexp + STDERR.puts prevline + STDERR.puts "Unexpected: #{line.chomp.inspect}" + errors += 1 + end + end + prevline = line end puts "Errors = #{errors}" diff --git a/test/7.3.4.fs b/test/7.3.4.fs index b4dedf0..b8fd420 100644 --- a/test/7.3.4.fs +++ b/test/7.3.4.fs @@ -37,16 +37,16 @@ t{ control A -> 01 }t testing 7.3.4.4 Console output -t{ ." test" -> }t -t{ .( test ) -> }t -t{ 41 emit -> }t -t{ parse-word test type -> }t +t{ ." test" -> }t \ expect: "test OK" +t{ .( test) -> }t \ expect: "test OK" +t{ 41 emit -> }t \ expect: "A OK" +t{ parse-word test type -> }t \ expect: "test OK" testing 7.3.4.5 Output formatting -t{ cr -> }t -t{ space -> }t -t{ 10 spaces -> }t +t{ cr -> }t \ expect: "" +t{ space -> }t \ expect: " OK" +t{ 8 spaces -> }t \ expect: " OK" t{ #line @ 0>= -> true }t t{ #out @ 0>= -> true }t diff --git a/test/7.3.5.fs b/test/7.3.5.fs index 0520e89..b3fba02 100644 --- a/test/7.3.5.fs +++ b/test/7.3.5.fs @@ -28,21 +28,17 @@ t{ o# 10 -> 08 }t testing 7.3.5.3 Numeric output -\ the output must be examined by hand to completely verify -\ but if the subsequent privitives work, the chances are that -\ these work as well - -t{ 0 . 1 . -1 . -> }t -t{ 0 s. 1 s. -1 s. -> }t -t{ 0 u. 1 u. -1 u. -> }t \ 0 1 ffffffff -t{ -1 10 .r -> }t -t{ -1 10 u.r -> }t -t{ f .d -> }t +t{ 0 . 1 . -1 . -> }t \ expect: "0 1 -1 OK" +t{ 0 s. 1 s. -1 s. -> }t \ expect: "0 1 -1 OK" +t{ 0 u. 1 u. -1 u. -> }t \ expect: "0 1 FFFFFFFF OK" +t{ -1 7 .r -> }t \ expect: " -1 OK" +t{ -1 9 u.r -> }t \ expect: " FFFFFFFF OK" +t{ f .d -> }t \ expect: "15 OK" decimal -t{ 15 .h -> }t +t{ 15 .h -> }t \ expect: "F OK" hex -t{ 0 1 .s -> 0 1 }t -t{ base ? -> }t +t{ 0 1 .s -> 0 1 }t \ expect: "{ 2 : 0 1 } OK" +t{ base ? -> }t \ expect: "10 OK" testing 7.3.5.4 Numeric output primitives