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/comprehensive.zigmodified+14-14
Changes to tests/comprehensive.zig
@@ -3,7 +3,7 @@ const Regex = @import("regex").Regex;
33
44test "comprehensive: email-like pattern" {
55 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+");
77 defer regex.deinit();
88
99 try std.testing.expect(try regex.isMatch("user@domain"));
@@ -12,7 +12,7 @@ test "comprehensive: email-like pattern" {
1212
1313test "comprehensive: phone number pattern" {
1414 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+");
1616 defer regex.deinit();
1717
1818 if (try regex.find("Call 555-1234 now")) |match| {
@@ -26,7 +26,7 @@ test "comprehensive: phone number pattern" {
2626
2727test "comprehensive: complex alternation" {
2828 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");
3030 defer regex.deinit();
3131
3232 try std.testing.expect(try regex.isMatch("cat"));
@@ -37,7 +37,7 @@ test "comprehensive: complex alternation" {
3737
3838test "comprehensive: nested grouping" {
3939 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)");
4141 defer regex.deinit();
4242
4343 try std.testing.expect(try regex.isMatch("abc"));
@@ -46,7 +46,7 @@ test "comprehensive: nested grouping" {
4646
4747test "comprehensive: multiple quantifiers" {
4848 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?");
5050 defer regex.deinit();
5151
5252 try std.testing.expect(try regex.isMatch("a"));
@@ -57,7 +57,7 @@ test "comprehensive: multiple quantifiers" {
5757
5858test "comprehensive: start and end anchors" {
5959 const allocator = std.testing.allocator;
60 var regex = try Regex.compile(allocator, "^hello$");
60 var regex = try Regex.compile(allocator, std.testing.io, "^hello$");
6161 defer regex.deinit();
6262
6363 try std.testing.expect(try regex.isMatch("hello"));
@@ -67,7 +67,7 @@ test "comprehensive: start and end anchors" {
6767
6868test "comprehensive: character class ranges" {
6969 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]+");
7171 defer regex.deinit();
7272
7373 if (try regex.find("ABC123xyz")) |match| {
@@ -81,7 +81,7 @@ test "comprehensive: character class ranges" {
8181
8282test "comprehensive: negated character class" {
8383 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]+");
8585 defer regex.deinit();
8686
8787 if (try regex.find("123abc456")) |match| {
@@ -95,7 +95,7 @@ test "comprehensive: negated character class" {
9595
9696test "comprehensive: findAll with multiple matches" {
9797 const allocator = std.testing.allocator;
98 var regex = try Regex.compile(allocator, "\\d+");
98 var regex = try Regex.compile(allocator, std.testing.io, "\\d+");
9999 defer regex.deinit();
100100
101101 const matches = try regex.findAll(allocator, "10 cats and 20 dogs");
@@ -114,7 +114,7 @@ test "comprehensive: findAll with multiple matches" {
114114
115115test "comprehensive: replaceAll multiple occurrences" {
116116 const allocator = std.testing.allocator;
117 var regex = try Regex.compile(allocator, "\\d+");
117 var regex = try Regex.compile(allocator, std.testing.io, "\\d+");
118118 defer regex.deinit();
119119
120120 const result = try regex.replaceAll(allocator, "I have 2 cats and 3 dogs", "many");
@@ -125,7 +125,7 @@ test "comprehensive: replaceAll multiple occurrences" {
125125
126126test "comprehensive: split by whitespace pattern" {
127127 const allocator = std.testing.allocator;
128 var regex = try Regex.compile(allocator, "\\s+");
128 var regex = try Regex.compile(allocator, std.testing.io, "\\s+");
129129 defer regex.deinit();
130130
131131 const parts = try regex.split(allocator, "hello world test");
@@ -139,7 +139,7 @@ test "comprehensive: split by whitespace pattern" {
139139
140140test "comprehensive: dot matches any character" {
141141 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");
143143 defer regex.deinit();
144144
145145 try std.testing.expect(try regex.isMatch("abc"));
@@ -150,7 +150,7 @@ test "comprehensive: dot matches any character" {
150150
151151test "comprehensive: escape special characters" {
152152 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+");
154154 defer regex.deinit();
155155
156156 if (try regex.find("Price: $19.99")) |match| {
@@ -164,7 +164,7 @@ test "comprehensive: escape special characters" {
164164
165165test "comprehensive: word boundary" {
166166 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");
168168 defer regex.deinit();
169169
170170 if (try regex.find("a word here")) |match| {