aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorLouis Pilfold <louis@lpil.uk>2021-08-26 23:13:44 +0100
committerLouis Pilfold <louis@lpil.uk>2021-08-27 00:37:15 +0100
commit6104a3bcc26a05942b8062ae62a0c7b932ca8cf6 (patch)
treed32e8a76a710a33b0d204333343bec5f831f9db2 /test
parent70f065415469c65dd7f66dd4ef3f8e651f16b66a (diff)
downloadgleam_stdlib-6104a3bcc26a05942b8062ae62a0c7b932ca8cf6.tar.gz
gleam_stdlib-6104a3bcc26a05942b8062ae62a0c7b932ca8cf6.zip
Regex scan
Diffstat (limited to 'test')
-rw-r--r--test/gleam/regex_test.gleam48
1 files changed, 19 insertions, 29 deletions
diff --git a/test/gleam/regex_test.gleam b/test/gleam/regex_test.gleam
index 87535a0..5916b63 100644
--- a/test/gleam/regex_test.gleam
+++ b/test/gleam/regex_test.gleam
@@ -46,33 +46,23 @@ pub fn split_test() {
|> should.equal(["foo", "32", "4", "9", "0"])
}
-if erlang {
- pub fn scan_test() {
- assert Ok(re) = regex.from_string("Gl\\w+")
-
- regex.scan(re, "!Gleam")
- |> should.equal([Match(content: "Gleam", byte_index: 1, submatches: [])])
-
- regex.scan(re, "हGleam")
- |> should.equal([Match(content: "Gleam", byte_index: 3, submatches: [])])
-
- regex.scan(re, "𐍈Gleam")
- |> should.equal([Match(content: "Gleam", byte_index: 4, submatches: [])])
-
- assert Ok(re) = regex.from_string("[oi]n a(.?) (\\w+)")
-
- regex.scan(re, "I am on a boat in a lake.")
- |> should.equal([
- Match(
- content: "on a boat",
- byte_index: 5,
- submatches: [None, Some("boat")],
- ),
- Match(
- content: "in a lake",
- byte_index: 15,
- submatches: [None, Some("lake")],
- ),
- ])
- }
+pub fn scan_test() {
+ assert Ok(re) = regex.from_string("Gl\\w+")
+
+ regex.scan(re, "!Gleam")
+ |> should.equal([Match(content: "Gleam", submatches: [])])
+
+ regex.scan(re, "हGleam")
+ |> should.equal([Match(content: "Gleam", submatches: [])])
+
+ regex.scan(re, "𐍈Gleam")
+ |> should.equal([Match(content: "Gleam", submatches: [])])
+
+ assert Ok(re) = regex.from_string("[oi]n a(.?) (\\w+)")
+
+ regex.scan(re, "I am on a boat in a lake.")
+ |> should.equal([
+ Match(content: "on a boat", submatches: [None, Some("boat")]),
+ Match(content: "in a lake", submatches: [None, Some("lake")]),
+ ])
}