Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Tests for the flattened in bigint case.
  • Loading branch information
jnthn committed Nov 8, 2011
1 parent d6c0f7b commit 39c6bcd
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion t/nqp/60-bigint.t
@@ -1,5 +1,7 @@
#! nqp
plan(16);
use nqpmo;

plan(19);

pir::nqp_bigint_setup__v();

Expand Down Expand Up @@ -34,3 +36,18 @@ ok(iseq(nqp::bitor_I( box(0xdead), box(0xbeef)), 0xfeef), 'bit or');
ok(iseq(nqp::bitxor_I(box(0xdead), box(0xbeef)), 0x6042), 'bit xor');

ok(iseq(nqp::bitneg_I(box(-123)), 122), 'bit negation');


# Now we'll create a type that boxes a P6bigint.
my $bi_boxer := $knowhow.new_type(:name('TestPerl6Int'), :repr('P6opaque'));
$bi_boxer.HOW.add_attribute($bi_boxer, NQPAttribute.new(
:name('$!value'), :type($bi_type), :box_target(1)
));
$bi_boxer.HOW.compose($bi_boxer);

# Try some basic operations with it.
my $box_val_1 := nqp::box_i(4, $bi_boxer);
ok(iseq($box_val_1, 4), 'can box to a complex type with a P6bigint target');
my $box_val_2 := pir::nqp_bigint_from_str__PPS($bi_boxer, '38');
ok(iseq($box_val_2, 38), 'can get a bigint from a string with boxing type');
ok(iseq(nqp::add_I($box_val_1, $box_val_2), 42), 'addition works on boxing type');

0 comments on commit 39c6bcd

Please sign in to comment.