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 "posix: [:alpha:] matches letters" { |
| 7 | 7 | const allocator = std.testing.allocator; |
| 8 | var regex = try Regex.compile(allocator, "[[:alpha:]]+"); | |
| 8 | var regex = try Regex.compile(allocator, std.testing.io, "[[:alpha:]]+"); | |
| 9 | 9 | defer regex.deinit(); |
| 10 | 10 | |
| 11 | 11 | try std.testing.expect(try regex.isMatch("hello")); |
| @@ -17,7 +17,7 @@ test "posix: [:alpha:] matches letters" { | ||
| 17 | 17 | |
| 18 | 18 | test "posix: [:digit:] matches digits" { |
| 19 | 19 | const allocator = std.testing.allocator; |
| 20 | var regex = try Regex.compile(allocator, "[[:digit:]]+"); | |
| 20 | var regex = try Regex.compile(allocator, std.testing.io, "[[:digit:]]+"); | |
| 21 | 21 | defer regex.deinit(); |
| 22 | 22 | |
| 23 | 23 | try std.testing.expect(try regex.isMatch("123")); |
| @@ -29,7 +29,7 @@ test "posix: [:digit:] matches digits" { | ||
| 29 | 29 | |
| 30 | 30 | test "posix: [:alnum:] matches alphanumeric" { |
| 31 | 31 | const allocator = std.testing.allocator; |
| 32 | var regex = try Regex.compile(allocator, "[[:alnum:]]+"); | |
| 32 | var regex = try Regex.compile(allocator, std.testing.io, "[[:alnum:]]+"); | |
| 33 | 33 | defer regex.deinit(); |
| 34 | 34 | |
| 35 | 35 | try std.testing.expect(try regex.isMatch("hello123")); |
| @@ -41,7 +41,7 @@ test "posix: [:alnum:] matches alphanumeric" { | ||
| 41 | 41 | |
| 42 | 42 | test "posix: [:space:] matches whitespace" { |
| 43 | 43 | const allocator = std.testing.allocator; |
| 44 | var regex = try Regex.compile(allocator, "[[:space:]]+"); | |
| 44 | var regex = try Regex.compile(allocator, std.testing.io, "[[:space:]]+"); | |
| 45 | 45 | defer regex.deinit(); |
| 46 | 46 | |
| 47 | 47 | try std.testing.expect(try regex.isMatch(" ")); |
| @@ -53,7 +53,7 @@ test "posix: [:space:] matches whitespace" { | ||
| 53 | 53 | |
| 54 | 54 | test "posix: [:upper:] matches uppercase" { |
| 55 | 55 | const allocator = std.testing.allocator; |
| 56 | var regex = try Regex.compile(allocator, "[[:upper:]]+"); | |
| 56 | var regex = try Regex.compile(allocator, std.testing.io, "[[:upper:]]+"); | |
| 57 | 57 | defer regex.deinit(); |
| 58 | 58 | |
| 59 | 59 | try std.testing.expect(try regex.isMatch("HELLO")); |
| @@ -65,7 +65,7 @@ test "posix: [:upper:] matches uppercase" { | ||
| 65 | 65 | |
| 66 | 66 | test "posix: [:lower:] matches lowercase" { |
| 67 | 67 | const allocator = std.testing.allocator; |
| 68 | var regex = try Regex.compile(allocator, "[[:lower:]]+"); | |
| 68 | var regex = try Regex.compile(allocator, std.testing.io, "[[:lower:]]+"); | |
| 69 | 69 | defer regex.deinit(); |
| 70 | 70 | |
| 71 | 71 | try std.testing.expect(try regex.isMatch("hello")); |
| @@ -77,7 +77,7 @@ test "posix: [:lower:] matches lowercase" { | ||
| 77 | 77 | |
| 78 | 78 | test "posix: [:xdigit:] matches hex digits" { |
| 79 | 79 | const allocator = std.testing.allocator; |
| 80 | var regex = try Regex.compile(allocator, "[[:xdigit:]]+"); | |
| 80 | var regex = try Regex.compile(allocator, std.testing.io, "[[:xdigit:]]+"); | |
| 81 | 81 | defer regex.deinit(); |
| 82 | 82 | |
| 83 | 83 | try std.testing.expect(try regex.isMatch("0123456789")); |
| @@ -90,7 +90,7 @@ test "posix: [:xdigit:] matches hex digits" { | ||
| 90 | 90 | |
| 91 | 91 | test "posix: [:punct:] matches punctuation" { |
| 92 | 92 | const allocator = std.testing.allocator; |
| 93 | var regex = try Regex.compile(allocator, "[[:punct:]]+"); | |
| 93 | var regex = try Regex.compile(allocator, std.testing.io, "[[:punct:]]+"); | |
| 94 | 94 | defer regex.deinit(); |
| 95 | 95 | |
| 96 | 96 | try std.testing.expect(try regex.isMatch("!@#$%")); |
| @@ -102,7 +102,7 @@ test "posix: [:punct:] matches punctuation" { | ||
| 102 | 102 | |
| 103 | 103 | test "posix: [:blank:] matches space and tab" { |
| 104 | 104 | const allocator = std.testing.allocator; |
| 105 | var regex = try Regex.compile(allocator, "[[:blank:]]+"); | |
| 105 | var regex = try Regex.compile(allocator, std.testing.io, "[[:blank:]]+"); | |
| 106 | 106 | defer regex.deinit(); |
| 107 | 107 | |
| 108 | 108 | try std.testing.expect(try regex.isMatch(" ")); |
| @@ -114,7 +114,7 @@ test "posix: [:blank:] matches space and tab" { | ||
| 114 | 114 | |
| 115 | 115 | test "posix: [:print:] matches printable characters" { |
| 116 | 116 | const allocator = std.testing.allocator; |
| 117 | var regex = try Regex.compile(allocator, "[[:print:]]+"); | |
| 117 | var regex = try Regex.compile(allocator, std.testing.io, "[[:print:]]+"); | |
| 118 | 118 | defer regex.deinit(); |
| 119 | 119 | |
| 120 | 120 | try std.testing.expect(try regex.isMatch("Hello World!")); |
| @@ -124,7 +124,7 @@ test "posix: [:print:] matches printable characters" { | ||
| 124 | 124 | |
| 125 | 125 | test "posix: [:graph:] matches visible characters" { |
| 126 | 126 | const allocator = std.testing.allocator; |
| 127 | var regex = try Regex.compile(allocator, "[[:graph:]]+"); | |
| 127 | var regex = try Regex.compile(allocator, std.testing.io, "[[:graph:]]+"); | |
| 128 | 128 | defer regex.deinit(); |
| 129 | 129 | |
| 130 | 130 | try std.testing.expect(try regex.isMatch("Hello")); |
| @@ -136,7 +136,7 @@ test "posix: [:graph:] matches visible characters" { | ||
| 136 | 136 | |
| 137 | 137 | test "posix: [:cntrl:] matches control characters" { |
| 138 | 138 | const allocator = std.testing.allocator; |
| 139 | var regex = try Regex.compile(allocator, "[[:cntrl:]]"); | |
| 139 | var regex = try Regex.compile(allocator, std.testing.io, "[[:cntrl:]]"); | |
| 140 | 140 | defer regex.deinit(); |
| 141 | 141 | |
| 142 | 142 | try std.testing.expect(try regex.isMatch("\x00")); |
| @@ -149,7 +149,7 @@ test "posix: [:cntrl:] matches control characters" { | ||
| 149 | 149 | |
| 150 | 150 | test "posix: combined with regular characters" { |
| 151 | 151 | const allocator = std.testing.allocator; |
| 152 | var regex = try Regex.compile(allocator, "[[:alpha:]0-9_]+"); | |
| 152 | var regex = try Regex.compile(allocator, std.testing.io, "[[:alpha:]0-9_]+"); | |
| 153 | 153 | defer regex.deinit(); |
| 154 | 154 | |
| 155 | 155 | try std.testing.expect(try regex.isMatch("hello123")); |
| @@ -159,7 +159,7 @@ test "posix: combined with regular characters" { | ||
| 159 | 159 | |
| 160 | 160 | test "posix: multiple POSIX classes in one bracket" { |
| 161 | 161 | const allocator = std.testing.allocator; |
| 162 | var regex = try Regex.compile(allocator, "[[:alpha:][:digit:]]+"); | |
| 162 | var regex = try Regex.compile(allocator, std.testing.io, "[[:alpha:][:digit:]]+"); | |
| 163 | 163 | defer regex.deinit(); |
| 164 | 164 | |
| 165 | 165 | try std.testing.expect(try regex.isMatch("abc123")); |
| @@ -169,7 +169,7 @@ test "posix: multiple POSIX classes in one bracket" { | ||
| 169 | 169 | |
| 170 | 170 | test "posix: extract words with [:alpha:]" { |
| 171 | 171 | const allocator = std.testing.allocator; |
| 172 | var regex = try Regex.compile(allocator, "[[:alpha:]]+"); | |
| 172 | var regex = try Regex.compile(allocator, std.testing.io, "[[:alpha:]]+"); | |
| 173 | 173 | defer regex.deinit(); |
| 174 | 174 | |
| 175 | 175 | const text = "Hello World 123"; |
| @@ -189,7 +189,7 @@ test "posix: extract words with [:alpha:]" { | ||
| 189 | 189 | |
| 190 | 190 | test "posix: extract hex numbers with [:xdigit:]" { |
| 191 | 191 | const allocator = std.testing.allocator; |
| 192 | var regex = try Regex.compile(allocator, "0x[[:xdigit:]]+"); | |
| 192 | var regex = try Regex.compile(allocator, std.testing.io, "0x[[:xdigit:]]+"); | |
| 193 | 193 | defer regex.deinit(); |
| 194 | 194 | |
| 195 | 195 | const text = "Colors: 0xFF5733 and 0xABCDEF"; |
| @@ -209,7 +209,7 @@ test "posix: extract hex numbers with [:xdigit:]" { | ||
| 209 | 209 | |
| 210 | 210 | test "posix: validate identifier with [:alnum:]" { |
| 211 | 211 | const allocator = std.testing.allocator; |
| 212 | var regex = try Regex.compile(allocator, "^[[:alpha:]_][[:alnum:]_]*$"); | |
| 212 | var regex = try Regex.compile(allocator, std.testing.io, "^[[:alpha:]_][[:alnum:]_]*$"); | |
| 213 | 213 | defer regex.deinit(); |
| 214 | 214 | |
| 215 | 215 | try std.testing.expect(try regex.isMatch("valid_identifier")); |
| @@ -221,7 +221,7 @@ test "posix: validate identifier with [:alnum:]" { | ||
| 221 | 221 | |
| 222 | 222 | test "posix: split on whitespace with [:space:]" { |
| 223 | 223 | const allocator = std.testing.allocator; |
| 224 | var regex = try Regex.compile(allocator, "[[:space:]]+"); | |
| 224 | var regex = try Regex.compile(allocator, std.testing.io, "[[:space:]]+"); | |
| 225 | 225 | defer regex.deinit(); |
| 226 | 226 | |
| 227 | 227 | const text = "one\ttwo\nthree four"; |