Skip to content

Commit

Permalink
Allow testing of code that shouldn't panic
Browse files Browse the repository at this point in the history
Changelog: added
  • Loading branch information
yorickpeterse committed Jun 5, 2023
1 parent 5f87a41 commit c5af219
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions std/src/std/test.inko
Expand Up @@ -545,6 +545,20 @@ class pub Tests {
}
}

# Registers a new test that asserts the given closure doesn't panic.
fn pub mut no_panic(name: String, code: uni fn) {
fork(name, code) fn (test, process) {
let output = process.spawn
let code = output.status.to_int

if code != 101 { return }

let got = output.stderr.split("\n").last.unwrap_or('the process panicked')

test.failures.push(Failure.new(got, 'the process not to panic'))
}
}

# Runs all the tests.
fn pub move run {
match env.opt(CHILD_VAR) {
Expand Down

0 comments on commit c5af219

Please sign in to comment.