7 use Tests_Helper qw(test_app);
8 use Test::More 'tests' => 110;
12 my $app = test_app( sub { 1 } );
14 for my $i ( [ \&Wx::_match, 'match' ],
15 [ \&Wx::_xsmatch, 'xsmatch' ] ) {
20 ok( xx( [ [] ], $Wx::_arr ), "$t: match an array" );
21 ok( xx( [ [], 1 ], $Wx::_arr ),
22 "$t: more arguments than in prototype" );
23 ok( !xx( [ '' ], $Wx::_arr ), "$t: wrong arguments" );
24 ok( xx( [ [] ], $Wx::_arr ), "$t: match with required arguments" );
25 ok( !xx( [ [], 1 ], $Wx::_arr, 1 ),
26 "$t: don't match with more than required" );
27 ok( xx( [ [] ], $Wx::_arr, 1, 1 ),
28 "$t: match with required arguments and allow_more" );
29 ok( xx( [ [], 1 ], $Wx::_arr, 1, 1 ),
30 "$t: match with more than required and allow_more" );
33 ok( xx( [ [] ], $Wx::_b ), "$t: boolean matches reference" );
34 ok( xx( [ 1 ], $Wx::_b ), "$t: boolean matches integer" );
35 ok( xx( [ 0 ], $Wx::_b ), "$t: boolean matches zero" );
36 ok( xx( [ undef ], $Wx::_b ), "$t: boolean matches literal undef" );
37 ok( xx( [ $undef ], $Wx::_b ), "$t: boolean matches undefined variable" );
38 ok( xx( [ 'foo' ], $Wx::_b ), "$t: boolean matches string" );
41 ok( xx( [ [] ], $Wx::_s ), "$t: string matches reference" );
42 ok( xx( [ 1 ], $Wx::_s ), "$t: string matches integer" );
43 ok( xx( [ 0 ], $Wx::_s ), "$t: string matches zero" );
44 ok( xx( [ undef ], $Wx::_s ), "$t: string matches literal undef" );
45 ok( xx( [ $undef ], $Wx::_s ), "$t: string matches undefined variable" );
46 ok( xx( [ 'foo' ], $Wx::_s ), "$t: string matches string" );
49 ok( !xx( [ [] ], $Wx::_n ), "$t: number does not match reference" );
50 ok( xx( [ 1 ], $Wx::_n ), "$t: number matches integer" );
51 ok( xx( [ 0 ], $Wx::_n ), "$t: number matches zero" );
52 ok( xx( [ 1.2 ], $Wx::_n ), "$t: number matches floating point" );
53 ok( xx( [ 0.0 ], $Wx::_n ), "$t: number matches floating point zero" );
54 ok( !xx( [ undef ], $Wx::_n ), "$t: number does not match literal undef" );
55 ok( !xx( [ $undef ], $Wx::_n ),
56 "$t: number does not match undefined variable" );
57 ok( !xx( [ 'foo' ], $Wx::_n ), "$t: number does not match string" );
60 ok( !xx( [ [] ], $Wx::_wszr ),
61 "$t: Wx::Sizer does not match reference" );
62 ok( !xx( [ 1 ], $Wx::_wszr ), "$t: Wx::Sizer does not match integer" );
63 ok( !xx( [ 0 ], $Wx::_wszr ), "$t: Wx::Sizer does not match zero" );
64 ok( xx( [ undef ], $Wx::_wszr ), "$t: Wx::Sizer matches literal undef" );
65 ok( xx( [ $undef ], $Wx::_wszr ),
66 "$t: Wx::Sizer matches undefined variable" );
67 ok( !xx( [ 'foo' ], $Wx::_wszr ), "$t: Wx::Sizer does not match string" );
68 ok( xx( [ Wx::BoxSizer->new( Wx::wxVERTICAL() ) ], $Wx::_wszr ),
69 "$t: Wx::Sizer matches Wx::Sizer" );
72 ok( !xx( [ [] ], $Wx::_wimg ),
73 "$t: Wx::Image does not match reference" );
74 ok( !xx( [ 1 ], $Wx::_wimg ), "$t: Wx::Image does not match integer" );
75 ok( !xx( [ 0 ], $Wx::_wimg ), "$t: Wx::Image does not match zero" );
76 ok( xx( [ undef ], $Wx::_wimg ), "$t: Wx::Image matches literal undef" );
77 ok( xx( [ $undef ], $Wx::_wimg ),
78 "$t: Wx::Image matches undefined variable" );
79 ok( !xx( [ 'foo' ], $Wx::_wimg ), "$t: Wx::Image does not match string" );
80 ok( xx( [ Wx::Image->new( 1, 2 ) ], $Wx::_wimg ),
81 "$t: Wx::Image matches Wx::Image" );
83 # test for Wx::Point/Wx::Size
84 ok( xx( [ [] ], $Wx::_wpoi ),
85 "$t: Wx::Point matches ARRAY reference" );
86 ok( !xx( [ {} ], $Wx::_wpoi ),
87 "$t: Wx::Point does not match other reference" );
88 ok( !xx( [ 1 ], $Wx::_wpoi ), "$t: Wx::Point does not match integer" );
89 ok( !xx( [ 0 ], $Wx::_wpoi ), "$t: Wx::Point does not match zero" );
90 ok( xx( [ $undef ], $Wx::_wpoi ),
91 "$t: Wx::Point matches undefined variable" );
92 ok( !xx( [ 'foo' ], $Wx::_wpoi ), "$t: Wx::Point does not match string" );
93 ok( xx( [ Wx::Point->new( 1, 1 ) ], $Wx::_wpoi ),
94 "$t: Wx::Point matches Wx::Point" );
95 ok( xx( [ Wx::Size->new( 1, 2 ) ], $Wx::_wsiz ),
96 "$t: Wx::Size matches Wx::Size" );
98 # test for Wx::Input/OutputStream
99 ok( xx( [ [], 1 ], $Wx::_wist_n ),
100 "$t: Wx::InputStream matches references" );
101 ok( xx( [ {}, 1 ], $Wx::_wist_n ),
102 "$t: Wx::InputStream matches references (again)" );
103 ok( !xx( [ 1, 1 ], $Wx::_wist_n ),
104 "$t: Wx::InputStream does not match integer" );
105 ok( !xx( [ 'foo', 1 ], $Wx::_wist_n ),
106 "$t: Wx::InputStream does not match string" );
107 ok( xx( [ undef, 1 ], $Wx::_wist_n ),
108 "$t: Wx::InputStream matches undef" );
109 ok( xx( [ *main::bar, 1 ], $Wx::_wist_n ),
110 "$t: Wx::InputStream matches typeglobs" );
111 *main::bar = *main::bar; # fool warning