Skip to content

Commit 2f05936

Browse files
author
Chris White
committed
Begin moving tests to Test::Class
Now /t/lib has a Test::Kit... kit, and /t/tests hold Test::Class-based tests.
1 parent f7e0236 commit 2f05936

File tree

6 files changed

+57
-17
lines changed

6 files changed

+57
-17
lines changed

Makefile.PL

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ WriteMakefile(
2121
},
2222
BUILD_REQUIRES => {
2323
'Test::More' => '0.92',
24+
'Test::Kit' => '0',
25+
'Test::Class' => '0',
26+
'Test::Class::Load' => '0',
2427
'Capture::Tiny' => '0',
2528
'Module::Loaded' => '0',
2629
'File::Spec' => '0',

run

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/sh
22
if [[ $# -eq 0 ]]; then
3-
args=(-f ex/xml1.axk ex/ex1.xml)
3+
args=(-f ex/xml1.axk t/ex1.xml)
44
else
55
args=("$@")
66
fi

t/06-class-tests.t

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!perl
2+
# 06-class-tests.t: Run t/tests
3+
4+
use 5.018;
5+
use strict;
6+
use warnings;
7+
use lib 't/lib';
8+
use Test::Class::Load qw(t/tests);
9+
Test::Class->runtests;
10+
11+
# vi: set ts=4 sts=4 sw=4 et ai fdm=marker fdl=1: #
File renamed without changes.

t/lib/AxkTest.pm

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#!perl
2+
# AxkTest.pm: Test::Kit for XML::Axk
3+
4+
use Test::Kit;
5+
use 5.018;
6+
use strict;
7+
use warnings;
8+
9+
include feature => {
10+
import => [':5.18']
11+
};
12+
include qw(strict warnings);
13+
include qw(Test::More File::Spec XML::Axk::App);
14+
include 'Capture::Tiny' => {
15+
import => [qw(capture_stdout capture_merged)]
16+
};
17+
18+
1;
19+
20+
# vi: set ts=4 sts=4 sw=4 et ai fdm=marker fdl=1: #
Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
11
#!perl -T
22

3-
package main;
3+
package T::Object::TinyDefaults;
44

5-
use 5.018;
6-
use strict;
7-
use warnings;
8-
use Test::More tests=>27;
5+
use AxkTest;
6+
use parent 'Test::Class';
97

10-
BEGIN {
11-
use_ok( 'Object::TinyDefaults' ) || print "Bail out!\n";
12-
}
8+
sub class { "Object::TinyDefaults" };
139

14-
diag( "Testing Object::TinyDefaults $Object::TinyDefaults::VERSION, Perl $], $^X" );
10+
sub startup :Tests(startup=>1) {
11+
my $test = shift;
12+
use_ok $test->class;
13+
diag( "Testing Object::TinyDefaults $Object::TinyDefaults::VERSION, Perl $], $^X" );
14+
}
1515

1616
# No defaults ===================================================== {{{1
1717
package NoDefaults {
1818
use Object::TinyDefaults qw(foo bar);
1919
}
2020

21-
package main {
21+
package T::Object::TinyDefaults {
22+
sub no_defaults : Tests {
2223
my $x = NoDefaults->new();
2324
isa_ok($x, 'NoDefaults');
2425
isa_ok($x, 'Object::TinyDefaults');
@@ -29,14 +30,15 @@ package main {
2930
is($x->foo, 42, 'numeric assignment');
3031
is($x->bar, 'yes', 'string assignment');
3132
}
32-
33+
}
3334
# }}}1
3435
# Defaults and field names ======================================== {{{1
3536
package DefaultsAndNames {
3637
use Object::TinyDefaults { foo => 'default' }, qw(foo bar);
3738
}
3839

39-
package main {
40+
package T::Object::TinyDefaults {
41+
sub defaults_and_names : Tests {
4042
my $x = DefaultsAndNames->new();
4143
isa_ok($x, 'DefaultsAndNames');
4244
isa_ok($x, 'Object::TinyDefaults');
@@ -47,14 +49,16 @@ package main {
4749
is($x->foo, 42, 'numeric assignment');
4850
is($x->bar, 'yes', 'string assignment');
4951
}
52+
}
5053

5154
# }}}1
5255
# Defaults and field names; some names only in defaults =========== {{{1
5356
package DefaultsWithNamesAndNames {
5457
use Object::TinyDefaults { quux => 'default' }, qw(foo bar);
5558
}
5659

57-
package main {
60+
package T::Object::TinyDefaults {
61+
sub defaults_with_names_and_names {
5862
my $x = DefaultsWithNamesAndNames->new();
5963
isa_ok($x, 'DefaultsWithNamesAndNames');
6064
isa_ok($x, 'Object::TinyDefaults');
@@ -68,14 +72,16 @@ package main {
6872
is($x->foo, 42, 'numeric assignment');
6973
is($x->bar, 'yes', 'string assignment');
7074
}
75+
}
7176

7277
# }}}1
7378
# Defaults only =================================================== {{{1
7479
package DefaultsOnly {
7580
use Object::TinyDefaults { quux => 'default', foo=>42 };
7681
}
7782

78-
package main {
83+
package T::Object::TinyDefaults {
84+
sub defaults_only {
7985
my $x = DefaultsOnly->new();
8086
isa_ok($x, 'DefaultsOnly');
8187
isa_ok($x, 'Object::TinyDefaults');
@@ -86,9 +92,9 @@ package main {
8692
is($x->quux, 'yes', 'string assignment (quux)');
8793
is($x->foo, 'indeed', 'string assignment (foo)');
8894
}
95+
}
8996

9097
# }}}1
9198

92-
#done_testing();
93-
99+
1;
94100
# vi: set ts=4 sts=4 sw=4 et ai fdm=marker fdl=0: #

0 commit comments

Comments
 (0)