Skip to content

Commit a4612e3

Browse files
committed
Add more tests for nqp::index
1 parent fa72a73 commit a4612e3

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

t/nqp/107-index.t

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# string indexing tests.
2+
my int $x := 100;
3+
plan(26 * $x);
4+
# XXX TODO rework this stuff into indexic.t
5+
# If changing this file, also add equivalent changes to moar/xx-indexic.t
6+
my str $abc-string := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';
7+
my int $i := 0;
8+
my str $abc-x-string := nqp::x($abc-string, $x);
9+
while ($i < nqp::chars($abc-x-string)) {
10+
my int $j := $i % nqp::chars($abc-string);
11+
my str $letter := nqp::chr($j + nqp::ord('A'));
12+
is( nqp::index($abc-x-string, $letter, 0), $j, "nqp::index('$abc-string' x $x, '$letter', $j)");
13+
$i++;
14+
}

0 commit comments

Comments
 (0)