Permalink
Browse files

Kill off prefix:<int> (as per r25890)

Also remove a huge chunk of commented-out Perl 5 code form pack.t.
It confused me greatly twice already - if anybody wants it back,
it can be found in the perl 5 git repo.

git-svn-id: http://svn.pugscode.org/pugs@28246 c213334d-75ef-0310-aa23-eaa082d1ae64
  • Loading branch information...
1 parent 3c2bc42 commit e84b818102100f45013d407cf8935ab1c06af7fd moritz committed Sep 15, 2009
@@ -19,14 +19,14 @@ plan 12;
#?rakudo todo 'integer Inf'
{
- my $x = int( Inf );
+ my $x = Inf.Int;
ok( $x == Inf, 'int numeric equal' );
ok( $x eq 'Inf', 'int string equal' );
}
#?rakudo todo 'integer Inf'
{
- my $x = int( -Inf );
+ my $x = ( -Inf ).Int;
ok( $x == -Inf, 'int numeric equal' );
ok( $x eq '-Inf', 'int string equal' );
}
@@ -123,8 +123,8 @@ isa_ok(1 / 1, Rat);
{
my $a = "1.01";
- isa_ok(int($a), "Int");
- is(int($a), 1, "1.01 intifies to 1");
+ isa_ok($a.Int, "Int");
+ is($a.Int, 1, "1.01 intifies to 1");
}
#L<S02/Built-In Data Types/Num may support arbitrary-precision floating-point>
@@ -93,7 +93,7 @@ plan 22;
ok &::("true")(42),
"symbolic dereferentiation of global subs without the star works (2)";
- is &::("int")(3.1), 3,
+ is &::("truncate")(3.1), 3,
"symbolic dereferentiation of global subs without the star works (3)";
}
@@ -2,7 +2,7 @@ use v6;
use Test;
-plan 99;
+plan 93;
{ # L<S03/"Changes to Perl 5 operators"/imposes boolean context/>
is ?True, True, "? context forcer works (1)";
@@ -163,19 +163,7 @@ sub eval_elsewhere($code){ eval($code) }
}
# int context
-{
- my $a = '2 is my favorite number';
- isa_ok(int($a), Int, 'it is forced into a Int');
- is(+$a, 2, 'forced into integer context');
-
- my $b = 'Did you know that, 2 is my favorite number';
- isa_ok(int($b), Int, 'it is forced into a Int');
- is(int($b), 0, 'non numbers forced into integer context are 0');
-
- my $c = 1.21122111;
- isa_ok(int($c), Int, 'it is forced into a Int');
- is(int($c), 1, 'float numbers forced into integer context are 0');
-}
+# tested in t/spec/S32-num/int.t
#?rakudo skip 'TODO: @(), list assignment'
{
@@ -206,7 +206,6 @@ ok !(uc "a" eq "A"), "uc has the correct precedence in comparision to eq";
# L<S03/Named unary precedence/my $i = int $x; # ILLEGAL>
-#?rakudo todo 'remove prefix:<int>'
eval_dies_ok 'int 4.5', 'there is no more prefix:<int>';
@@ -232,16 +232,16 @@ These tests are the testing for "List parameters" section of Synopsis 06
sub slurp_int( Int *@a ) { @a[0] }
#?rakudo todo 'RT #64814'
- lives_ok { slurp_int( 27.int ) }, 'can call sub with (Int *@a) sig';
+ lives_ok { slurp_int( 27.Int ) }, 'can call sub with (Int *@a) sig';
dies_ok { slurp_int( 'foo' ) }, 'dies: call (Int *@a) sub with string';
#?rakudo skip 'RT #64814'
- is slurp_int( 27.int ), 27, 'call to sub with (Int *@a) works';
+ is slurp_int( 27.Int ), 27, 'call to sub with (Int *@a) works';
sub slurp_of_int( *@a of Int ) { @a[0] }
+ #?rakudo 2 todo 'RT #64814'
lives_ok { slurp_of_int( 64814.int ) }, 'can call (*@a of Int) sub';
- #?rakudo todo 'RT #64814'
dies_ok { slurp_of_int( 'foo' ) }, 'dies: call (*@a of Int) with string';
- is slurp_of_int( 99.int ), 99, 'call to (*@a of Int) sub works';
+ is slurp_of_int( 99.Int ), 99, 'call to (*@a of Int) sub works';
class X64814 {}
class Y64814 {
@@ -84,7 +84,7 @@ class Bar is Foo {
$.data * $a;
}
multi method mul(Num $a) {
- $.data * $a.int * 2
+ $.data * $a.Int * 2
}
}
View
@@ -19,7 +19,7 @@
if $server_or_client eq 'server' {
# warn "SERVER TEST=$test PORT=$port";
my $server = IO::Socket::INET.socket( PF_INET, SOCK_STREAM, TCP );
- $server.bind( $host, int($port) );
+ $server.bind( $host, $port.Int );
$server.listen(); # should accept max queue size parameter
# warn "SERVER LISTENING";
my $fd = open( 't/spec/S32-io/server-ready-flag', :w );
@@ -39,7 +39,7 @@
# open() before the server gets to accept().
until 't/spec/S32-io/server-ready-flag' ~~ :e { sleep(1) }
my $client = IO::Socket::INET.new;
- $client.open( $host, int($port) );
+ $client.open( $host, $port.Int );
# warn "CLIENT OPENED";
$client.send( [~] '0'..'9', 'a'..'z' );
# warn "CLIENT SENT";
@@ -55,7 +55,7 @@
if $server_or_client eq 'server' {
# warn "SERVER TEST=$test PORT=$port";
my $server = IO::Socket::INET.socket( PF_INET, SOCK_STREAM, TCP );
- $server.bind( $host, int($port) );
+ $server.bind( $host, $port.Int );
$server.listen(); # should accept max queue size parameter
# warn "SERVER LISTENING";
while my $client = $server.accept() {
@@ -71,7 +71,7 @@
# open() before the server gets to accept().
sleep 1; # crude, sorry
my $client = IO::Socket::INET.new;
- $client.open( $host, int($port) );
+ $client.open( $host, $port.Int );
# warn "CLIENT OPENED";
$client.send( [~] '0'..'9', 'a'..'z' );
# warn "CLIENT SENT";
View
@@ -251,9 +251,9 @@ is( ~((1..3).map: { dbl( $_ ) }),'2 4 6','extern method in map');
# .thing inside map blocks should still default to $_
# used to be a pugs regression
{
- is ~((1,2,3).map: { int($_) }), "1 2 3", "dependency for following test (1)";
- $_ = 4; is .int, 4, "dependency for following test (2)";
- is ~((1,2,3).map: { .int }), "1 2 3", 'int() should default to $_ inside map, too';
+ is ~((1,2,3).map: { $_.Int }), "1 2 3", "dependency for following test (1)";
+ $_ = 4; is .Int, 4, "dependency for following test (2)";
+ is ~((1,2,3).map: { .Int }), "1 2 3", 'int() should default to $_ inside map, too';
is ~(({1},{2},{3}).map: { $_; $_() }), "1 2 3", 'lone $_ in map should work (1)';
is ~(({1},{2},{3}).map: { $_() }), "1 2 3", 'lone $_ in map should work (2)';
View
@@ -1,6 +1,6 @@
use v6;
use Test;
-plan 68;
+plan 62;
# L<S32::Numeric/Num/"=item truncate">
# truncate and int() are synonynms.
@@ -15,52 +15,43 @@ Basic tests for the int() builtin
# basic sanity:
is(-0, 0, '-0 is the same as 0 - hey, they are integers ;-)');
-is(int(-1), -1, "int(-1) is -1");
-is(int(0), 0, "int(0) is 0");
-is(int(1), 1, "int(1) is 1");
-is(int(3.14159265), 3, "int(3.14159265) is 3");
-is(int(-3.14159265), -3, "int(-3.14159265) is -3");
-
-#?rakudo skip 'named args'
-{
- is(int(:x(-1)), -1, "int(-1) is -1");
- is(int(:x(0)), 0, "int(0) is 0");
- is(int(:x(1)), 1, "int(1) is 1");
- is(int(:x(3.14159265)), 3, "int(3.14159265) is 3");
- is(int(:x(-3.14159265)), -3, "int(-3.14159265) is -3");
-}
-
-is(int(0.999), 0, "int(0.999) is 0");
-is(int(0.51), 0, "int(0.51) is 0");
-is(int(0.5), 0, "int(0.5) is 0");
-is(int(0.49), 0, "int(0.49) is 0");
-is(int(0.1), 0, "int(0.1) is 0");
-isa_ok(int(0.1), Int, 'int(0.1) returns an Int');
-
-is(int(-0.999), 0, "int(-0.999) is 0");
-is(int(-0.51), 0, "int(-0.51) is 0");
-is(int(-0.5), 0, "int(-0.5) is 0");
-is(int(-0.49), 0, "int(-0.49) is 0");
-is(int(-0.1), 0, "int(-0.1) is 0");
-isa_ok(int(-0.1), Int, 'int(-0.1) returns an Int');
-
-is(int(1.999), 1, "int(1.999) is 1");
-is(int(1.51), 1, "int(1.51) is 1");
-is(int(1.5), 1, "int(1.5) is 1");
-is(int(1.49), 1, "int(1.49) is 1");
-is(int(1.1), 1, "int(1.1) is 1");
-
-is(int(-1.999), -1, "int(-1.999) is -1");
-is(int(-1.51), -1, "int(-1.51) is -1");
-is(int(-1.5), -1, "int(-1.5) is -1");
-is(int(-1.49), -1, "int(-1.49) is -1");
-is(int(-1.1), -1, "int(-1.1) is -1");
-
-is(int('-1.999'), -1, "int('-1.999') is -1");
-is(int('0x123'), 0x123, "int('0x123') is 0x123");
-is(int('0d456'), 0d456, "int('0d456') is 0d456");
-is(int('0o678'), 0o67, "int('0o678') is 0o67");
-is(int('3e4d5'), 3e4, "int('3e4d5') is 3e4");
+is((-1).Int, -1, "(-1).Int is -1");
+is(0.Int, 0, "int(0) is 0");
+is(1.Int, 1, "int(1) is 1");
+is(3.14159265.Int, 3, "int(3.14159265) is 3");
+is((-3.14159265).Int, -3, "int(-3.14159265) is -3");
+
+is(0.999.Int, 0, "int(0.999) is 0");
+is(0.51.Int, 0, "int(0.51) is 0");
+is(0.5.Int, 0, "int(0.5) is 0");
+is(0.49.Int, 0, "int(0.49) is 0");
+is(0.1.Int, 0, "int(0.1) is 0");
+isa_ok(0.1.Int, Int, 'int(0.1) returns an Int');
+
+is((-0.999).Int, 0, "int(-0.999) is 0");
+is((-0.51).Int, 0, "int(-0.51) is 0");
+is((-0.5).Int, 0, "int(-0.5) is 0");
+is((-0.49).Int, 0, "int(-0.49) is 0");
+is((-0.1).Int, 0, "int(-0.1) is 0");
+isa_ok((-0.1).Int, Int, 'int(-0.1) returns an Int');
+
+is(1.999.Int, 1, "int(1.999) is 1");
+is(1.51.Int, 1, "int(1.51) is 1");
+is(1.5.Int, 1, "int(1.5) is 1");
+is(1.49.Int, 1, "int(1.49) is 1");
+is(1.1.Int, 1, "int(1.1) is 1");
+
+is((-1.999).Int, -1, "int(-1.999) is -1");
+is((-1.51).Int, -1, "int(-1.51) is -1");
+is((-1.5).Int, -1, "int(-1.5) is -1");
+is((-1.49).Int, -1, "int(-1.49) is -1");
+is((-1.1).Int, -1, "int(-1.1) is -1");
+
+is('-1.999'.Int, -1, "int('-1.999') is -1");
+is('0x123'.Int, 0x123, "int('0x123') is 0x123");
+is('0d456'.Int, 0d456, "int('0d456') is 0d456");
+is('0o678'.Int, 0o67, "int('0o678') is 0o67");
+is('3e4d5'.Int, 3e4, "int('3e4d5') is 3e4");
{
sub __int( $s ) {
@@ -73,26 +64,21 @@ is(int('3e4d5'), 3e4, "int('3e4d5') is 3e4");
for 0, 0.0, 1, 50, 60.0, 99.99, 0.4, 0.6, -1, -50, -60.0, -99.99 {
my $int = __int($_);
- is(.int, $int, "integral value for $_ is $int");
- isa_ok(.int, "Int");
+ is(.Int, $int, "integral value for $_ is $int");
+ isa_ok(.Int, "Int");
}
}
#?DOES 1
# Special values
-is(int(1.9e3), 1900, "int 1.9e3 is 1900");
+is((1.9e3).Int, 1900, "int 1.9e3 is 1900");
#?pugs 3 todo 'bug'
#?rakudo 3 todo 'Inf and NaN not yet implemented'
-is(int(Inf), Inf, "int Inf is Inf");
-is(int(-Inf), -Inf, "int -Inf is -Inf");
-is(int(NaN), NaN, "int NaN is NaN");
+is((Inf).Int, Inf, "int Inf is Inf");
+is((-Inf).Int, -Inf, "int -Inf is -Inf");
+is((NaN).Int, NaN, "int NaN is NaN");
# RT #65132
-{
- #?rakudo todo 'no more prefix:int'
- eval_dies_ok 'int time', 'dies: int time (prefix:int is gone)';
- my $t = time;
- is int($t), $t.int, 'int(time) == time.int'
-}
+eval_dies_ok 'int 3.14', 'dies: int 3.14 (prefix:int is gone)';
# vim: ft=perl6
Oops, something went wrong.

0 comments on commit e84b818

Please sign in to comment.