TB2::AssertStack - A stack of where asserts were called
use TB2::AssertRecord; use TB2::AssertStack; my $stack = TB2::AssertStack->new; my $record = TB2::AssertRecord->new_from_caller(1); $stack->push($record); my $record = $stack->pop; my $asserts = $stack->asserts;
Records what asserts have been called in the current user assert call stack. This is used to know at that point the user originally called an assert, so diagnostics can report the file and line number from the user's point of view despite being buried deep in stacks of asserts.
It can also let TB2 know when control is about to return to the user from calling an assert so it can fire an end of assert action which includes formatting and outputing the final result and diagnostics.
Asserts are stored as TB2::AssertRecord objects.
my $asserts = $stack->asserts;
Returns an array ref of the TB2::AssertRecord objects on the stack.
my $record = $stack->top;
Returns the top AssertRecord on the stack.
my $is_at_top = $stack->at_top;
Returns true if the stack contains just one assert.
my $is_in_assert = $stack->in_assert;
Returns true if there are any assertions on the stack
my $message = $stack->from_top(@message);
Joins @message with empty string and returns it with " at $file line $line" appended from the top of the stack.
Convenient for printing failure diagnostics.
$stack->push(@asserts);
Push asserts onto the stack
my $assert = $stack->pop;
Pop an assert off the stack
To install Test::Simple, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Test::Simple
CPAN shell
perl -MCPAN -e shell install Test::Simple
For more information on module installation, please visit the detailed CPAN module installation guide.