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/integration.zigmodified+22-22
Changes to tests/integration.zig
@@ -5,7 +5,7 @@ const Regex = @import("regex").Regex;
55test "integration: email validation - basic pattern" {
66 const allocator = std.testing.allocator;
77 // Simplified email pattern: word@word.word
8 var regex = try Regex.compile(allocator, "\\w+@\\w+\\.\\w+");
8 var regex = try Regex.compile(allocator, std.testing.io, "\\w+@\\w+\\.\\w+");
99 defer regex.deinit();
1010
1111 try std.testing.expect(try regex.isMatch("user@example.com"));
@@ -16,7 +16,7 @@ test "integration: email validation - basic pattern" {
1616
1717test "integration: email validation - extract from text" {
1818 const allocator = std.testing.allocator;
19 var regex = try Regex.compile(allocator, "\\w+@\\w+\\.\\w+");
19 var regex = try Regex.compile(allocator, std.testing.io, "\\w+@\\w+\\.\\w+");
2020 defer regex.deinit();
2121
2222 const text = "Contact support@example.com for help";
@@ -33,7 +33,7 @@ test "integration: email validation - extract from text" {
3333test "integration: URL extraction from text" {
3434 const allocator = std.testing.allocator;
3535 // Simplified: just match http:// or https:// followed by word.word
36 var regex = try Regex.compile(allocator, "https://\\w+\\.\\w+");
36 var regex = try Regex.compile(allocator, std.testing.io, "https://\\w+\\.\\w+");
3737 defer regex.deinit();
3838
3939 const text = "Visit https://example.com for more info.";
@@ -49,7 +49,7 @@ test "integration: URL extraction from text" {
4949// Phone Number Tests
5050test "integration: US phone number validation" {
5151 const allocator = std.testing.allocator;
52 var regex = try Regex.compile(allocator, "^\\d{3}-\\d{3}-\\d{4}$");
52 var regex = try Regex.compile(allocator, std.testing.io, "^\\d{3}-\\d{3}-\\d{4}$");
5353 defer regex.deinit();
5454
5555 try std.testing.expect(try regex.isMatch("555-123-4567"));
@@ -60,7 +60,7 @@ test "integration: US phone number validation" {
6060
6161test "integration: extract phone numbers from text" {
6262 const allocator = std.testing.allocator;
63 var regex = try Regex.compile(allocator, "\\d{3}-\\d{3}-\\d{4}");
63 var regex = try Regex.compile(allocator, std.testing.io, "\\d{3}-\\d{3}-\\d{4}");
6464 defer regex.deinit();
6565
6666 const text = "Call 555-123-4567 or 800-555-9876 for support.";
@@ -81,7 +81,7 @@ test "integration: extract phone numbers from text" {
8181// Date/Time Patterns
8282test "integration: ISO date format" {
8383 const allocator = std.testing.allocator;
84 var regex = try Regex.compile(allocator, "^\\d{4}-\\d{2}-\\d{2}$");
84 var regex = try Regex.compile(allocator, std.testing.io, "^\\d{4}-\\d{2}-\\d{2}$");
8585 defer regex.deinit();
8686
8787 try std.testing.expect(try regex.isMatch("2025-01-26"));
@@ -92,7 +92,7 @@ test "integration: ISO date format" {
9292
9393test "integration: time format HH:MM:SS" {
9494 const allocator = std.testing.allocator;
95 var regex = try Regex.compile(allocator, "^\\d{2}:\\d{2}:\\d{2}$");
95 var regex = try Regex.compile(allocator, std.testing.io, "^\\d{2}:\\d{2}:\\d{2}$");
9696 defer regex.deinit();
9797
9898 try std.testing.expect(try regex.isMatch("14:30:45"));
@@ -106,7 +106,7 @@ test "integration: time format HH:MM:SS" {
106106test "integration: extract log levels" {
107107 const allocator = std.testing.allocator;
108108 // Match INFO specifically (alternation with 4 options seems to cause overflow)
109 var regex = try Regex.compile(allocator, "INFO");
109 var regex = try Regex.compile(allocator, std.testing.io, "INFO");
110110 defer regex.deinit();
111111
112112 try std.testing.expect(try regex.isMatch("[INFO] Application started"));
@@ -115,7 +115,7 @@ test "integration: extract log levels" {
115115
116116test "integration: parse log timestamp and message" {
117117 const allocator = std.testing.allocator;
118 var regex = try Regex.compile(allocator, "\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}");
118 var regex = try Regex.compile(allocator, std.testing.io, "\\d{4}-\\d{2}-\\d{2} \\d{2}:\\d{2}:\\d{2}");
119119 defer regex.deinit();
120120
121121 const log = "[2025-01-26 14:30:45] User login successful";
@@ -132,7 +132,7 @@ test "integration: parse log timestamp and message" {
132132test "integration: IPv4 address matching" {
133133 const allocator = std.testing.allocator;
134134 // Simplified pattern (doesn't validate ranges)
135 var regex = try Regex.compile(allocator, "^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$");
135 var regex = try Regex.compile(allocator, std.testing.io, "^\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$");
136136 defer regex.deinit();
137137
138138 try std.testing.expect(try regex.isMatch("192.168.1.1"));
@@ -145,7 +145,7 @@ test "integration: IPv4 address matching" {
145145test "integration: password strength - minimum length" {
146146 const allocator = std.testing.allocator;
147147 // Check if string has at least 8 characters (simplified - just check length differently)
148 var regex = try Regex.compile(allocator, ".{8}");
148 var regex = try Regex.compile(allocator, std.testing.io, ".{8}");
149149 defer regex.deinit();
150150
151151 try std.testing.expect(try regex.isMatch("password123")); // has 8+ chars
@@ -155,7 +155,7 @@ test "integration: password strength - minimum length" {
155155
156156test "integration: password contains digit" {
157157 const allocator = std.testing.allocator;
158 var regex = try Regex.compile(allocator, "\\d");
158 var regex = try Regex.compile(allocator, std.testing.io, "\\d");
159159 defer regex.deinit();
160160
161161 try std.testing.expect(try regex.isMatch("password1"));
@@ -167,7 +167,7 @@ test "integration: password contains digit" {
167167test "integration: username alphanumeric with underscores" {
168168 const allocator = std.testing.allocator;
169169 // Simplified - removed anchors and large quantifier bound to avoid crash
170 var regex = try Regex.compile(allocator, "[a-zA-Z0-9_]{3}");
170 var regex = try Regex.compile(allocator, std.testing.io, "[a-zA-Z0-9_]{3}");
171171 defer regex.deinit();
172172
173173 try std.testing.expect(try regex.isMatch("user123"));
@@ -179,7 +179,7 @@ test "integration: username alphanumeric with underscores" {
179179// Hashtag Extraction
180180test "integration: extract hashtags from text" {
181181 const allocator = std.testing.allocator;
182 var regex = try Regex.compile(allocator, "#\\w+");
182 var regex = try Regex.compile(allocator, std.testing.io, "#\\w+");
183183 defer regex.deinit();
184184
185185 const tweet = "Loving #Zig programming! #opensource #systems";
@@ -202,7 +202,7 @@ test "integration: extract hashtags from text" {
202202test "integration: match HTML tags" {
203203 const allocator = std.testing.allocator;
204204 // Match opening tags only (no closing tags with /)
205 var regex = try Regex.compile(allocator, "<[a-z]+>");
205 var regex = try Regex.compile(allocator, std.testing.io, "<[a-z]+>");
206206 defer regex.deinit();
207207
208208 const html = "<div>content<span>text";
@@ -223,7 +223,7 @@ test "integration: match HTML tags" {
223223// CSV Parsing
224224test "integration: split CSV line" {
225225 const allocator = std.testing.allocator;
226 var regex = try Regex.compile(allocator, ",");
226 var regex = try Regex.compile(allocator, std.testing.io, ",");
227227 defer regex.deinit();
228228
229229 const csv = "John,Doe,30,Engineer";
@@ -240,7 +240,7 @@ test "integration: split CSV line" {
240240// Whitespace Normalization
241241test "integration: replace multiple spaces with single space" {
242242 const allocator = std.testing.allocator;
243 var regex = try Regex.compile(allocator, "\\s+");
243 var regex = try Regex.compile(allocator, std.testing.io, "\\s+");
244244 defer regex.deinit();
245245
246246 const text = "This has too many spaces";
@@ -254,7 +254,7 @@ test "integration: replace multiple spaces with single space" {
254254test "integration: extract markdown links" {
255255 const allocator = std.testing.allocator;
256256 // Simplified pattern - just find one link
257 var regex = try Regex.compile(allocator, "\\[\\w+\\]\\(https://\\w+\\.\\w+\\)");
257 var regex = try Regex.compile(allocator, std.testing.io, "\\[\\w+\\]\\(https://\\w+\\.\\w+\\)");
258258 defer regex.deinit();
259259
260260 const markdown = "Check [Zig](https://ziglang.org) for more info";
@@ -270,7 +270,7 @@ test "integration: extract markdown links" {
270270// Version Number Extraction
271271test "integration: semver version numbers" {
272272 const allocator = std.testing.allocator;
273 var regex = try Regex.compile(allocator, "\\d+\\.\\d+\\.\\d+");
273 var regex = try Regex.compile(allocator, std.testing.io, "\\d+\\.\\d+\\.\\d+");
274274 defer regex.deinit();
275275
276276 const text = "Version 1.2.3 released. Upgrade from 1.0.0 required.";
@@ -291,7 +291,7 @@ test "integration: semver version numbers" {
291291// Hex Color Codes
292292test "integration: match hex color codes" {
293293 const allocator = std.testing.allocator;
294 var regex = try Regex.compile(allocator, "#[0-9a-fA-F]{6}");
294 var regex = try Regex.compile(allocator, std.testing.io, "#[0-9a-fA-F]{6}");
295295 defer regex.deinit();
296296
297297 const css = "color: #FF5733; background: #FFFFFF;";
@@ -312,7 +312,7 @@ test "integration: match hex color codes" {
312312// Code Comment Extraction
313313test "integration: extract single-line comments" {
314314 const allocator = std.testing.allocator;
315 var regex = try Regex.compile(allocator, "//.*");
315 var regex = try Regex.compile(allocator, std.testing.io, "//.*");
316316 defer regex.deinit();
317317
318318 const code = "const x = 5; // This is a comment";
@@ -328,7 +328,7 @@ test "integration: extract single-line comments" {
328328// Environment Variable Format
329329test "integration: match environment variables" {
330330 const allocator = std.testing.allocator;
331 var regex = try Regex.compile(allocator, "\\$[A-Z_]+");
331 var regex = try Regex.compile(allocator, std.testing.io, "\\$[A-Z_]+");
332332 defer regex.deinit();
333333
334334 const script = "export PATH=$HOME/bin:$PATH";