This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
yada-yada is a term, not an operator
[perl5.git] / t / op / upgrade.t
CommitLineData
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
7BEGIN {
a817e89d 8 chdir 't' if -d 't';
c975a425 9 require './test.pl';
624c42e2 10 set_up_inc('../lib');
c975a425
NC
11}
12
13use strict;
14
15my $null;
16
17$! = 1;
18my %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
35my @keys = keys %types;
36plan tests => @keys * @keys;
37
38foreach 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}