Add test for table.get

This commit is contained in:
0x4261756D 2023-11-24 03:35:55 +01:00
parent 5dc1b9d50b
commit c8cbf4659a
1 changed files with 13 additions and 0 deletions

View File

@ -169,6 +169,19 @@ test "Value equalities"
try std.testing.expect(!h.rawEqual(j));
}
test "Table get"
{
var a = Table { .entries = std.ArrayList(TableEntry).init(std.testing.allocator) };
defer a.entries.deinit();
try a.entries.append(TableEntry { .key = Value { .Bool = true }, .value = Value { .String = "foo" } });
try std.testing.expectEqualStrings(a.get(Value { .Bool = true }).String, "foo");
try std.testing.expectEqual(a.get(Value.Nil), Value.Nil);
try std.testing.expectEqual(a.get(Value { .Numeral = Numeral { .Integer = 12 } }), Value.Nil);
var c = a.get(Value { .Bool = true });
c.String = "bar";
try std.testing.expectEqual(a.get(Value { .Bool = true }).String, "foo");
}
pub const CodeRegion = struct
{
start: ?CodeLocation,