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 lookahead: 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 "foo" only when followed by "bar" |
| @@ -24,7 +24,7 @@ test "positive lookahead: basic (?=...)" { | ||
| 24 | 24 | |
| 25 | 25 | test "positive lookahead: at end of string" { |
| 26 | 26 | const allocator = std.testing.allocator; |
| 27 | var regex = try Regex.compile(allocator, "foo(?=bar)bar"); | |
| 27 | var regex = try Regex.compile(allocator, std.testing.io, "foo(?=bar)bar"); | |
| 28 | 28 | defer regex.deinit(); |
| 29 | 29 | |
| 30 | 30 | try std.testing.expect(try regex.isMatch("foobar")); |
| @@ -40,7 +40,7 @@ test "positive lookahead: at end of string" { | ||
| 40 | 40 | |
| 41 | 41 | test "positive lookahead: with alternation" { |
| 42 | 42 | const allocator = std.testing.allocator; |
| 43 | var regex = try Regex.compile(allocator, "foo(?=bar|baz)"); | |
| 43 | var regex = try Regex.compile(allocator, std.testing.io, "foo(?=bar|baz)"); | |
| 44 | 44 | defer regex.deinit(); |
| 45 | 45 | |
| 46 | 46 | try std.testing.expect(try regex.isMatch("foobar")); |
| @@ -50,7 +50,7 @@ test "positive lookahead: with alternation" { | ||
| 50 | 50 | |
| 51 | 51 | test "negative lookahead: basic (?!...)" { |
| 52 | 52 | const allocator = std.testing.allocator; |
| 53 | var regex = try Regex.compile(allocator, "foo(?!bar)"); | |
| 53 | var regex = try Regex.compile(allocator, std.testing.io, "foo(?!bar)"); | |
| 54 | 54 | defer regex.deinit(); |
| 55 | 55 | |
| 56 | 56 | // Should match "foo" when NOT followed by "bar" |
| @@ -68,7 +68,7 @@ test "negative lookahead: basic (?!...)" { | ||
| 68 | 68 | |
| 69 | 69 | test "negative lookahead: with character class" { |
| 70 | 70 | const allocator = std.testing.allocator; |
| 71 | var regex = try Regex.compile(allocator, "\\d+(?!\\d)"); | |
| 71 | var regex = try Regex.compile(allocator, std.testing.io, "\\d+(?!\\d)"); | |
| 72 | 72 | defer regex.deinit(); |
| 73 | 73 | |
| 74 | 74 | // Should match digits not followed by another digit |
| @@ -84,7 +84,7 @@ test "negative lookahead: with character class" { | ||
| 84 | 84 | test "multiple lookaheads" { |
| 85 | 85 | const allocator = std.testing.allocator; |
| 86 | 86 | // Password validation: at least one digit AND at least one letter |
| 87 | var regex = try Regex.compile(allocator, "(?=.*\\d)(?=.*[a-z]).+"); | |
| 87 | var regex = try Regex.compile(allocator, std.testing.io, "(?=.*\\d)(?=.*[a-z]).+"); | |
| 88 | 88 | defer regex.deinit(); |
| 89 | 89 | |
| 90 | 90 | try std.testing.expect(try regex.isMatch("abc123")); |
| @@ -95,7 +95,7 @@ test "multiple lookaheads" { | ||
| 95 | 95 | |
| 96 | 96 | test "lookahead in alternation" { |
| 97 | 97 | const allocator = std.testing.allocator; |
| 98 | var regex = try Regex.compile(allocator, "(?=foo)|(?=bar)"); | |
| 98 | var regex = try Regex.compile(allocator, std.testing.io, "(?=foo)|(?=bar)"); | |
| 99 | 99 | defer regex.deinit(); |
| 100 | 100 | |
| 101 | 101 | try std.testing.expect(try regex.isMatch("foo")); |
| @@ -104,7 +104,7 @@ test "lookahead in alternation" { | ||
| 104 | 104 | |
| 105 | 105 | test "lookahead with quantifiers" { |
| 106 | 106 | const allocator = std.testing.allocator; |
| 107 | var regex = try Regex.compile(allocator, "a+(?=b+)"); | |
| 107 | var regex = try Regex.compile(allocator, std.testing.io, "a+(?=b+)"); | |
| 108 | 108 | defer regex.deinit(); |
| 109 | 109 | |
| 110 | 110 | if (try regex.find("aaabbb")) |match| { |
| @@ -118,7 +118,7 @@ test "lookahead with quantifiers" { | ||
| 118 | 118 | |
| 119 | 119 | test "nested lookahead" { |
| 120 | 120 | const allocator = std.testing.allocator; |
| 121 | var regex = try Regex.compile(allocator, "foo(?=bar(?=baz))"); | |
| 121 | var regex = try Regex.compile(allocator, std.testing.io, "foo(?=bar(?=baz))"); | |
| 122 | 122 | defer regex.deinit(); |
| 123 | 123 | |
| 124 | 124 | try std.testing.expect(try regex.isMatch("foobarbaz")); |
| @@ -127,7 +127,7 @@ test "nested lookahead" { | ||
| 127 | 127 | |
| 128 | 128 | test "lookahead: zero-width assertion" { |
| 129 | 129 | const allocator = std.testing.allocator; |
| 130 | var regex = try Regex.compile(allocator, "(?=a)a"); | |
| 130 | var regex = try Regex.compile(allocator, std.testing.io, "(?=a)a"); | |
| 131 | 131 | defer regex.deinit(); |
| 132 | 132 | |
| 133 | 133 | if (try regex.find("a")) |match| { |
| @@ -144,7 +144,7 @@ test "lookahead: zero-width assertion" { | ||
| 144 | 144 | |
| 145 | 145 | test "lookahead with capture groups" { |
| 146 | 146 | const allocator = std.testing.allocator; |
| 147 | var regex = try Regex.compile(allocator, "(\\w+)(?= world)"); | |
| 147 | var regex = try Regex.compile(allocator, std.testing.io, "(\\w+)(?= world)"); | |
| 148 | 148 | defer regex.deinit(); |
| 149 | 149 | |
| 150 | 150 | if (try regex.find("hello world")) |match| { |