Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #41 from skids/master
Add some integer related tests, some pre-fudged.
  • Loading branch information
moritz committed May 15, 2014
2 parents 28d0d98 + 5313c52 commit d6fdc05
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
7 changes: 6 additions & 1 deletion S02-literals/radix.t
@@ -1,7 +1,7 @@
use v6;
use Test;

plan 134;
plan 135;

# L<S02/General radices/":10<42>">
is( :10<0>, 0, 'got the correct int value from decimal 0' );
Expand Down Expand Up @@ -202,6 +202,11 @@ is( :2<1.1> * :2<10> ** :2<10>, 6, 'multiplication and exponentiatio

is :100[10,10], 1010, "Adverbial form of base 100 integer works";
is :100[10,'.',10], 10.10, "Adverbial form of base 100 fraction works";

# Representation-stressing large radix. Do two tests in one here
# so both 32-bit and 64-bit machines are likely to fail uniformly.
#?rakudo todo "This needs an RT"
is :18446744073709551616[1,1] ~ " " ~ :4294967296[1,1], "18446744073709551617 4294967297", "32bit and 64bit large radix literals work";
}

# What follows are tests that were moved here from t/syntax/numbers/misc.t
Expand Down
10 changes: 9 additions & 1 deletion S03-operators/bit.t
Expand Up @@ -4,7 +4,7 @@ use Test;

# Mostly copied from Perl 5.8.4 s t/op/bop.t

plan 33;
plan 37;

# test the bit operators '&', '|', '^', '+<', and '+>'

Expand Down Expand Up @@ -32,6 +32,12 @@ plan 33;
is +^ 0xdeaddead0000deaddead0000dead, -0xdeaddead0000deaddead0000deae,
'numeric bitwise negation';

# Negative numbers. These really need more tests for bigint vs sized natives
#?rakudo 3 skip 'RT#115966'
is (-5 +& -2),(-6), "logical AND of two negative Int is twos complement";
is (-7 +| -6),(-5), "logical OR of two negative Int is twos complement";
is (-7 +^ -6),( 3), "logical XOR of two negative Int is twos complement";

# string
#?niecza 6 skip 'string bitops'
is( 'a' ~& 'A', 'A', 'string bitwise ~& of "a" and "A"' );
Expand Down Expand Up @@ -61,6 +67,8 @@ plan 33;
is( 32 +> 1, 16, 'shift one bit right' );
is( 257 +< 7, 32896, 'shift seven bits left' );
is( 33023 +> 7, 257, 'shift seven bits right' );
# RT #115958
is (-4..-1 X+> 1..3), (-2,-1,-1,-2,-1 xx 8), "right shift is 2s complement";

is 0xdeaddead0000deaddead0000dead +< 4, 0xdeaddead0000deaddead0000dead0, 'shift bigint 4 bits left';
is 0xdeaddead0000deaddead0000dead +> 4, 0xdeaddead0000deaddead0000dea, 'shift bigint 4 bits right';
Expand Down

0 comments on commit d6fdc05

Please sign in to comment.