Skip to content

Commit d652e27

Browse files
committed
Test nqp::atpos_i, nqp::atpos_n, nqp::atpos_s with negative indexes.
1 parent 12dd2e9 commit d652e27

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

t/nqp/59-nqpop.t

Lines changed: 5 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(254);
5+
plan(257);
66

77
ok( nqp::add_i(5,2) == 7, 'nqp::add_i');
88
ok( nqp::sub_i(5,2) == 3, 'nqp::sub_i');
@@ -321,6 +321,8 @@ ok(nqp::getcomp("noSuchLanguageEver1")[0] eq "compiler1", "nqp::getcomp");
321321
my $b := nqp::list_i(1,2,30.4);
322322
ok(nqp::atpos_i($b,2) == 30, 'atpos_i');
323323

324+
ok(nqp::atpos_i($b, -2) == 2, 'atpos_i with negative index');
325+
324326
ok(nqp::atpos_i($b, 100) == 0, 'nqp::atpos_i ouside of array');
325327

326328

@@ -344,6 +346,7 @@ ok(nqp::getcomp("noSuchLanguageEver1")[0] eq "compiler1", "nqp::getcomp");
344346
my $b := nqp::list_s("A","B","C");
345347
ok(nqp::bindpos_s($b, 2, "D"), 'nqp::bindpos_s');
346348
ok(nqp::atpos_s($b,2) eq "D", 'nqp::atpos_s');
349+
ok(nqp::atpos_s($b, -2) eq "B", 'nqp::atpos_s with negative index');
347350
ok(nqp::isnull_s(nqp::atpos_s($a, 10)), 'nqp::atpos_s with element outside of array');
348351
}
349352

@@ -366,6 +369,7 @@ ok(nqp::getcomp("noSuchLanguageEver1")[0] eq "compiler1", "nqp::getcomp");
366369
nqp::bindpos_n($c, 1, 103.5);
367370
nqp::bindpos_n($c, 0, 101);
368371
ok(nqp::atpos_n($c, 1) == 103.5, 'bindpos_n works');
372+
ok(nqp::atpos_n($c, -1) == 103.5, 'nqp::atpos_n with negative index');
369373
ok(nqp::atpos_n($c, 10) == 0.0, 'atpos_n with element outside of the array');
370374

371375
}

0 commit comments

Comments
 (0)