Skip to content

Commit 95a7aca

Browse files
committed
Fix assumption Str.ords.iterator always…
…offers .count-only/.bool-only optimization methods.
1 parent 4adee51 commit 95a7aca

File tree

1 file changed

+5
-34
lines changed

1 file changed

+5
-34
lines changed

S32-str/ords.t

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
use v6;
2+
use lib $?FILE.IO.parent(2).add: 'packages';
23
use Test;
4+
use Test::Util;
35
plan 9;
46

57
# L<S32::Str/Str/ords>
@@ -18,7 +20,7 @@ is ".\x[301]".ords, (46, 769), 'ords does not lose NFG synthetics (method)';
1820

1921
# https://github.com/rakudo/rakudo/commit/8b7385d810
2022
subtest 'optimization coverage' => {
21-
plan 7;
23+
plan 4;
2224
my $s := "e\x[308]abc";
2325
my @ords := 235, 97, 98, 99;
2426

@@ -27,37 +29,6 @@ subtest 'optimization coverage' => {
2729
is-deeply @target-s, [@ords], '.push-all (has chars)';
2830
is-deeply @target-e, [], '.push-all (no chars)';
2931

30-
is-deeply +$s.ords, 4, '.count-only (has chars)';
31-
is-deeply +"".ords, 0, '.count-only (no chars)';
32-
is-deeply ?$s.ords, True, '.bool-only (has chars)';
33-
is-deeply ?"".ords, False, '.bool-only (no chars)';
34-
35-
with $s.ords.iterator -> \iter {
36-
subtest 'partially-iterated iterator' => {
37-
plan 17;
38-
39-
is-deeply iter.count-only, 4, 'count (1)';
40-
is-deeply iter.bool-only, True, 'bool (1)';
41-
42-
is-deeply iter.pull-one, @ords[0], 'char (2)';
43-
is-deeply iter.count-only, 3, 'count (2)';
44-
is-deeply iter.bool-only, True, 'bool (2)';
45-
46-
is-deeply iter.pull-one, @ords[1], 'char (3)';
47-
is-deeply iter.count-only, 2, 'count (3)';
48-
is-deeply iter.bool-only, True, 'bool (3)';
49-
50-
is-deeply iter.pull-one, @ords[2], 'char (4)';
51-
is-deeply iter.count-only, 1, 'count (4)';
52-
is-deeply iter.bool-only, True, 'bool (4)';
53-
54-
is-deeply iter.pull-one, @ords[3], 'char (5)';
55-
is-deeply iter.count-only, 0, 'count (5)';
56-
is-deeply iter.bool-only, False, 'bool (5)';
57-
58-
ok iter.pull-one =:= IterationEnd, 'char (6)';
59-
is-deeply iter.count-only, 0, 'count (6)';
60-
is-deeply iter.bool-only, False, 'bool (6)';
61-
}
62-
}
32+
test-iter-opt $s.ords.iterator, @ords, 'has chars';
33+
test-iter-opt "".ords.iterator, (), 'no chars';
6334
}

0 commit comments

Comments
 (0)