ReviewOS

also looking at this

zig-utils/zig-regex

Port to latest zig-master

#2
Closed armagidon-exception wants to merge main into main
53 files +1149 -1017
tests/utf8_unicode.zigmodified+14-14
Changes to tests/utf8_unicode.zig
@@ -5,7 +5,7 @@ const Regex = @import("regex").Regex;
55
66test "UTF-8: literal matching" {
77 const allocator = std.testing.allocator;
8 var regex = try Regex.compile(allocator, "café");
8 var regex = try Regex.compile(allocator, std.testing.io, "café");
99 defer regex.deinit();
1010
1111 try std.testing.expect(try regex.isMatch("café"));
@@ -14,7 +14,7 @@ test "UTF-8: literal matching" {
1414
1515test "UTF-8: emoji matching" {
1616 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");
1818 defer regex.deinit();
1919
2020 try std.testing.expect(try regex.isMatch("Hello 👋 World"));
@@ -22,7 +22,7 @@ test "UTF-8: emoji matching" {
2222
2323test "UTF-8: Chinese characters" {
2424 const allocator = std.testing.allocator;
25 var regex = try Regex.compile(allocator, "你好");
25 var regex = try Regex.compile(allocator, std.testing.io, "你好");
2626 defer regex.deinit();
2727
2828 try std.testing.expect(try regex.isMatch("你好"));
@@ -31,7 +31,7 @@ test "UTF-8: Chinese characters" {
3131
3232test "UTF-8: mixed ASCII and Unicode" {
3333 const allocator = std.testing.allocator;
34 var regex = try Regex.compile(allocator, "test-тест-テスト");
34 var regex = try Regex.compile(allocator, std.testing.io, "test-тест-テスト");
3535 defer regex.deinit();
3636
3737 try std.testing.expect(try regex.isMatch("test-тест-テスト"));
@@ -39,7 +39,7 @@ test "UTF-8: mixed ASCII and Unicode" {
3939
4040test "UTF-8: dot matches multi-byte character" {
4141 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é");
4343 defer regex.deinit();
4444
4545 // Currently . matches one byte, not one character
@@ -49,7 +49,7 @@ test "UTF-8: dot matches multi-byte character" {
4949
5050test "UTF-8: alternation with Unicode" {
5151 const allocator = std.testing.allocator;
52 var regex = try Regex.compile(allocator, "hello|你好|こんにちは");
52 var regex = try Regex.compile(allocator, std.testing.io, "hello|你好|こんにちは");
5353 defer regex.deinit();
5454
5555 try std.testing.expect(try regex.isMatch("hello"));
@@ -60,7 +60,7 @@ test "UTF-8: alternation with Unicode" {
6060test "UTF-8: character class range with multi-byte" {
6161 const allocator = std.testing.allocator;
6262 // 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]+");
6464 defer regex.deinit();
6565
6666 try std.testing.expect(try regex.isMatch("hello"));
@@ -79,7 +79,7 @@ test "UTF-8: character class range with multi-byte" {
7979
8080test "UTF-8: quantifiers with Unicode literals" {
8181 const allocator = std.testing.allocator;
82 var regex = try Regex.compile(allocator, "あ+");
82 var regex = try Regex.compile(allocator, std.testing.io, "あ+");
8383 defer regex.deinit();
8484
8585 try std.testing.expect(try regex.isMatch("あ"));
@@ -88,7 +88,7 @@ test "UTF-8: quantifiers with Unicode literals" {
8888
8989test "UTF-8: capture groups with Unicode" {
9090 const allocator = std.testing.allocator;
91 var regex = try Regex.compile(allocator, "(你好)(世界)");
91 var regex = try Regex.compile(allocator, std.testing.io, "(你好)(世界)");
9292 defer regex.deinit();
9393
9494 const result = try regex.find("你好世界");
@@ -106,7 +106,7 @@ test "UTF-8: capture groups with Unicode" {
106106
107107test "UTF-8: replacement with Unicode" {
108108 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+)");
110110 defer regex.deinit();
111111
112112 // ASCII works
@@ -117,7 +117,7 @@ test "UTF-8: replacement with Unicode" {
117117
118118test "UTF-8: anchors with Unicode" {
119119 const allocator = std.testing.allocator;
120 var regex = try Regex.compile(allocator, "^你好$");
120 var regex = try Regex.compile(allocator, std.testing.io, "^你好$");
121121 defer regex.deinit();
122122
123123 try std.testing.expect(try regex.isMatch("你好"));
@@ -127,7 +127,7 @@ test "UTF-8: anchors with Unicode" {
127127
128128test "UTF-8: non-capturing groups with Unicode" {
129129 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|세계)");
131131 defer regex.deinit();
132132
133133 const result1 = try regex.find("hello world");
@@ -156,7 +156,7 @@ test "UTF-8: non-capturing groups with Unicode" {
156156// Document current limitations
157157test "UTF-8: known limitation - dot is byte-based" {
158158 const allocator = std.testing.allocator;
159 var regex = try Regex.compile(allocator, "^.$");
159 var regex = try Regex.compile(allocator, std.testing.io, "^.$");
160160 defer regex.deinit();
161161
162162 // Single ASCII character
@@ -170,7 +170,7 @@ test "UTF-8: known limitation - dot is byte-based" {
170170
171171test "UTF-8: known limitation - \\w is ASCII-only" {
172172 const allocator = std.testing.allocator;
173 var regex = try Regex.compile(allocator, "\\w+");
173 var regex = try Regex.compile(allocator, std.testing.io, "\\w+");
174174 defer regex.deinit();
175175
176176 // ASCII word characters work