Skip to content

Commit

Permalink
fix test-by-example to check for correct error result; include
Browse files Browse the repository at this point in the history
complete actual result on test failure
  • Loading branch information
awwx committed Jun 9, 2011
1 parent 91e2d89 commit 0eb0b11
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions test-by-example.arc
Expand Up @@ -91,7 +91,7 @@
(catch
(if (and (alref actual 'err) (no (alref expected 'err)))
(throw (+ "error: " (alref actual 'err)))
(each (key expected-value) (keep [in (car _) 'val 'prints 'stderr] expected)
(each (key expected-value) (keep [in (car _) 'val 'err 'prints 'stderr] expected)
(let actual-value-assoc (assoc key actual)
(if (no actual-value-assoc)
(throw (+ "expected " key " " (tostring:write expected-value) ", "
Expand All @@ -101,7 +101,7 @@
(if (isnt (trim expected-value 'end)
(trim actual-value 'end))
(throw (+ "expected " key " " (tostring:write expected-value) ", "
"actual " (tostring:write actual-value)))))))))))
"actual " (tostring:write actual)))))))))))

(def example-test (runtime spec-string)
(let specs (fromstring spec-string (parse-test-specs))
Expand Down
12 changes: 11 additions & 1 deletion test-by-example.t
Expand Up @@ -144,7 +144,7 @@ prints: hi\n
(car (parse-test-specs)))
(testis (check-test-result runtime* spec
(eval-test runtime* spec))
"expected val \"4\\n\", actual \"8\""))
"expected val \"4\\n\", actual ((val \"8\"))"))

(example-test (runtime '(foobit-example)) #<<.
> foobit
Expand All @@ -163,3 +163,13 @@ prints: hi\n
prints: foo
.
)
(pr "expected (not a real failure): ")
(testis
(catcherr
(example-test runtime* #<<.
> (err "foo")
err: bar
.
))
(makeerr "test failed"))

0 comments on commit 0eb0b11

Please sign in to comment.