Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add some integer related tests, some pre-fudged. #41

Merged
merged 3 commits into from May 15, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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