# New Ticket Created by Steven Schubiger # Please include the string: [perl #34543] # in the subject line of all future correspondence about this issue. # <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=34543 >
> The test file t/pmc/pmc.t is full of Perl* tests. > These should be factored out into t/pmc/perl*.t. > The file itself should contain just common PMC functionality tests, > like the range or type checks. > Thanks, > leo
Index: t/pmc/perlundef.t =================================================================== RCS file: /cvs/public/parrot/t/pmc/perlundef.t,v retrieving revision 0.01 diff -u -r0.01 perlundef.t --- /dev/null Tue Mar 22 21:04:55 2005 +++ t/pmc/perlundef.t Tue Mar 22 20:33:50 2005 @@ -0,0 +1,306 @@ +#! perl -w + +# Copyright: 2001-2005 The Perl Foundation. All Rights Reserved. +# $Id: perlundef.t,v 0.01 2005/03/22 18:00:00 leo Exp $ + +=head1 NAME + +t/pmc/perlundef.t - Perl Undefs + +=head1 SYNOPSIS + + % perl -Ilib t/pmc/perlundef.t + +=head1 DESCRIPTION + +Tests the C<PerlUndef> PMC. Checks Perl-specific undef behaviour. + +=cut + +use Parrot::Test tests => 10; + +output_is(<<"CODE", <<'OUTPUT', "undef-logical"); + new P0, .PerlInt + new P1, .PerlUndef + new P2, .PerlInt + +# undef or undef = 0 + or P0, P1, P1 + print P0 + print "a" + +# undef and undef = 0 + and P0, P1, P1 + print P0 + print "b" + +#undef xor undef = "0" + xor P0, P1, P1 + print P0 + print "c" + +# undef or foo = foo + set P2, 349 + or P0, P1, P2 + print P0 + +# undef and foo = undef + and P0, P1, P2 + print P0 + print "c" + +#undef xor foo = foo + set P2, 910 + xor P0, P1, P2 + print P0 + +# not undef = 1 + not P0, P1 + print "x" + print P1 + print "y" + print P0 + print "z" + print "\\n" + end +CODE +ab0c349c910xy1z +OUTPUT + +output_is(<<"CODE", <<'OUTPUT', "undef-add"); [EMAIL PROTECTED] $fp_equality_macro ]} + new P1, .PerlUndef + +# undef + perlundef + new P0, .PerlUndef + add P0, P1, P1 + print P0 + print "\\n" + +# undef + perlint + + new P0, .PerlUndef + new P2, .PerlInt + set P2, 947 + add P0, P1, P2 + print P0 + print "\\n" + +# undef + perlnum + + new P0, .PerlUndef + new P2, .PerlNum + set P2, 385.623 + add P0, P1, P2 + .fp_eq( P0, 385.623, OK) + + print "not" +OK: print "ok" + print "\\n" + + end +CODE +0 +947 +ok +OUTPUT + +output_is(<<"CODE", <<'OUTPUT', "undef-subtract"); [EMAIL PROTECTED] $fp_equality_macro ]} + new P0, .PerlInt + new P1, .PerlUndef + +# undef - undef + sub P0, P1, P1 + print P0 + print "\\n" + +# undef - perlint + new P2, .PerlInt + set P2, 947 + sub P0, P1, P2 + print P0 + print "\\n" + +# undef - perlnum + + new P2, .PerlNum + set P2, 385.623 + sub P0, P1, P2 + .fp_eq( P0, -385.623, OK2) + + print "not" +OK2: print "ok" + print "\\n" + + end +CODE +0 +-947 +ok +OUTPUT + +output_is(<<"CODE", <<'OUTPUT', "undef-multiply"); [EMAIL PROTECTED] $fp_equality_macro ]} + + new P0, .PerlInt + new P1, .PerlUndef + new P2, .PerlInt + +# Undef * Undef + mul P0, P1, P1 + print P0 + print "\\n" + +# Undef * PerlInt + set P2, 983 + mul P0, P1, P2 + print P0 + print "\\n" + +# Undef * PerlNum + new P2, .PerlNum + set P2, 983.3 + mul P0, P1, P2 + print P0 + print "\\n" + + end +CODE +0 +0 +0 +OUTPUT + +output_is(<<"CODE", <<'OUTPUT', "undef-divide"); + new P0, .PerlInt + new P1, .PerlUndef + new P2, .PerlInt + +# Undef / PerlInt + set P2, 19 + div P0, P1, P2 + print P0 + print "\\n" + +# Undef / PerlNum + new P2, .PerlNum + set P2, 343.8 + div P0, P1, P2 + print P0 + print "\\n" + + end +CODE +0 +0 +OUTPUT + +output_is(<<"CODE", <<'OUTPUT', "undef-string"); + new P0, .PerlUndef + set S0, P0 + eq S0, "", OK + print "not " +OK: print "ok\\n" + end +CODE +ok +OUTPUT + +output_is(<<'CODE', <<OUTPUT, "arithmetic with PerlUndef and native ints"); + new P0, .PerlUndef + add P0, 10 + set I1, P0 + print I1 + print "\n" + + new P0, .PerlUndef + sub P0, 20 + set I1, P0 + print I1 + print "\n" + + new P0, .PerlUndef + mul P0, 30 + set I1, P0 + print I1 + print "\n" + + new P0, .PerlUndef + div P0, 40 + set I1, P0 + print I1 + print "\n" + end +CODE +10 +-20 +0 +0 +OUTPUT + +output_is(<<"CODE", <<OUTPUT, "arithmetic with PerlUndef and native floats"); [EMAIL PROTECTED] $fp_equality_macro ]} + new P0, .PerlUndef + add P0, 10.0 + set N1, P0 + .fp_ne(N1, 10.0, ERROR) + print "ok 1\\n" + + new P0, .PerlUndef + sub P0, 2.345 + set N1, P0 + .fp_ne(N1, -2.345, ERROR) + print "ok 2\\n" + + new P0, .PerlUndef + mul P0, 32.5 + set N1, P0 + .fp_ne(N1, 0.000, ERROR) + print "ok 3\\n" + + new P0, .PerlUndef + div P0, 0.5 + set N1, P0 + .fp_ne(N1, 0.000, ERROR) + print "ok 4\\n" + branch DONE +ERROR: print "not ok\\n" + print N1 +DONE: + end +CODE +ok 1 +ok 2 +ok 3 +ok 4 +OUTPUT + +output_like(<<"CODE", <<'OUTPUT', "undef warning"); + .include "warnings.pasm" + warningson .PARROT_WARNINGS_UNDEF_FLAG + new P0, .PerlUndef + print P0 + end +CODE +/Use of uninitialized.* +\s+in file .*pasm/i +OUTPUT + +output_is(<<'CODE', <<'OUTPUT', "bor undef"); + new P0, .PerlUndef + bor P0, 0b00001111 + print P0 + print "\n" + + new P0, .PerlUndef + new P1, .PerlInt + set P1, 0b11110000 + bor P0, P1 + print P0 + print "\n" + end +CODE +15 +240 +OUTPUT