From 6104a3bcc26a05942b8062ae62a0c7b932ca8cf6 Mon Sep 17 00:00:00 2001 From: Louis Pilfold Date: Thu, 26 Aug 2021 23:13:44 +0100 Subject: Regex scan --- test/gleam/regex_test.gleam | 48 ++++++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 29 deletions(-) (limited to 'test') 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")]), + ]) } -- cgit v1.2.3