This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Get t/uni/cache.t working under minitest
[perl5.git] / t / op / upgrade.t
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 {
8     chdir 't';
9     @INC = '../lib';
10     require './test.pl';
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};
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";
47         $vars->{dest} = $vars->{source};
48         is ($vars->{dest}, $vars->{source});
49     }
50 }