File: block.t

package info (click to toggle)
libtest-block-perl 0.13-5
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 160 kB
  • sloc: perl: 133; makefile: 2
file content (69 lines) | stat: -rw-r--r-- 1,284 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
use strict;
use warnings;
use Test::Builder::Tester tests => 6;
use Test::More;
use Test::Block;

# in perl 5.23.8 and later, caller() in a destructor called while
# exiting a block shows the last line of the block, not the first
my $lastl = $] >= 5.023008;

test_out('ok 1');
{
	my $block = Test::Block->plan(1);
	ok(1);
}
test_test("count okay");


test_out('ok 1');
test_out('not ok 2 - block 2 expected 2 test(s) and ran 1');
test_fail($lastl ? +3 : +2);
{
	my $block = Test::Block->plan(2);
	ok(1);
}
test_test("too few tests");


test_out('ok 1');
test_out('ok 2');
test_out('not ok 3 - block 3 expected 1 test(s) and ran 2');
test_fail($lastl ? +4 : +2);
{
	my $block = Test::Block->plan(1);
	ok(1);
	ok(1);
}
test_test("too many tests");


test_out('ok 1');
test_out('ok 2 # skip test');
test_out('ok 3 # skip test');
SKIP: {
	my $block = Test::Block->plan(3);
	ok(1);
	skip "test" => $block->remaining;
}
test_test("works with skipped tests");


test_out('ok 1');
{
	my $block = Test::Block->plan(1);
	{
		my $block = Test::Block->plan(1);
		ok(1);
	}
}
test_test("nested blocks");

test_out('ok 1');
test_out("not ok 2 - block 'foo' expected 2 test(s) and ran 1");
test_fail($lastl ? +3 : +2);
{
	my $block = Test::Block->plan(foo => 2);
	ok(1);
}
test_test("named block");