Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix nqp::cmp_{i|n|s} opcodes, add tests.
  • Loading branch information
pmichaud committed Jun 22, 2011
1 parent be6433c commit 68ed28c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/PAST/NQP.pir
Expand Up @@ -246,22 +246,23 @@ entry to produce the node to be returned.
maphash['x'] = 'repeat__Ssi'

# relational opcodes
maphash['cmp_i'] = 'cmp_Iii'
maphash['cmp_i'] = 'cmp__Iii'
maphash['iseq_i'] = 'iseq__Iii'
maphash['isne_i'] = 'isne__Iii'
maphash['islt_i'] = 'islt__Iii'
maphash['isle_i'] = 'isle__Iii'
maphash['isgt_i'] = 'isgt__Iii'
maphash['isge_i'] = 'isge__Iii'

maphash['cmp_n'] = 'cmp_Inn'
maphash['cmp_n'] = 'cmp__Inn'
maphash['iseq_n'] = 'iseq__Inn'
maphash['isne_n'] = 'isne__Inn'
maphash['islt_n'] = 'islt__Inn'
maphash['isle_n'] = 'isle__Inn'
maphash['isgt_n'] = 'isgt__Inn'
maphash['isge_n'] = 'isge__Inn'

maphash['cmp_s'] = 'cmp__Iss'
maphash['iseq_s'] = 'iseq__Iss'
maphash['isne_s'] = 'isne__Iss'
maphash['islt_s'] = 'islt__Iss'
Expand Down
14 changes: 13 additions & 1 deletion t/nqp/59-nqpop.t
Expand Up @@ -2,7 +2,7 @@

# Test nqp::op pseudo-functions.

plan(71);
plan(80);


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

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

ok( nqp::cmp_i(2, 0) == 1, 'nqp::cmp_i');
ok( nqp::cmp_i(2, 2) == 0, 'nqp::cmp_i');
ok( nqp::cmp_i(2, 5) == -1, 'nqp::cmp_i');

ok( nqp::cmp_n(2.5, 0.5) == 1, 'nqp::cmp_n');
ok( nqp::cmp_n(2.5, 2.5) == 0, 'nqp::cmp_n');
ok( nqp::cmp_n(2.5, 5.0) == -1, 'nqp::cmp_n');

ok( nqp::cmp_s("c", "a") == 1, 'nqp::cmp_s');
ok( nqp::cmp_s("c", "c") == 0, 'nqp::cmp_s');
ok( nqp::cmp_s("c", "e") == -1, 'nqp::cmp_s');

my @array := ['zero', 'one', 'two'];
ok( nqp::elems(@array) == 3, 'nqp::elems');

Expand Down

0 comments on commit 68ed28c

Please sign in to comment.