Skip to content

Commit d1f3d30

Browse files
committed
Add string processing test cases with pattern matching
1 parent 1d483fd commit d1f3d30

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

string/string_test.mbt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -579,3 +579,25 @@ test "length_eq" {
579579
assert_true!(str.length_eq(8))
580580
assert_false!(str.length_eq(9))
581581
}
582+
583+
///|
584+
test {
585+
enum Token {
586+
True
587+
False
588+
Other
589+
} derive(Show)
590+
fn process_string(s : String) {
591+
match s {
592+
[.."true", ..] => True
593+
[.."false", ..] => False
594+
_ => Other
595+
}
596+
}
597+
598+
inspect!(process_string("truexx"), content="True")
599+
// more tests
600+
inspect!(process_string("false xx"), content="False")
601+
inspect!(process_string("true"), content="True")
602+
inspect!(process_string(""), content="Other")
603+
}

0 commit comments

Comments
 (0)