also looking at this
Port to latest zig-master
#2
53 files
+1149
-1017
| @@ -3,7 +3,7 @@ const Regex = @import("regex").Regex; | ||
| 3 | 3 | |
| 4 | 4 | test "positive lookbehind: basic (?<=...)" { |
| 5 | 5 | const allocator = std.testing.allocator; |
| 6 | var regex = try Regex.compile(allocator, "(?<=foo)bar"); | |
| 6 | var regex = try Regex.compile(allocator, std.testing.io, "(?<=foo)bar"); | |
| 7 | 7 | defer regex.deinit(); |
| 8 | 8 | |
| 9 | 9 | // Should match "bar" only when preceded by "foo" |
| @@ -25,7 +25,7 @@ test "positive lookbehind: basic (?<=...)" { | ||
| 25 | 25 | |
| 26 | 26 | test "positive lookbehind: at start of pattern" { |
| 27 | 27 | const allocator = std.testing.allocator; |
| 28 | var regex = try Regex.compile(allocator, "(?<=foo)bar"); | |
| 28 | var regex = try Regex.compile(allocator, std.testing.io, "(?<=foo)bar"); | |
| 29 | 29 | defer regex.deinit(); |
| 30 | 30 | |
| 31 | 31 | try std.testing.expect(try regex.isMatch("foobar")); |
| @@ -34,7 +34,7 @@ test "positive lookbehind: at start of pattern" { | ||
| 34 | 34 | |
| 35 | 35 | test "positive lookbehind: with alternation" { |
| 36 | 36 | const allocator = std.testing.allocator; |
| 37 | var regex = try Regex.compile(allocator, "(?<=foo|baz)bar"); | |
| 37 | var regex = try Regex.compile(allocator, std.testing.io, "(?<=foo|baz)bar"); | |
| 38 | 38 | defer regex.deinit(); |
| 39 | 39 | |
| 40 | 40 | try std.testing.expect(try regex.isMatch("foobar")); |
| @@ -44,7 +44,7 @@ test "positive lookbehind: with alternation" { | ||
| 44 | 44 | |
| 45 | 45 | test "negative lookbehind: basic (?<!...)" { |
| 46 | 46 | const allocator = std.testing.allocator; |
| 47 | var regex = try Regex.compile(allocator, "(?<!foo)bar"); | |
| 47 | var regex = try Regex.compile(allocator, std.testing.io, "(?<!foo)bar"); | |
| 48 | 48 | defer regex.deinit(); |
| 49 | 49 | |
| 50 | 50 | // Should match "bar" when NOT preceded by "foo" |
| @@ -62,7 +62,7 @@ test "negative lookbehind: basic (?<!...)" { | ||
| 62 | 62 | |
| 63 | 63 | test "negative lookbehind: at string start" { |
| 64 | 64 | const allocator = std.testing.allocator; |
| 65 | var regex = try Regex.compile(allocator, "(?<!x)bar"); | |
| 65 | var regex = try Regex.compile(allocator, std.testing.io, "(?<!x)bar"); | |
| 66 | 66 | defer regex.deinit(); |
| 67 | 67 | |
| 68 | 68 | // "bar" at start should match (nothing before it, so not preceded by 'x') |
| @@ -78,7 +78,7 @@ test "negative lookbehind: at string start" { | ||
| 78 | 78 | |
| 79 | 79 | test "lookbehind with literal characters" { |
| 80 | 80 | const allocator = std.testing.allocator; |
| 81 | var regex = try Regex.compile(allocator, "(?<=\\$)\\d+"); | |
| 81 | var regex = try Regex.compile(allocator, std.testing.io, "(?<=\\$)\\d+"); | |
| 82 | 82 | defer regex.deinit(); |
| 83 | 83 | |
| 84 | 84 | // Match digits preceded by dollar sign |
| @@ -95,7 +95,7 @@ test "lookbehind with literal characters" { | ||
| 95 | 95 | |
| 96 | 96 | test "lookbehind: zero-width assertion" { |
| 97 | 97 | const allocator = std.testing.allocator; |
| 98 | var regex = try Regex.compile(allocator, "(?<=a)b"); | |
| 98 | var regex = try Regex.compile(allocator, std.testing.io, "(?<=a)b"); | |
| 99 | 99 | defer regex.deinit(); |
| 100 | 100 | |
| 101 | 101 | if (try regex.find("ab")) |match| { |
| @@ -112,7 +112,7 @@ test "lookbehind: zero-width assertion" { | ||
| 112 | 112 | |
| 113 | 113 | test "combined lookahead and lookbehind" { |
| 114 | 114 | const allocator = std.testing.allocator; |
| 115 | var regex = try Regex.compile(allocator, "(?<=foo)bar(?=baz)"); | |
| 115 | var regex = try Regex.compile(allocator, std.testing.io, "(?<=foo)bar(?=baz)"); | |
| 116 | 116 | defer regex.deinit(); |
| 117 | 117 | |
| 118 | 118 | try std.testing.expect(try regex.isMatch("foobarbaz")); |
| @@ -132,7 +132,7 @@ test "combined lookahead and lookbehind" { | ||
| 132 | 132 | |
| 133 | 133 | test "lookbehind with capture groups" { |
| 134 | 134 | const allocator = std.testing.allocator; |
| 135 | var regex = try Regex.compile(allocator, "(?<=@)(\\w+)"); | |
| 135 | var regex = try Regex.compile(allocator, std.testing.io, "(?<=@)(\\w+)"); | |
| 136 | 136 | defer regex.deinit(); |
| 137 | 137 | |
| 138 | 138 | if (try regex.find("@username")) |match| { |
| @@ -148,7 +148,7 @@ test "lookbehind with capture groups" { | ||
| 148 | 148 | |
| 149 | 149 | test "multiple lookbehinds" { |
| 150 | 150 | const allocator = std.testing.allocator; |
| 151 | var regex = try Regex.compile(allocator, "(?<=a)(?<=ab)c"); | |
| 151 | var regex = try Regex.compile(allocator, std.testing.io, "(?<=a)(?<=ab)c"); | |
| 152 | 152 | defer regex.deinit(); |
| 153 | 153 | |
| 154 | 154 | try std.testing.expect(try regex.isMatch("abc")); |
| @@ -157,7 +157,7 @@ test "multiple lookbehinds" { | ||
| 157 | 157 | |
| 158 | 158 | test "lookbehind in findAll" { |
| 159 | 159 | const allocator = std.testing.allocator; |
| 160 | var regex = try Regex.compile(allocator, "(?<=\\s)\\w+"); | |
| 160 | var regex = try Regex.compile(allocator, std.testing.io, "(?<=\\s)\\w+"); | |
| 161 | 161 | defer regex.deinit(); |
| 162 | 162 | |
| 163 | 163 | const matches = try regex.findAll(allocator, "hello world foo bar"); |