also looking at this
Port to latest zig-master
#2
53 files
+1149
-1017
| @@ -5,7 +5,7 @@ const Regex = @import("regex").Regex; | ||
| 5 | 5 | |
| 6 | 6 | test "UTF-8: literal matching" { |
| 7 | 7 | const allocator = std.testing.allocator; |
| 8 | var regex = try Regex.compile(allocator, "café"); | |
| 8 | var regex = try Regex.compile(allocator, std.testing.io, "café"); | |
| 9 | 9 | defer regex.deinit(); |
| 10 | 10 | |
| 11 | 11 | try std.testing.expect(try regex.isMatch("café")); |
| @@ -14,7 +14,7 @@ test "UTF-8: literal matching" { | ||
| 14 | 14 | |
| 15 | 15 | test "UTF-8: emoji matching" { |
| 16 | 16 | const allocator = std.testing.allocator; |
| 17 | var regex = try Regex.compile(allocator, "Hello 👋 World"); | |
| 17 | var regex = try Regex.compile(allocator, std.testing.io, "Hello 👋 World"); | |
| 18 | 18 | defer regex.deinit(); |
| 19 | 19 | |
| 20 | 20 | try std.testing.expect(try regex.isMatch("Hello 👋 World")); |
| @@ -22,7 +22,7 @@ test "UTF-8: emoji matching" { | ||
| 22 | 22 | |
| 23 | 23 | test "UTF-8: Chinese characters" { |
| 24 | 24 | const allocator = std.testing.allocator; |
| 25 | var regex = try Regex.compile(allocator, "你好"); | |
| 25 | var regex = try Regex.compile(allocator, std.testing.io, "你好"); | |
| 26 | 26 | defer regex.deinit(); |
| 27 | 27 | |
| 28 | 28 | try std.testing.expect(try regex.isMatch("你好")); |
| @@ -31,7 +31,7 @@ test "UTF-8: Chinese characters" { | ||
| 31 | 31 | |
| 32 | 32 | test "UTF-8: mixed ASCII and Unicode" { |
| 33 | 33 | const allocator = std.testing.allocator; |
| 34 | var regex = try Regex.compile(allocator, "test-тест-テスト"); | |
| 34 | var regex = try Regex.compile(allocator, std.testing.io, "test-тест-テスト"); | |
| 35 | 35 | defer regex.deinit(); |
| 36 | 36 | |
| 37 | 37 | try std.testing.expect(try regex.isMatch("test-тест-テスト")); |
| @@ -39,7 +39,7 @@ test "UTF-8: mixed ASCII and Unicode" { | ||
| 39 | 39 | |
| 40 | 40 | test "UTF-8: dot matches multi-byte character" { |
| 41 | 41 | const allocator = std.testing.allocator; |
| 42 | var regex = try Regex.compile(allocator, "c.fé"); | |
| 42 | var regex = try Regex.compile(allocator, std.testing.io, "c.fé"); | |
| 43 | 43 | defer regex.deinit(); |
| 44 | 44 | |
| 45 | 45 | // Currently . matches one byte, not one character |
| @@ -49,7 +49,7 @@ test "UTF-8: dot matches multi-byte character" { | ||
| 49 | 49 | |
| 50 | 50 | test "UTF-8: alternation with Unicode" { |
| 51 | 51 | const allocator = std.testing.allocator; |
| 52 | var regex = try Regex.compile(allocator, "hello|你好|こんにちは"); | |
| 52 | var regex = try Regex.compile(allocator, std.testing.io, "hello|你好|こんにちは"); | |
| 53 | 53 | defer regex.deinit(); |
| 54 | 54 | |
| 55 | 55 | try std.testing.expect(try regex.isMatch("hello")); |
| @@ -60,7 +60,7 @@ test "UTF-8: alternation with Unicode" { | ||
| 60 | 60 | test "UTF-8: character class range with multi-byte" { |
| 61 | 61 | const allocator = std.testing.allocator; |
| 62 | 62 | // Character classes currently only work with single-byte ASCII |
| 63 | var regex = try Regex.compile(allocator, "[a-z]+"); | |
| 63 | var regex = try Regex.compile(allocator, std.testing.io, "[a-z]+"); | |
| 64 | 64 | defer regex.deinit(); |
| 65 | 65 | |
| 66 | 66 | try std.testing.expect(try regex.isMatch("hello")); |
| @@ -79,7 +79,7 @@ test "UTF-8: character class range with multi-byte" { | ||
| 79 | 79 | |
| 80 | 80 | test "UTF-8: quantifiers with Unicode literals" { |
| 81 | 81 | const allocator = std.testing.allocator; |
| 82 | var regex = try Regex.compile(allocator, "あ+"); | |
| 82 | var regex = try Regex.compile(allocator, std.testing.io, "あ+"); | |
| 83 | 83 | defer regex.deinit(); |
| 84 | 84 | |
| 85 | 85 | try std.testing.expect(try regex.isMatch("あ")); |
| @@ -88,7 +88,7 @@ test "UTF-8: quantifiers with Unicode literals" { | ||
| 88 | 88 | |
| 89 | 89 | test "UTF-8: capture groups with Unicode" { |
| 90 | 90 | const allocator = std.testing.allocator; |
| 91 | var regex = try Regex.compile(allocator, "(你好)(世界)"); | |
| 91 | var regex = try Regex.compile(allocator, std.testing.io, "(你好)(世界)"); | |
| 92 | 92 | defer regex.deinit(); |
| 93 | 93 | |
| 94 | 94 | const result = try regex.find("你好世界"); |
| @@ -106,7 +106,7 @@ test "UTF-8: capture groups with Unicode" { | ||
| 106 | 106 | |
| 107 | 107 | test "UTF-8: replacement with Unicode" { |
| 108 | 108 | const allocator = std.testing.allocator; |
| 109 | var regex = try Regex.compile(allocator, "(\\w+)@(\\w+)"); | |
| 109 | var regex = try Regex.compile(allocator, std.testing.io, "(\\w+)@(\\w+)"); | |
| 110 | 110 | defer regex.deinit(); |
| 111 | 111 | |
| 112 | 112 | // ASCII works |
| @@ -117,7 +117,7 @@ test "UTF-8: replacement with Unicode" { | ||
| 117 | 117 | |
| 118 | 118 | test "UTF-8: anchors with Unicode" { |
| 119 | 119 | const allocator = std.testing.allocator; |
| 120 | var regex = try Regex.compile(allocator, "^你好$"); | |
| 120 | var regex = try Regex.compile(allocator, std.testing.io, "^你好$"); | |
| 121 | 121 | defer regex.deinit(); |
| 122 | 122 | |
| 123 | 123 | try std.testing.expect(try regex.isMatch("你好")); |
| @@ -127,7 +127,7 @@ test "UTF-8: anchors with Unicode" { | ||
| 127 | 127 | |
| 128 | 128 | test "UTF-8: non-capturing groups with Unicode" { |
| 129 | 129 | const allocator = std.testing.allocator; |
| 130 | var regex = try Regex.compile(allocator, "(?:안녕|hello) (world|세계)"); | |
| 130 | var regex = try Regex.compile(allocator, std.testing.io, "(?:안녕|hello) (world|세계)"); | |
| 131 | 131 | defer regex.deinit(); |
| 132 | 132 | |
| 133 | 133 | const result1 = try regex.find("hello world"); |
| @@ -156,7 +156,7 @@ test "UTF-8: non-capturing groups with Unicode" { | ||
| 156 | 156 | // Document current limitations |
| 157 | 157 | test "UTF-8: known limitation - dot is byte-based" { |
| 158 | 158 | const allocator = std.testing.allocator; |
| 159 | var regex = try Regex.compile(allocator, "^.$"); | |
| 159 | var regex = try Regex.compile(allocator, std.testing.io, "^.$"); | |
| 160 | 160 | defer regex.deinit(); |
| 161 | 161 | |
| 162 | 162 | // Single ASCII character |
| @@ -170,7 +170,7 @@ test "UTF-8: known limitation - dot is byte-based" { | ||
| 170 | 170 | |
| 171 | 171 | test "UTF-8: known limitation - \\w is ASCII-only" { |
| 172 | 172 | const allocator = std.testing.allocator; |
| 173 | var regex = try Regex.compile(allocator, "\\w+"); | |
| 173 | var regex = try Regex.compile(allocator, std.testing.io, "\\w+"); | |
| 174 | 174 | defer regex.deinit(); |
| 175 | 175 | |
| 176 | 176 | // ASCII word characters work |