This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix regression with $version::LAX and bump release
[perl5.git] / cpan / version / t / 04strict_lax.t
CommitLineData
543eec9e
JP
1#! /usr/local/perl -w
2# Before `make install' is performed this script should be runnable with
3# `make test'. After `make install' it should work as `perl test.pl'
4
5#########################
6
7use Test::More qw/no_plan/;
8
9# do strict lax tests in a sub to isolate a package to test importing
10SKIP: {
db9cb848 11 skip 'No extended regexes Perl < 5.006', 174
543eec9e
JP
12 if $] < 5.006_000;
13 strict_lax_tests();
db9cb848
JP
14 is ref($version::LAX), 'Regexp', 'Can see $version::LAX '.$version::LAX ;
15 is ref($version::STRICT), 'Regexp', 'Can see $version::STRICT '.$version::STRICT;
543eec9e
JP
16}
17
db9cb848 18
543eec9e
JP
19sub strict_lax_tests {
20 package temp12345;
21 # copied from perl core test t/op/packagev.t
22 # format: STRING STRICT_OK LAX_OK
23 my $strict_lax_data = << 'CASE_DATA';
241.00 pass pass
251.00001 pass pass
260.123 pass pass
2712.345 pass pass
2842 pass pass
290 pass pass
300.0 pass pass
31v1.2.3 pass pass
32v1.2.3.4 pass pass
33v0.1.2 pass pass
34v0.0.0 pass pass
3501 fail pass
3601.0203 fail pass
37v01 fail pass
38v01.02.03 fail pass
39.1 fail pass
40.1.2 fail pass
411. fail pass
421.a fail fail
431._ fail fail
441.02_03 fail pass
45v1.2_3 fail pass
46v1.02_03 fail pass
47v1.2_3_4 fail fail
48v1.2_3.4 fail fail
491.2_3.4 fail fail
500_ fail fail
511_ fail fail
521_. fail fail
531.1_ fail fail
541.02_03_04 fail fail
551.2.3 fail pass
56v1.2 fail pass
57v0 fail pass
58v1 fail pass
59v.1.2.3 fail fail
60v fail fail
61v1.2345.6 fail pass
62undef fail pass
631a fail fail
641.2a3 fail fail
65bar fail fail
66_ fail fail
67CASE_DATA
68
69 require version;
70 version->import( qw/is_strict is_lax/ );
71 for my $case ( split qr/\n/, $strict_lax_data ) {
72 my ($v, $strict, $lax) = split qr/\t+/, $case;
73 main::ok( $strict eq 'pass' ? is_strict($v) : ! is_strict($v), "is_strict($v) [$strict]" );
74 main::ok( $strict eq 'pass' ? version::is_strict($v) : ! version::is_strict($v), "version::is_strict($v) [$strict]" );
75 main::ok( $lax eq 'pass' ? is_lax($v) : ! is_lax($v), "is_lax($v) [$lax]" );
76 main::ok( $lax eq 'pass' ? version::is_lax($v) : ! version::is_lax($v), "version::is_lax($v) [$lax]" );
77 }
78}