Skip to content

Commit 68ed28c

Browse files
committed
Fix nqp::cmp_{i|n|s} opcodes, add tests.
1 parent be6433c commit 68ed28c

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

src/PAST/NQP.pir

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,22 +246,23 @@ entry to produce the node to be returned.
246246
maphash['x'] = 'repeat__Ssi'
247247

248248
# relational opcodes
249-
maphash['cmp_i'] = 'cmp_Iii'
249+
maphash['cmp_i'] = 'cmp__Iii'
250250
maphash['iseq_i'] = 'iseq__Iii'
251251
maphash['isne_i'] = 'isne__Iii'
252252
maphash['islt_i'] = 'islt__Iii'
253253
maphash['isle_i'] = 'isle__Iii'
254254
maphash['isgt_i'] = 'isgt__Iii'
255255
maphash['isge_i'] = 'isge__Iii'
256256

257-
maphash['cmp_n'] = 'cmp_Inn'
257+
maphash['cmp_n'] = 'cmp__Inn'
258258
maphash['iseq_n'] = 'iseq__Inn'
259259
maphash['isne_n'] = 'isne__Inn'
260260
maphash['islt_n'] = 'islt__Inn'
261261
maphash['isle_n'] = 'isle__Inn'
262262
maphash['isgt_n'] = 'isgt__Inn'
263263
maphash['isge_n'] = 'isge__Inn'
264264

265+
maphash['cmp_s'] = 'cmp__Iss'
265266
maphash['iseq_s'] = 'iseq__Iss'
266267
maphash['isne_s'] = 'isne__Iss'
267268
maphash['islt_s'] = 'islt__Iss'

t/nqp/59-nqpop.t

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
# Test nqp::op pseudo-functions.
44

5-
plan(71);
5+
plan(80);
66

77

88
ok( nqp::add_i(5,2) == 7, 'nqp::add_i');
@@ -27,6 +27,18 @@ ok( nqp::uc("Don't Panic") eq "DON'T PANIC", 'nqp::upcase');
2727

2828
ok( nqp::iseq_i(2, 2) == 1, 'nqp::iseq_i');
2929

30+
ok( nqp::cmp_i(2, 0) == 1, 'nqp::cmp_i');
31+
ok( nqp::cmp_i(2, 2) == 0, 'nqp::cmp_i');
32+
ok( nqp::cmp_i(2, 5) == -1, 'nqp::cmp_i');
33+
34+
ok( nqp::cmp_n(2.5, 0.5) == 1, 'nqp::cmp_n');
35+
ok( nqp::cmp_n(2.5, 2.5) == 0, 'nqp::cmp_n');
36+
ok( nqp::cmp_n(2.5, 5.0) == -1, 'nqp::cmp_n');
37+
38+
ok( nqp::cmp_s("c", "a") == 1, 'nqp::cmp_s');
39+
ok( nqp::cmp_s("c", "c") == 0, 'nqp::cmp_s');
40+
ok( nqp::cmp_s("c", "e") == -1, 'nqp::cmp_s');
41+
3042
my @array := ['zero', 'one', 'two'];
3143
ok( nqp::elems(@array) == 3, 'nqp::elems');
3244

0 commit comments

Comments
 (0)