Commit | Line | Data |
---|---|---|
c975a425 NC |
1 | #!./perl -w |
2 | ||
3 | # Check that we can "upgrade" from anything to anything else. | |
4 | # Curiously, before this, lib/Math/Trig.t was the only code anywhere in the | |
5 | # build or testsuite that upgraded an NV to an RV | |
6 | ||
7 | BEGIN { | |
a817e89d | 8 | chdir 't' if -d 't'; |
c975a425 | 9 | require './test.pl'; |
624c42e2 | 10 | set_up_inc('../lib'); |
c975a425 NC |
11 | } |
12 | ||
13 | use strict; | |
14 | ||
15 | my $null; | |
16 | ||
17 | $! = 1; | |
18 | my %types = ( | |
19 | null => $null, | |
20 | iv => 3, | |
21 | nv => .5, | |
22 | rv => [], | |
23 | pv => "Perl rules", | |
24 | pviv => 3, | |
25 | pvnv => 1==1, | |
26 | pvmg => $^, | |
27 | ); | |
28 | ||
29 | # This is somewhat cheating but I can't think of anything built in that I can | |
30 | # copy that already has type PVIV | |
31 | $types{pviv} = "Perl rules!"; | |
32 | ||
33 | # use Devel::Peek; Dump $pvmg; | |
34 | ||
35 | my @keys = keys %types; | |
36 | plan tests => @keys * @keys; | |
37 | ||
38 | foreach my $source_type (@keys) { | |
39 | foreach my $dest_type (@keys) { | |
40 | # Pads re-using variables might contaminate this | |
41 | my $vars = {}; | |
42 | $vars->{dest} = $types{$dest_type}; | |
43 | $vars->{source} = $types{$source_type}; | |
649a2d69 NC |
44 | # The assignment can potentially trigger assertion failures, so it's |
45 | # useful to have the diagnostics about what was attempted printed first | |
46 | print "# Assigning $source_type to $dest_type\n"; | |
c975a425 NC |
47 | $vars->{dest} = $vars->{source}; |
48 | is ($vars->{dest}, $vars->{source}); | |
49 | } | |
50 | } |