commit e5fffc5c680ec3d91c4b282d7d76da109142db20
parent 54432f7f75d5a6dd6e6c0146df3c4d232cb8b157
Author: Sebastian <sebastian@sebsite.pw>
Date: Sat, 9 Dec 2023 21:14:44 -0500
strings: use type assertion in iter tests
Signed-off-by: Sebastian <sebastian@sebsite.pw>
Diffstat:
1 file changed, 3 insertions(+), 18 deletions(-)
diff --git a/strings/iter.ha b/strings/iter.ha
@@ -86,23 +86,13 @@ export fn slice(begin: *iterator, end: *iterator) str = {
assert(prev(&s) is void);
const expected1 = ['こ', 'ん'];
for (let i = 0z; i < len(expected1); i += 1) {
- match (next(&s)) {
- case let r: rune =>
- assert(r == expected1[i]);
- case void =>
- abort();
- };
+ assert(next(&s) as rune == expected1[i]);
};
assert(iterstr(&s) == "にちは");
assert(prev(&s) as rune == 'ん');
const expected2 = ['ん', 'に', 'ち', 'は'];
for (let i = 0z; i < len(expected2); i += 1) {
- match (next(&s)) {
- case let r: rune =>
- assert(r == expected2[i]);
- case void =>
- abort();
- };
+ assert(next(&s) as rune == expected2[i]);
};
assert(next(&s) is void);
assert(next(&s) is void);
@@ -111,12 +101,7 @@ export fn slice(begin: *iterator, end: *iterator) str = {
s = riter("にちは");
const expected3 = ['は', 'ち', 'に'];
for (let i = 0z; i < len(expected3); i += 1) {
- match (next(&s)) {
- case let r: rune =>
- assert(r == expected3[i]);
- case void =>
- abort();
- };
+ assert(next(&s) as rune == expected3[i]);
};
assert(next(&s) is void);
assert(prev(&s) as rune == 'に');