1use strict;
2
3use Test::Tester;
4
5use Data::Dumper qw(Dumper);
6
7my $test = Test::Builder->new;
8$test->plan(tests => 105);
9
10my $cap;
11
12$cap = Test::Tester->capture;
13
14my @tests = (
15	[
16		'pass',
17		'$cap->ok(1, "pass");',
18		{
19			name => "pass",
20			ok => 1,
21			actual_ok => 1,
22			reason => "",
23			type => "",
24			diag => "",
25			depth => 0,
26		},
27	],
28	[
29		'pass diag',
30		'$cap->ok(1, "pass diag");
31		$cap->diag("pass diag1");
32		$cap->diag("pass diag2");',
33		{
34			name => "pass diag",
35			ok => 1,
36			actual_ok => 1,
37			reason => "",
38			type => "",
39			diag => "pass diag1\npass diag2\n",
40			depth => 0,
41		},
42	],
43	[
44		'pass diag no \\n',
45		'$cap->ok(1, "pass diag");
46		$cap->diag("pass diag1");
47		$cap->diag("pass diag2");',
48		{
49			name => "pass diag",
50			ok => 1,
51			actual_ok => 1,
52			reason => "",
53			type => "",
54			diag => "pass diag1\npass diag2",
55			depth => 0,
56		},
57	],
58	[
59		'fail',
60		'$cap->ok(0, "fail");
61		$cap->diag("fail diag");',
62		{
63			name => "fail",
64			ok => 0,
65			actual_ok => 0,
66			reason => "",
67			type => "",
68			diag => "fail diag\n",
69			depth => 0,
70		},
71	],
72	[
73		'skip',
74		'$cap->skip("just because");',
75		{
76			name => "",
77			ok => 1,
78			actual_ok => 1,
79			reason => "just because",
80			type => "skip",
81			diag => "",
82			depth => 0,
83		},
84	],
85	[
86		'todo_skip',
87		'$cap->todo_skip("why not");',
88		{
89			name => "",
90			ok => 1,
91			actual_ok => 0,
92			reason => "why not",
93			type => "todo_skip",
94			diag => "",
95			depth => 0,
96		},
97	],
98);
99
100my $big_code = "";
101my @big_expect;
102
103foreach my $test (@tests)
104{
105	my ($name, $code, $expect) = @$test;
106
107	$big_code .= "$code\n";
108	push(@big_expect, $expect);
109
110	my $test_sub = eval "sub {$code}";
111
112	check_test($test_sub, $expect, $name);
113}
114
115my $big_test_sub = eval "sub {$big_code}";
116
117check_tests($big_test_sub, \@big_expect, "run all");
118