test runner: add ability to match line of output against string or regex

This commit is contained in:
mgcaret 2020-01-08 18:16:28 -08:00
parent 20ad937855
commit c9a4b81466
3 changed files with 31 additions and 20 deletions

View File

@ -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}"

View File

@ -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

View File

@ -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