2026-01-24 23:53:19 +05:30
|
|
|
// This test is imported by root.zig for testing
|
2026-01-17 18:32:29 +05:30
|
|
|
const std = @import("std");
|
2026-01-24 23:53:19 +05:30
|
|
|
const testing = std.testing;
|
|
|
|
|
const mixin = @import("../mixin.zig");
|
2026-01-17 18:32:29 +05:30
|
|
|
|
2026-01-24 23:53:19 +05:30
|
|
|
test "bindArguments - with default value in param" {
|
|
|
|
|
const allocator = testing.allocator;
|
|
|
|
|
|
|
|
|
|
var bindings = std.StringHashMapUnmanaged([]const u8){};
|
|
|
|
|
defer bindings.deinit(allocator);
|
|
|
|
|
|
|
|
|
|
// This is how it appears: params have default, args are the call args
|
|
|
|
|
try mixin.bindArguments(allocator, "text, type=\"primary\"", "\"Click Me\", \"primary\"", &bindings);
|
|
|
|
|
|
|
|
|
|
std.debug.print("\nBindings:\n", .{});
|
|
|
|
|
var iter = bindings.iterator();
|
|
|
|
|
while (iter.next()) |entry| {
|
|
|
|
|
std.debug.print(" {s} = '{s}'\n", .{entry.key_ptr.*, entry.value_ptr.*});
|
2026-01-17 18:32:29 +05:30
|
|
|
}
|
2026-01-24 23:53:19 +05:30
|
|
|
|
|
|
|
|
try testing.expectEqualStrings("Click Me", bindings.get("text").?);
|
|
|
|
|
try testing.expectEqualStrings("primary", bindings.get("type").?);
|
2026-01-17 18:32:29 +05:30
|
|
|
}
|