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 "comprehensive: email-like pattern" { |
| 5 | 5 | const allocator = std.testing.allocator; |
| 6 | var regex = try Regex.compile(allocator, "\\w+@\\w+"); | |
| 6 | var regex = try Regex.compile(allocator, std.testing.io, "\\w+@\\w+"); | |
| 7 | 7 | defer regex.deinit(); |
| 8 | 8 | |
| 9 | 9 | try std.testing.expect(try regex.isMatch("user@domain")); |
| @@ -12,7 +12,7 @@ test "comprehensive: email-like pattern" { | ||
| 12 | 12 | |
| 13 | 13 | test "comprehensive: phone number pattern" { |
| 14 | 14 | const allocator = std.testing.allocator; |
| 15 | var regex = try Regex.compile(allocator, "\\d+-\\d+"); | |
| 15 | var regex = try Regex.compile(allocator, std.testing.io, "\\d+-\\d+"); | |
| 16 | 16 | defer regex.deinit(); |
| 17 | 17 | |
| 18 | 18 | if (try regex.find("Call 555-1234 now")) |match| { |
| @@ -26,7 +26,7 @@ test "comprehensive: phone number pattern" { | ||
| 26 | 26 | |
| 27 | 27 | test "comprehensive: complex alternation" { |
| 28 | 28 | const allocator = std.testing.allocator; |
| 29 | var regex = try Regex.compile(allocator, "cat|dog|bird"); | |
| 29 | var regex = try Regex.compile(allocator, std.testing.io, "cat|dog|bird"); | |
| 30 | 30 | defer regex.deinit(); |
| 31 | 31 | |
| 32 | 32 | try std.testing.expect(try regex.isMatch("cat")); |
| @@ -37,7 +37,7 @@ test "comprehensive: complex alternation" { | ||
| 37 | 37 | |
| 38 | 38 | test "comprehensive: nested grouping" { |
| 39 | 39 | const allocator = std.testing.allocator; |
| 40 | var regex = try Regex.compile(allocator, "(a(b)c)"); | |
| 40 | var regex = try Regex.compile(allocator, std.testing.io, "(a(b)c)"); | |
| 41 | 41 | defer regex.deinit(); |
| 42 | 42 | |
| 43 | 43 | try std.testing.expect(try regex.isMatch("abc")); |
| @@ -46,7 +46,7 @@ test "comprehensive: nested grouping" { | ||
| 46 | 46 | |
| 47 | 47 | test "comprehensive: multiple quantifiers" { |
| 48 | 48 | const allocator = std.testing.allocator; |
| 49 | var regex = try Regex.compile(allocator, "a+b*c?"); | |
| 49 | var regex = try Regex.compile(allocator, std.testing.io, "a+b*c?"); | |
| 50 | 50 | defer regex.deinit(); |
| 51 | 51 | |
| 52 | 52 | try std.testing.expect(try regex.isMatch("a")); |
| @@ -57,7 +57,7 @@ test "comprehensive: multiple quantifiers" { | ||
| 57 | 57 | |
| 58 | 58 | test "comprehensive: start and end anchors" { |
| 59 | 59 | const allocator = std.testing.allocator; |
| 60 | var regex = try Regex.compile(allocator, "^hello$"); | |
| 60 | var regex = try Regex.compile(allocator, std.testing.io, "^hello$"); | |
| 61 | 61 | defer regex.deinit(); |
| 62 | 62 | |
| 63 | 63 | try std.testing.expect(try regex.isMatch("hello")); |
| @@ -67,7 +67,7 @@ test "comprehensive: start and end anchors" { | ||
| 67 | 67 | |
| 68 | 68 | test "comprehensive: character class ranges" { |
| 69 | 69 | const allocator = std.testing.allocator; |
| 70 | var regex = try Regex.compile(allocator, "[a-z]+"); | |
| 70 | var regex = try Regex.compile(allocator, std.testing.io, "[a-z]+"); | |
| 71 | 71 | defer regex.deinit(); |
| 72 | 72 | |
| 73 | 73 | if (try regex.find("ABC123xyz")) |match| { |
| @@ -81,7 +81,7 @@ test "comprehensive: character class ranges" { | ||
| 81 | 81 | |
| 82 | 82 | test "comprehensive: negated character class" { |
| 83 | 83 | const allocator = std.testing.allocator; |
| 84 | var regex = try Regex.compile(allocator, "[^0-9]+"); | |
| 84 | var regex = try Regex.compile(allocator, std.testing.io, "[^0-9]+"); | |
| 85 | 85 | defer regex.deinit(); |
| 86 | 86 | |
| 87 | 87 | if (try regex.find("123abc456")) |match| { |
| @@ -95,7 +95,7 @@ test "comprehensive: negated character class" { | ||
| 95 | 95 | |
| 96 | 96 | test "comprehensive: findAll with multiple matches" { |
| 97 | 97 | const allocator = std.testing.allocator; |
| 98 | var regex = try Regex.compile(allocator, "\\d+"); | |
| 98 | var regex = try Regex.compile(allocator, std.testing.io, "\\d+"); | |
| 99 | 99 | defer regex.deinit(); |
| 100 | 100 | |
| 101 | 101 | const matches = try regex.findAll(allocator, "10 cats and 20 dogs"); |
| @@ -114,7 +114,7 @@ test "comprehensive: findAll with multiple matches" { | ||
| 114 | 114 | |
| 115 | 115 | test "comprehensive: replaceAll multiple occurrences" { |
| 116 | 116 | const allocator = std.testing.allocator; |
| 117 | var regex = try Regex.compile(allocator, "\\d+"); | |
| 117 | var regex = try Regex.compile(allocator, std.testing.io, "\\d+"); | |
| 118 | 118 | defer regex.deinit(); |
| 119 | 119 | |
| 120 | 120 | const result = try regex.replaceAll(allocator, "I have 2 cats and 3 dogs", "many"); |
| @@ -125,7 +125,7 @@ test "comprehensive: replaceAll multiple occurrences" { | ||
| 125 | 125 | |
| 126 | 126 | test "comprehensive: split by whitespace pattern" { |
| 127 | 127 | const allocator = std.testing.allocator; |
| 128 | var regex = try Regex.compile(allocator, "\\s+"); | |
| 128 | var regex = try Regex.compile(allocator, std.testing.io, "\\s+"); | |
| 129 | 129 | defer regex.deinit(); |
| 130 | 130 | |
| 131 | 131 | const parts = try regex.split(allocator, "hello world test"); |
| @@ -139,7 +139,7 @@ test "comprehensive: split by whitespace pattern" { | ||
| 139 | 139 | |
| 140 | 140 | test "comprehensive: dot matches any character" { |
| 141 | 141 | const allocator = std.testing.allocator; |
| 142 | var regex = try Regex.compile(allocator, "a.c"); | |
| 142 | var regex = try Regex.compile(allocator, std.testing.io, "a.c"); | |
| 143 | 143 | defer regex.deinit(); |
| 144 | 144 | |
| 145 | 145 | try std.testing.expect(try regex.isMatch("abc")); |
| @@ -150,7 +150,7 @@ test "comprehensive: dot matches any character" { | ||
| 150 | 150 | |
| 151 | 151 | test "comprehensive: escape special characters" { |
| 152 | 152 | const allocator = std.testing.allocator; |
| 153 | var regex = try Regex.compile(allocator, "\\$\\d+\\.\\d+"); | |
| 153 | var regex = try Regex.compile(allocator, std.testing.io, "\\$\\d+\\.\\d+"); | |
| 154 | 154 | defer regex.deinit(); |
| 155 | 155 | |
| 156 | 156 | if (try regex.find("Price: $19.99")) |match| { |
| @@ -164,7 +164,7 @@ test "comprehensive: escape special characters" { | ||
| 164 | 164 | |
| 165 | 165 | test "comprehensive: word boundary" { |
| 166 | 166 | const allocator = std.testing.allocator; |
| 167 | var regex = try Regex.compile(allocator, "\\bword\\b"); | |
| 167 | var regex = try Regex.compile(allocator, std.testing.io, "\\bword\\b"); | |
| 168 | 168 | defer regex.deinit(); |
| 169 | 169 | |
| 170 | 170 | if (try regex.find("a word here")) |match| { |