Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introducing Routine is test-assertion trait (#3991)
Introducing Routine is test-assertion trait Marking a subroutine with the "is test-assertion" trait, indicates that the subroutine produces Test (aka TAP) output. All of the exported subroutines in Test implicitely have this trait. When a test fails and a failure needs to be reported, the file and line at which a test assertion is *called* is shown. However, if you build your own subroutines for doing several similar tests depending on arguments given, any failure will be reported *inside* that subroutine rather than at the location where your own subroutine was called. Which is extremely annoying when writing extensive, parameter driven tests. With this trait, you can mark your own testing subroutines to get failing tests to report at the place your own testing subroutine is called! use Test; sub foo-test($value) is test-assertion { is $value, 42, "is the value 42?"; # <-- do *not* report this line } foo-test(666); # <-- report *this* line You can even nest such test assertion subroutines: any failures will always point to the call to the outer subroutine; sub bar-test($value) is test-assertion { foo-test($value); # <-- do *not* report this line } bar-test(666); # <-- report this line
- Loading branch information