forked from Test-More/test-more
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add basic "top stack" functionality. TB2 can now track the call stack…
… and report messages from the top of the stack.
- Loading branch information
Showing
2 changed files
with
114 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#!/usr/bin/perl -w | ||
|
||
use strict; | ||
use warnings; | ||
|
||
use Test::More tests => 4; | ||
use Test::Builder2; | ||
|
||
my $tb = Test::Builder2->new; | ||
|
||
sub outer { | ||
$tb->test_start; | ||
my @ret = $tb->from_top("outer"); | ||
push @ret, inner(@_); | ||
$tb->test_end; | ||
|
||
return @ret; | ||
} | ||
|
||
sub inner { | ||
$tb->test_start; | ||
my $ret = $tb->from_top("inner"); | ||
$tb->test_end; | ||
|
||
return $ret; | ||
} | ||
|
||
is_deeply( $tb->top_stack, [], "top_stack() empty" ); | ||
|
||
#line 29 | ||
is_deeply( [inner()], ["inner at $0 line 29"], "from_top() shallow" ); | ||
is_deeply( [outer()], ["outer at $0 line 30", "inner at $0 line 30"], "from_top() deep" ); | ||
|
||
is_deeply( $tb->top_stack, [], "top_stack() still empty" ); |