refactor: localize keyword check and simplify command tests

This commit is contained in:
Adrià Arrufat
2026-05-11 20:08:38 +02:00
parent c41955ade3
commit 45da2c8196
3 changed files with 16 additions and 39 deletions

View File

@@ -311,14 +311,6 @@ pub fn isAllWhitespace(text: []const u8) bool {
} else true;
}
pub fn isAllUpper(s: []const u8) bool {
if (s.len == 0) return false;
for (s) |ch| {
if (!std.ascii.isUpper(ch) and !std.ascii.isDigit(ch) and ch != '_') return false;
}
return true;
}
// Discriminatory type that signals the bridge to use arena instead of call_arena
// Use this for strings that need to persist beyond the current call
// The caller can unwrap and store just the underlying .str field
@@ -341,17 +333,6 @@ fn asUint(comptime string: anytype) std.meta.Int(
const testing = @import("testing.zig");
test "isAllUpper" {
try testing.expectEqual(false, isAllUpper(""));
try testing.expectEqual(true, isAllUpper("GOTO"));
try testing.expectEqual(true, isAllUpper("ACCEPT_COOKIES"));
try testing.expectEqual(true, isAllUpper("X1"));
try testing.expectEqual(true, isAllUpper("_"));
try testing.expectEqual(false, isAllUpper("Goto"));
try testing.expectEqual(false, isAllUpper("goto"));
try testing.expectEqual(false, isAllUpper("GO TO"));
}
test "String" {
const other_short = try String.init(undefined, "other_short", .{});
const other_long = try String.init(testing.allocator, "other_long" ** 100, .{});