1
- # ! nqp
2
- plan (12 );
1
+ # ! nq5
2
+ plan (15 );
3
3
4
4
pir::nqp_bigint_setup__v();
5
5
@@ -8,11 +8,12 @@ my $bi_type := $knowhow.new_type(:name('TestBigInt'), :repr('P6bigint'));
8
8
$ bi_type . HOW . compose($ bi_type );
9
9
sub s ($ x ) { pir::nqp_bigint_to_str__SP($ x ) };
10
10
sub iseq ($ x , $ y ) { nqp ::iseq_I($ x , nqp ::box_i($ y , $ bi_type )) }
11
+ sub box ($ x ) { nqp ::box_i($ x , $ bi_type ) }
11
12
12
- my $ one := nqp ::box_i( 1 , $ bi_type );
13
+ my $ one := box( 1 );
13
14
14
15
my $ b := pir::nqp_bigint_from_str__PPS($ one , ' -123' );
15
- my $ c := nqp ::box_i (-123 , $ bi_type );
16
+ my $ c := box (-123 );
16
17
17
18
ok (s($ b ) eq ' -123' , ' can round-trip negative number (string)' );
18
19
ok (s($ c ) eq ' -123' , ' can round-trip negative number (string) by boxing' );
@@ -23,6 +24,11 @@ ok(iseq(nqp::mul_I($b, $b), 15129,), 'multiplication');
23
24
ok (iseq(nqp ::add_I($ b , $ b ), -246 ,), ' addition' );
24
25
ok (nqp ::iseq_I(nqp ::sub_I($ b , $ b ), nqp ::box_i(0 , $ bi_type )), ' subtraction' );
25
26
ok (nqp ::iseq_I(nqp ::div_I($ b , $ b ), $ one ), ' division' );
27
+
26
28
ok (iseq(nqp ::bitshiftl_I($ one , 3 ), 8 ), ' bitshift left' );
27
29
ok (iseq($ one , 1 ), ' original not modified by bitshift left' );
28
- ok (iseq(nqp ::bitshiftr_I(nqp ::box_i(16 , $ bi_type ), 4 ), 1 ), ' bitshift right' );
30
+ ok (iseq(nqp ::bitshiftr_I(box(16 ), 4 ), 1 ), ' bitshift right' );
31
+
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 and' );
34
+ ok (iseq(nqp ::bitxor_I(box(0xdead ), box(0xbeef )), 0x6042 ), ' bit and' );
0 commit comments