2 # -*- mode: cperl; coding: utf-8-unix; -*-
4 eval 'exec ${PERL-perl} -Sx "$0" ${1+"$@"}'
15 my $outfile = "t/scope-nested-const.t";
17 my $dirname = dirname(__FILE__);
19 or die "$dirname: chdir failed: $!";
21 chomp(my $gitroot = `git rev-parse --show-toplevel`);
23 or die "$gitroot: chdir failed: $!";
25 open my($fh), ">", $outfile
26 or die "$outfile: can't open file for writing: $!";
28 use Algorithm::Combinatorics 'permutations';
31 ['bigint', 'Math::BigInt' ],
32 ['bigfloat', 'Math::BigFloat'],
33 ['bigrat', 'Math::BigRat' ],
36 print $fh <<'EOF' or die "$outfile: print failed: $!";
44 plan skip_all => 'Need at least Perl v5.10.1' if $] < "5.010001";
49 my $iter = permutations([0, 1, 2]);
50 while (my $idxs = $iter -> next()) {
52 my $p0 = $data -> [ $idxs -> [0] ][0];
53 my $c0 = $data -> [ $idxs -> [0] ][1];
54 my $p1 = $data -> [ $idxs -> [1] ][0];
55 my $c1 = $data -> [ $idxs -> [1] ][1];
56 my $p2 = $data -> [ $idxs -> [2] ][0];
57 my $c2 = $data -> [ $idxs -> [2] ][1];
59 print $fh <<"EOF" or die "$outfile: print failed: $!";
61 note "\\n$p0 -> $p1 -> $p2\\n\\n";
66 is(ref(hex("1")), "$c0", 'ref(hex("1"))');
67 is(ref(oct("1")), "$c0", 'ref(oct("1"))');
72 is(ref(hex("1")), "$c1", 'ref(hex("1"))');
73 is(ref(oct("1")), "$c1", 'ref(oct("1"))');
78 is(ref(hex("1")), "$c2", 'ref(hex("1"))');
79 is(ref(oct("1")), "$c2", 'ref(oct("1"))');
83 is(ref(hex("1")), "", 'ref(hex("1"))');
84 is(ref(oct("1")), "", 'ref(oct("1"))');
87 is(ref(hex("1")), "$c1", 'ref(hex("1"))');
88 is(ref(oct("1")), "$c1", 'ref(oct("1"))');
92 is(ref(hex("1")), "", 'ref(hex("1"))');
93 is(ref(oct("1")), "", 'ref(oct("1"))');
96 is(ref(hex("1")), "$c0", 'ref(hex("1"))');
97 is(ref(oct("1")), "$c0", 'ref(oct("1"))');
101 is(ref(hex("1")), "", 'ref(hex("1"))');
102 is(ref(oct("1")), "", 'ref(oct("1"))');
108 or die "$outfile: can't close file after writing: $!";
110 print "Wrote '$outfile'\n";