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/lookahead.zigmodified+11-11
Changes to tests/lookahead.zig
@@ -3,7 +3,7 @@ const Regex = @import("regex").Regex;
33
44test "positive lookahead: basic (?=...)" {
55 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)");
77 defer regex.deinit();
88
99 // Should match "foo" only when followed by "bar"
@@ -24,7 +24,7 @@ test "positive lookahead: basic (?=...)" {
2424
2525test "positive lookahead: at end of string" {
2626 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");
2828 defer regex.deinit();
2929
3030 try std.testing.expect(try regex.isMatch("foobar"));
@@ -40,7 +40,7 @@ test "positive lookahead: at end of string" {
4040
4141test "positive lookahead: with alternation" {
4242 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)");
4444 defer regex.deinit();
4545
4646 try std.testing.expect(try regex.isMatch("foobar"));
@@ -50,7 +50,7 @@ test "positive lookahead: with alternation" {
5050
5151test "negative lookahead: basic (?!...)" {
5252 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)");
5454 defer regex.deinit();
5555
5656 // Should match "foo" when NOT followed by "bar"
@@ -68,7 +68,7 @@ test "negative lookahead: basic (?!...)" {
6868
6969test "negative lookahead: with character class" {
7070 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)");
7272 defer regex.deinit();
7373
7474 // Should match digits not followed by another digit
@@ -84,7 +84,7 @@ test "negative lookahead: with character class" {
8484test "multiple lookaheads" {
8585 const allocator = std.testing.allocator;
8686 // 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]).+");
8888 defer regex.deinit();
8989
9090 try std.testing.expect(try regex.isMatch("abc123"));
@@ -95,7 +95,7 @@ test "multiple lookaheads" {
9595
9696test "lookahead in alternation" {
9797 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)");
9999 defer regex.deinit();
100100
101101 try std.testing.expect(try regex.isMatch("foo"));
@@ -104,7 +104,7 @@ test "lookahead in alternation" {
104104
105105test "lookahead with quantifiers" {
106106 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+)");
108108 defer regex.deinit();
109109
110110 if (try regex.find("aaabbb")) |match| {
@@ -118,7 +118,7 @@ test "lookahead with quantifiers" {
118118
119119test "nested lookahead" {
120120 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))");
122122 defer regex.deinit();
123123
124124 try std.testing.expect(try regex.isMatch("foobarbaz"));
@@ -127,7 +127,7 @@ test "nested lookahead" {
127127
128128test "lookahead: zero-width assertion" {
129129 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");
131131 defer regex.deinit();
132132
133133 if (try regex.find("a")) |match| {
@@ -144,7 +144,7 @@ test "lookahead: zero-width assertion" {
144144
145145test "lookahead with capture groups" {
146146 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)");
148148 defer regex.deinit();
149149
150150 if (try regex.find("hello world")) |match| {