Skip to content

Commit e05dc77

Browse files
committed
adapt tests to new bigint usage
1 parent 8266846 commit e05dc77

File tree

1 file changed

+20
-20
lines changed

1 file changed

+20
-20
lines changed

t/nqp/60-bigint.t

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -12,28 +12,28 @@ sub box($x) { nqp::box_i($x, $bi_type) }
1212

1313
my $one := box(1);
1414

15-
my $b := pir::nqp_bigint_from_str__PPS($one, '-123');
15+
my $b := pir::nqp_bigint_from_str__PSP('-123', $one);
1616
my $c := box(-123);
1717

1818
ok(str($b) eq '-123', 'can round-trip negative number (string)');
1919
ok(str($c) eq '-123', 'can round-trip negative number (string) by boxing');
2020
ok(nqp::unbox_i($b) == -123, 'can round-trip negative number by unboxing');
2121
ok(!nqp::iseq_I($one, $b), 'nqp::iseq_I can return false');
2222
ok(nqp::iseq_I($one, $one), 'nqp::iseq_I can return true');
23-
ok(iseq(nqp::mul_I($b, $b), 15129,), 'multiplication');
24-
ok(iseq(nqp::add_I($b, $b), -246,), 'addition');
25-
ok(nqp::iseq_I(nqp::sub_I($b, $b), nqp::box_i(0, $bi_type)), 'subtraction');
26-
ok(nqp::iseq_I(nqp::div_I($b, $b), $one), 'division');
23+
ok(iseq(nqp::mul_I($b, $b, $b), 15129,), 'multiplication');
24+
ok(iseq(nqp::add_I($b, $b, $b), -246,), 'addition');
25+
ok(nqp::iseq_I(nqp::sub_I($b, $b, $b), nqp::box_i(0, $bi_type)), 'subtraction');
26+
ok(nqp::iseq_I(nqp::div_I($b, $b, $b), $one), 'division');
2727

28-
ok(iseq(nqp::bitshiftl_I($one, 3), 8), 'bitshift left');
28+
ok(iseq(nqp::bitshiftl_I($one, 3, $one), 8), 'bitshift left');
2929
ok(iseq($one, 1), 'original not modified by bitshift left');
30-
ok(iseq(nqp::bitshiftr_I(box(16), 4), 1), 'bitshift right');
30+
ok(iseq(nqp::bitshiftr_I(box(16), 4, $one), 1), 'bitshift right');
3131

32-
ok(iseq(nqp::bitand_I(box(0xdead), box(0xbeef)), 0x9ead), 'bit and');
33-
ok(iseq(nqp::bitor_I( box(0xdead), box(0xbeef)), 0xfeef), 'bit or');
34-
ok(iseq(nqp::bitxor_I(box(0xdead), box(0xbeef)), 0x6042), 'bit xor');
32+
ok(iseq(nqp::bitand_I(box(0xdead), box(0xbeef), $one), 0x9ead), 'bit and');
33+
ok(iseq(nqp::bitor_I( box(0xdead), box(0xbeef), $one), 0xfeef), 'bit or');
34+
ok(iseq(nqp::bitxor_I(box(0xdead), box(0xbeef), $one), 0x6042), 'bit xor');
3535

36-
ok(iseq(nqp::bitneg_I(box(-123)), 122), 'bit negation');
36+
ok(iseq(nqp::bitneg_I(box(-123), $one), 122), 'bit negation');
3737

3838

3939
# Now we'll create a type that boxes a P6bigint.
@@ -46,33 +46,33 @@ $bi_boxer.HOW.compose($bi_boxer);
4646
# Try some basic operations with it.
4747
my $box_val_1 := nqp::box_i(4, $bi_boxer);
4848
ok(iseq($box_val_1, 4), 'can box to a complex type with a P6bigint target');
49-
my $box_val_2 := pir::nqp_bigint_from_str__PPS($bi_boxer, '38');
49+
my $box_val_2 := pir::nqp_bigint_from_str__PSP('38', $bi_boxer);
5050
ok(iseq($box_val_2, 38), 'can get a bigint from a string with boxing type');
51-
ok(iseq(nqp::add_I($box_val_1, $box_val_2), 42), 'addition works on boxing type');
51+
ok(iseq(nqp::add_I($box_val_1, $box_val_2, $bi_boxer), 42), 'addition works on boxing type');
5252

5353

5454
# Note that the last argument to pow_I should be capable of boxing a num,
5555
# so $bi_type is wrong here. But so far we only test the integer case,
5656
# so we can get away with it.
57-
my $big := nqp::pow_I($c, box(42), $bi_type);
57+
my $big := nqp::pow_I($c, box(42), $bi_type, $bi_type);
5858
ok(str($big) eq '5970554685064519004265641008828923248442340700473500698131071806779372733915289638628729', 'pow (int, positive)');
59-
ok(iseq(nqp::pow_I(box(0), $big, $bi_type), 0), 'pow 0 ** large_number');
60-
ok(iseq(nqp::pow_I($one, $big, $bi_type), 1), 'pow 1 ** large_number');
59+
ok(iseq(nqp::pow_I(box(0), $big, $bi_type, $bi_type), 0), 'pow 0 ** large_number');
60+
ok(iseq(nqp::pow_I($one, $big, $bi_type, $bi_type), 1), 'pow 1 ** large_number');
6161

6262
# test conversion to float
6363
# try it with 2 ** 100, because that's big enough not to fit into a single
6464
# int, but can be represented exactly in a double
65-
$big := nqp::pow_I(box(2), box(100), $bi_type);
65+
$big := nqp::pow_I(box(2), box(100), $bi_type, $bi_type);
6666
ok(nqp::iseq_n(nqp::tonum_I($big), nqp::pow_n(2, 100)), '2**100 to float');
67-
$big := nqp::pow_I(box(-2), box(101), $bi_type);
67+
$big := nqp::pow_I(box(-2), box(101), $bi_type, $bi_type);
6868
ok(nqp::iseq_n(nqp::tonum_I($big), nqp::pow_n(-2, 101)), '(-2)**101 to float');
6969
# the mantissa can hold much information accurately, so test that too
7070
my $factor := 123456789;
71-
$big := nqp::mul_I($big, box($factor));
71+
$big := nqp::mul_I($big, box($factor), $bi_type);
7272
ok(nqp::iseq_n(nqp::tonum_I($big), nqp::mul_n($factor, nqp::pow_n(-2, 101))), "$factor * (-2)**101 to float");
7373

7474
$big := 1e16;
75-
my $converted := nqp::tonum_I(nqp::fromstr_I($bi_type, '10000000000000000'));
75+
my $converted := nqp::tonum_I(nqp::fromstr_I('10000000000000000', $bi_type));
7676
ok(nqp::abs_n($big - $converted) / $big < 1e-4, 'bigint -> float, 1e16');
7777

7878
my $float := 123456789e240;

0 commit comments

Comments
 (0)