This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
malloc() things must be free()d, not Safefree()d (bug in change#11280
[perl5.git] / lib / Test / Simple / t / More.t
CommitLineData
33459055
MS
1#!perl -w
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = '../lib';
6}
7
8use Test::More tests => 24;
3f2ec160
JH
9
10use_ok('Text::Soundex');
11require_ok('Test::More');
12
13
14ok( 2 eq 2, 'two is two is two is two' );
15is( "foo", "foo", 'foo is foo' );
16isnt( "foo", "bar", 'foo isnt bar');
17isn't("foo", "bar", 'foo isn\'t bar');
18
19#'#
20like("fooble", '/^foo/', 'foo is like fooble');
21like("FooBle", '/foo/i', 'foo is like FooBle');
d020a79a
JH
22like("/usr/local/pr0n/", '/^\/usr\/local/', 'regexes with slashes in like' );
23
24can_ok('Test::More', qw(require_ok use_ok ok is isnt like skip can_ok
25 pass fail eq_array eq_hash eq_set));
26can_ok(bless({}, "Test::More"), qw(require_ok use_ok ok is isnt like skip
27 can_ok pass fail eq_array eq_hash eq_set));
28
29isa_ok(bless([], "Foo"), "Foo");
30
3f2ec160
JH
31
32pass('pass() passed');
33
34ok( eq_array([qw(this that whatever)], [qw(this that whatever)]),
35 'eq_array with simple arrays' );
36ok( eq_hash({ foo => 42, bar => 23 }, {bar => 23, foo => 42}),
37 'eq_hash with simple hashes' );
38ok( eq_set([qw(this that whatever)], [qw(that whatever this)]),
39 'eq_set with simple sets' );
40
41my @complex_array1 = (
42 [qw(this that whatever)],
43 {foo => 23, bar => 42},
44 "moo",
45 "yarrow",
46 [qw(498 10 29)],
47 );
48my @complex_array2 = (
49 [qw(this that whatever)],
50 {foo => 23, bar => 42},
51 "moo",
52 "yarrow",
53 [qw(498 10 29)],
54 );
55
33459055 56is_deeply( \@complex_array1, \@complex_array2, 'is_deeply with arrays' );
3f2ec160
JH
57ok( eq_array(\@complex_array1, \@complex_array2),
58 'eq_array with complicated arrays' );
59ok( eq_set(\@complex_array1, \@complex_array2),
60 'eq_set with complicated arrays' );
61
62my @array1 = (qw(this that whatever),
63 {foo => 23, bar => 42} );
64my @array2 = (qw(this that whatever),
65 {foo => 24, bar => 42} );
66
67ok( !eq_array(\@array1, \@array2),
68 'eq_array with slightly different complicated arrays' );
69ok( !eq_set(\@array1, \@array2),
70 'eq_set with slightly different complicated arrays' );
71
72my %hash1 = ( foo => 23,
73 bar => [qw(this that whatever)],
74 har => { foo => 24, bar => 42 },
75 );
76my %hash2 = ( foo => 23,
77 bar => [qw(this that whatever)],
78 har => { foo => 24, bar => 42 },
79 );
80
33459055
MS
81is_deeply( \%hash1, \%hash2, 'is_deeply with complicated hashes' );
82ok( eq_hash(\%hash1, \%hash2), 'eq_hash with complicated hashes');
3f2ec160
JH
83
84%hash1 = ( foo => 23,
85 bar => [qw(this that whatever)],
86 har => { foo => 24, bar => 42 },
87 );
88%hash2 = ( foo => 23,
89 bar => [qw(this tha whatever)],
90 har => { foo => 24, bar => 42 },
91 );
92
93ok( !eq_hash(\%hash1, \%hash2),
94 'eq_hash with slightly different complicated hashes' );