Help for this page

Select Code to Download


  1. or download this
    sub lives_and_tests_ok (&&;$) {
        my ($case, $test, $name) = @_;
    ...
        my $result = eval { $case->() };
        $@ ? fail($name) : $test->($result, $name);
    }
    
  2. or download this
    lives_and_tests_ok (
        sub { $o->answer },
        sub { is shift, 42, shift },
        "answer is 42"
    );
    
  3. or download this
    sub lives_and_tests_ok (&&;$) {
        my ($case, $test, $name) = @_;
    ...
        local ($b, $a) = ($name, eval { $case->() });
        $@ ? fail($name) : $test->($result, $name);
    }
    
  4. or download this
    lives_and_tests_ok (
        sub { $o->answer },
        sub { is $a, 42, $b },
        "answer is 42"
    );