From 7cbc75f8e91c71f922d0116df4d4000420133173 Mon Sep 17 00:00:00 2001 From: Filip Tibell Date: Sun, 26 Mar 2023 11:58:30 +0200 Subject: [PATCH] Add cloning to attribute test --- tests/roblox/instance/attributes.luau | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/roblox/instance/attributes.luau b/tests/roblox/instance/attributes.luau index 5a0a61e..0796e20 100644 --- a/tests/roblox/instance/attributes.luau +++ b/tests/roblox/instance/attributes.luau @@ -66,6 +66,30 @@ for name, value in ATTRS_EXPECTED do end end +-- Cloning instances should also clone attributes + +local cloned = model:Clone() +ATTRS_ACTUAL = cloned:GetAttributes() + +for name, value in ATTRS_EXPECTED do + local actual = ATTRS_ACTUAL[name] + if actual ~= value then + if value ~= value and actual ~= actual then + continue -- NaN + end + error( + string.format( + "Expected cloned attribute '%s' to have value '%s', got value '%s'", + name, + tostring(value), + tostring(actual) + ) + ) + end +end + +-- Writing files with modified attributes should work + local game = Instance.new("DataModel") model.Parent = game