"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "cpan/Scalar-List-Utils/t/dualvar.t" between
perl-5.32.0-RC0.tar.xz and perl-5.32.0-RC1.tar.xz

About: Perl (Practical Extraction and Report Language) is a high-level, general-purpose, interpreted, dynamic programming language. Release candidate.

dualvar.t  (perl-5.32.0-RC0.tar.xz):dualvar.t  (perl-5.32.0-RC1.tar.xz)
#!./perl #!./perl
use strict; use strict;
use warnings; use warnings;
use Scalar::Util (); use Scalar::Util ();
use Test::More (grep { /dualvar/ } @Scalar::Util::EXPORT_FAIL) use Test::More (grep { /dualvar/ } @Scalar::Util::EXPORT_FAIL)
? (skip_all => 'dualvar requires XS version') ? (skip_all => 'dualvar requires XS version')
: (tests => 41); : (tests => 41);
use Config; use Config;
Scalar::Util->import('dualvar'); Scalar::Util->import('dualvar');
Scalar::Util->import('isdual'); Scalar::Util->import('isdual');
my $var; my $var;
$var = dualvar( 2.2,"string"); $var = dualvar( 2.2,"string");
ok( isdual($var), 'Is a dualvar'); ok( isdual($var), 'Is a dualvar');
ok( $var == 2.2, 'Numeric value'); ok( $var == 2.2, 'Numeric value');
ok( $var eq "string", 'String value'); ok( $var eq "string", 'String value');
my $var2 = $var; my $var2 = $var;
ok( isdual($var2), 'Is a dualvar'); ok( isdual($var2), 'Is a dualvar');
ok( $var2 == 2.2, 'copy Numeric value'); ok( $var2 == 2.2, 'copy Numeric value');
ok( $var2 eq "string", 'copy String value'); ok( $var2 eq "string", 'copy String value');
$var++; $var++;
ok( ! isdual($var), 'No longer dualvar'); ok( ! isdual($var), 'No longer dualvar');
ok( $var == 3.2, 'inc Numeric value'); ok( $var == 3.2, 'inc Numeric value');
ok( $var ne "string", 'inc String value'); ok( $var ne "string", 'inc String value');
my $numstr = "10.2"; my $numstr = "10.2";
my $numtmp = int($numstr); # use $numstr as an int my $numtmp = int($numstr); # use $numstr as an int
$var = dualvar($numstr, ""); $var = dualvar($numstr, "");
ok( isdual($var), 'Is a dualvar'); ok( isdual($var), 'Is a dualvar');
ok( $var == $numstr, 'NV'); ok( $var == $numstr, 'NV');
SKIP: { SKIP: {
skip("dualvar with UV value known to fail with $]",3) if $] < 5.006_001; skip("dualvar with UV value known to fail with $]",3) if $] < 5.006_001;
my $bits = ($Config{'use64bitint'}) ? 63 : 31; my $bits = ($Config{'use64bitint'}) ? 63 : 31;
$var = dualvar(1<<$bits, ""); $var = dualvar(1<<$bits, "");
ok( isdual($var), 'Is a dualvar'); ok( isdual($var), 'Is a dualvar');
ok( $var == (1<<$bits), 'UV 1'); ok( $var == (1<<$bits), 'UV 1');
ok( $var > 0, 'UV 2'); ok( $var > 0, 'UV 2');
} }
# Create a dualvar "the old fashioned way" # Create a dualvar "the old fashioned way"
$var = "10"; $var = "10";
ok( ! isdual($var), 'Not a dualvar'); ok( ! isdual($var), 'Not a dualvar');
my $foo = $var + 0; my $foo = $var + 0;
ok( isdual($var), 'Is a dualvar'); ok( isdual($var), 'Is a dualvar');
{ {
package Tied; package Tied;
sub TIESCALAR { bless {} } sub TIESCALAR { bless {} }
sub FETCH { 7.5 } sub FETCH { 7.5 }
} }
tie my $tied, 'Tied'; tie my $tied, 'Tied';
$var = dualvar($tied, "ok"); $var = dualvar($tied, "ok");
ok(isdual($var), 'Is a dualvar'); ok(isdual($var), 'Is a dualvar');
ok($var == 7.5, 'Tied num'); ok($var == 7.5, 'Tied num');
ok($var eq 'ok', 'Tied str'); ok($var eq 'ok', 'Tied str');
SKIP: { SKIP: {
skip("need utf8::is_utf8",2) unless defined &utf8::is_utf8; skip("need utf8::is_utf8",2) unless defined &utf8::is_utf8;
ok(!!utf8::is_utf8(dualvar(1,chr(400))), 'utf8'); ok(!!utf8::is_utf8(dualvar(1,chr(400))), 'utf8');
ok( !utf8::is_utf8(dualvar(1,"abc")), 'not utf8'); ok( !utf8::is_utf8(dualvar(1,"abc")), 'not utf8');
} }
BEGIN { BEGIN {
if($Config{'useithreads'}) { if($Config{'useithreads'}) {
require threads; import threads; require threads; import threads;
 End of changes. 9 change blocks. 
21 lines changed or deleted 21 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)