From a69e24573aac6104d0f071e8c6d7583dd2dfae1b Mon Sep 17 00:00:00 2001 From: Validark Date: Mon, 15 Apr 2019 19:17:11 -0600 Subject: [PATCH 1/8] Add string.split implementation (#190) * init * remove .history files * fix bad test and add Roblox's internal tests * change formatting to please linter --- lib/libs/init.lua | 3 +- lib/libs/string.lua | 36 +++++++++++++++ lib/libs/string_spec.lua | 98 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 136 insertions(+), 1 deletion(-) create mode 100644 lib/libs/string.lua create mode 100644 lib/libs/string_spec.lua diff --git a/lib/libs/init.lua b/lib/libs/init.lua index 79abf14..f2ae7e4 100644 --- a/lib/libs/init.lua +++ b/lib/libs/init.lua @@ -1,5 +1,6 @@ local names = { "math", + "string", } local libs = {} @@ -8,4 +9,4 @@ for _, name in ipairs(names) do libs[name] = import("./" .. name) end -return libs \ No newline at end of file +return libs diff --git a/lib/libs/string.lua b/lib/libs/string.lua new file mode 100644 index 0000000..4f0d972 --- /dev/null +++ b/lib/libs/string.lua @@ -0,0 +1,36 @@ +local rbxString = {} + +for key, value in pairs(string) do + rbxString[key] = value +end + +rbxString.split = function(str, sep) + local result = {} + + if sep == "" then + for i = 1, #str do + result[i] = str:sub(i, i) + end + else + if sep == nil then + sep = "," + end + + local count = 1 + local pos = 1 + local a, b = str:find(sep, pos, true) + + while a do + result[count] = str:sub(pos, a - 1) + count = count + 1 + pos = b + 1 + a, b = str:find(sep, pos, true) + end + + result[count] = str:sub(pos) + end + + return result +end + +return rbxString diff --git a/lib/libs/string_spec.lua b/lib/libs/string_spec.lua new file mode 100644 index 0000000..f042a8a --- /dev/null +++ b/lib/libs/string_spec.lua @@ -0,0 +1,98 @@ +local string = import("./string") + +describe("libs.string", function() + describe("split", function() + it("should be a function", function() + assert.is_function(string.split) + end) + + it("should return an array of comma separated strings if sep is nil", function() + assert.are.same({"Hello", "world", "and", "lemur"}, string.split("Hello,world,and,lemur")) + end) + + it("should return an array of all characters in a string if sep is the empty string", function() + assert.are.same({ + "H", + "e", + "l", + "l", + "o", + ",", + "w", + "o", + "r", + "l", + "d", + ",", + "a", + "n", + "d", + ",", + "l", + "e", + "m", + "u", + "r", + }, string.split("Hello,world,and,lemur", "")) + end) + + it("should return an empty table if the string and sep is the empty string", function() + assert.are.same({}, string.split("", "")) + end) + + it("should return the original string in a table if no sep is matched", function() + assert.are.same({"Hello, world"}, string.split("Hello, world", "K")) + assert.are.same({""}, string.split("", " ")) + end) + + it("should return empty strings at the front and back when seps are present there", function() + assert.are.same({"", "Validark", "Osyris", "Vorlias", ""}, string.split("/Validark/Osyris/Vorlias/", "/")) + assert.are.same({"", "Validark", "Osyris", "Vorlias"}, string.split("/Validark/Osyris/Vorlias", "/")) + assert.are.same({"Validark", "Osyris", "Vorlias", ""}, string.split("Validark/Osyris/Vorlias/", "/")) + assert.are.same({"Validark", "Osyris", "Vorlias"}, string.split("Validark/Osyris/Vorlias", "/")) + end) + + it("should allow multi-character separators", function() + assert.are.same({"Hello", "world"}, string.split("Hello, world", ", ")) + end) + + it("should literally interpret Lua character classes", function() + assert.are.same({"Hello, world"}, string.split("Hello, world", "%l")) + assert.are.same({"Hel", "o, world"}, string.split("Hel%lo, world", "%l")) + end) + + it("should match Roblox's internal tests", function() + -- Provided by tiffany352 at https://github.com/LPGhatguy/lemur/pull/190 + local char = string.char + local ZWJ = char(0xe2, 0x80, 0x8d) + assert.are.same({ "" }, string.split("", ",")) + assert.are.same({ "foo", "", "bar" }, string.split("foo,,bar", ",")) + assert.are.same({ "", "foo" }, string.split(",foo", ",")) + assert.are.same({ "foo", "" }, string.split("foo,", ",")) + assert.are.same({ "", "" }, string.split(",", ",")) + assert.are.same({ "", "", "" }, string.split(",,", ",")) + assert.are.same({ "" }, string.split("", "~~~")) + assert.are.same({ "~~" }, string.split("~~", "~~~")) + assert.are.same({ "~~ ~~" }, string.split("~~ ~~", "~~~")) + assert.are.same({ "foo", "bar" }, string.split("foo~~~bar", "~~~")) + assert.are.same({ "foo", "", "bar" }, string.split("foo~~~~~~bar", "~~~")) + assert.are.same({ "", "foo" }, string.split("~~~foo", "~~~")) + assert.are.same({ "foo", "" }, string.split("foo~~~", "~~~")) + assert.are.same({ "", "" }, string.split("~~~", "~~~")) + assert.are.same({ "", "", "" }, string.split("~~~~~~", "~~~")) + assert.are.same({ "", "", "O" }, string.split("OOOOO", "OO")) + assert.are.same({ " ws " }, string.split(" ws ", ",")) + assert.are.same({ "foo ", " bar" }, string.split("foo , bar", ",")) + assert.are.same({ "我很高兴", "你呢?" }, string.split("我很高兴,你呢?", ",")) + assert.are.same({ "👩", "👩", "👧", "👧" }, string.split("👩‍👩‍👧‍👧", ZWJ)) + assert.are.same({ "foo", "bar" }, string.split("foo\0bar", "\0")) + assert.are.same({ "foo", "bar", "" }, string.split("foo\0bar\0", "\0")) + assert.are.same({ "foo", "bar" }, string.split("foo\0\0bar", "\0\0")) + assert.are.same({ "foo\0" }, string.split("foo\0", "\0\0")) + assert.are.same({ "foo", "\0" }, string.split("foo\0\0\0", "\0\0")) + assert.are.same({ }, string.split("", "")) + assert.are.same({ "a", "b", "c" }, string.split("abc", "")) + assert.are.same({ char(0xef), char(0xbc), char(0x9f) }, string.split("?", "")) + end) + end) +end) From 900c8c3c895d1cc408bcfb5a51429dd8316ad517 Mon Sep 17 00:00:00 2001 From: dbrooks-roblox <42393327+dbrooks-roblox@users.noreply.github.com> Date: Wed, 10 Jul 2019 14:20:54 -0700 Subject: [PATCH 2/8] Add Enabled prop to ScreenGui (#201) This change adds the Enabled property to ScreenGui to facilitate writing tests with more modern API. --- lib/instances/ScreenGui.lua | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/instances/ScreenGui.lua b/lib/instances/ScreenGui.lua index 44609cb..a015d19 100644 --- a/lib/instances/ScreenGui.lua +++ b/lib/instances/ScreenGui.lua @@ -43,4 +43,10 @@ ScreenGui.properties.ZIndexBehavior = InstanceProperty.enum(ZIndexBehavior, { end, }) -return ScreenGui \ No newline at end of file +ScreenGui.properties.Enabled = InstanceProperty.typed("boolean", { + getDefault = function() + return true + end, +}) + +return ScreenGui From 5e006416911914a8b8529c7cd8b73f5e619de9b1 Mon Sep 17 00:00:00 2001 From: Jacob Date: Thu, 11 Jul 2019 16:12:15 -0400 Subject: [PATCH 3/8] Warn tostring (#171) (#195) * Add NumberRange (#155) * Tostring warn arguments * Remove NumberRange from another pr * Revert "Remove NumberRange from another pr" This reverts commit 6a9d046133d8e22ef04a03def1001628ed000cb7. * Removed the wrong thing --- lib/functions/warn.lua | 2 +- lib/functions/warn_spec.lua | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/lib/functions/warn.lua b/lib/functions/warn.lua index f36552d..aff9f91 100644 --- a/lib/functions/warn.lua +++ b/lib/functions/warn.lua @@ -2,7 +2,7 @@ local function warn(...) local count = select("#", ...) for i = 1, count do local piece = select(i, ...) - io.stderr:write(piece) + io.stderr:write(tostring(piece)) if i < count then io.stderr:write("\t") diff --git a/lib/functions/warn_spec.lua b/lib/functions/warn_spec.lua index a82b26b..04cd1ff 100644 --- a/lib/functions/warn_spec.lua +++ b/lib/functions/warn_spec.lua @@ -30,4 +30,18 @@ describe("functions.warn", function() assert.spy(writeSpy).was.called(4) -- IT'S DOGE, \t, AAH!, \n io.stderr = oldErr -- luacheck: ignore end) + + it("should warn with a non-string argument", function() + local oldErr, writeSpy = setupWarnDetour() + warn(1) + assert.spy(writeSpy).was_called_with(io.stderr, "1") + io.stderr = oldErr -- luacheck: ignore + end) + + it("should warn with non-string arguments", function() + local oldErr, writeSpy = setupWarnDetour() + warn(2, 3) + assert.spy(writeSpy).was.called(4) -- 2, \t, 3, \n + io.stderr = oldErr -- luacheck: ignore + end) end) \ No newline at end of file From e7ca13822ded09faea9b1331f1bbdc41f59ac108 Mon Sep 17 00:00:00 2001 From: Jacob Date: Thu, 11 Jul 2019 16:13:07 -0400 Subject: [PATCH 4/8] Adds Vector2 __mul and __div (#199) * Adds __mul and __div to Vector2 * Forgot to add typeof to Vector2 * Fix test * Add `/` and `*` to FEATURES.md --- FEATURES.md | 2 +- lib/types/Vector2.lua | 25 +++++++++++++++ lib/types/Vector2_spec.lua | 62 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 88 insertions(+), 1 deletion(-) diff --git a/FEATURES.md b/FEATURES.md index d751d97..1648d55 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -62,7 +62,7 @@ This document should remain up-to-date with current API coverage and status. * Vector2 * Vector2.new() * Vector2.new(x, y) - * Operators: `==`, `+` + * Operators: `==`, `+`, `*`, `/` ## Implemented Instance Members * AnalyticsService diff --git a/lib/types/Vector2.lua b/lib/types/Vector2.lua index 7132cfb..bed3840 100644 --- a/lib/types/Vector2.lua +++ b/lib/types/Vector2.lua @@ -1,5 +1,6 @@ local assign = import("../assign") local typeKey = import("../typeKey") +local typeof = import("../functions/typeof") local Vector2 = {} @@ -36,6 +37,30 @@ function metatable:__sub(other) return Vector2.new(self.X - other.X, self.Y - other.Y) end +function metatable:__mul(other) + if typeof(self) == "Vector2" and typeof(other) == "Vector2" then + return Vector2.new(self.X * other.X, self.Y * other.Y) + elseif typeof(self) == "Vector2" and typeof(other) == "number" then + return Vector2.new(self.X * other, self.Y * other) + elseif typeof(self) == "number" and typeof(other) == "Vector2" then + return Vector2.new(other.X * self, other.Y * self) + else + error("attempt to multiply a Vector2 with an incompatible value type or nil") + end +end + +function metatable:__div(other) + if typeof(self) == "Vector2" and typeof(other) == "Vector2" then + return Vector2.new(self.X / other.X, self.Y / other.Y) + elseif typeof(self) == "Vector2" and typeof(other) == "number" then + return Vector2.new(self.X / other, self.Y / other) + elseif typeof(self) == "number" and typeof(other) == "Vector2" then + return Vector2.new(other.X / self, other.Y / self) + else + error("attempt to divide a Vector2 with an incompatible value type or nil") + end +end + function metatable:__eq(other) return self.X == other.X and self.Y == other.Y end diff --git a/lib/types/Vector2_spec.lua b/lib/types/Vector2_spec.lua index 2497027..6b03ea1 100644 --- a/lib/types/Vector2_spec.lua +++ b/lib/types/Vector2_spec.lua @@ -48,6 +48,68 @@ describe("types.Vector2", function() assert.are.same({-99, -300}, extractValues(v)) end) + it("should multiply by another Vector2", function() + local vectorA = Vector2.new(1, 50) + local vectorB = Vector2.new(2, 0.5) + local v = vectorA * vectorB + + assert.not_nil(v) + assert.are.same({2, 25}, extractValues(v)) + end) + + it("should multiply by a number", function() + local vectorA = Vector2.new(1, 50) + local v = vectorA * 3 + + assert.not_nil(v) + assert.are.same({3, 150}, extractValues(v)) + end) + + it("should multiply by a number reversed", function() + local vectorA = Vector2.new(1, 50) + local v = 3 * vectorA + + assert.not_nil(v) + assert.are.same({3, 150}, extractValues(v)) + end) + + it("should throw an error when multiplied by an incompatible type", function() + assert.has.errors(function() + return Vector2.new(1, 2) * nil + end) + end) + + it("should divide by another Vector2", function() + local vectorA = Vector2.new(1, 50) + local vectorB = Vector2.new(2, 1) + local v = vectorA / vectorB + + assert.not_nil(v) + assert.are.same({0.5, 50}, extractValues(v)) + end) + + it("should divide by a number", function() + local vectorA = Vector2.new(1, 50) + local v = vectorA / 4 + + assert.not_nil(v) + assert.are.same({0.25, 12.5}, extractValues(v)) + end) + + it("should divide by a number reversed", function() + local vectorA = Vector2.new(1, 50) + local v = 4 / vectorA + + assert.not_nil(v) + assert.are.same({0.25, 12.5}, extractValues(v)) + end) + + it("should throw an error when divided by an incompatible type", function() + assert.has.errors(function() + return Vector2.new(1, 2) / "abc" + end) + end) + it("should equal another Vector2 with the same x and y", function() local vectorA = Vector2.new(1, 200) local vectorB = Vector2.new(1, 200) From 6c9668a3d2b29d4574138cb0a83183efc1780df2 Mon Sep 17 00:00:00 2001 From: Jacob Date: Thu, 11 Jul 2019 16:13:49 -0400 Subject: [PATCH 5/8] Fix n * Vector3 (#178) (#196) * Fix Vector3 multiplied backwards with a number * Fix Vector3 * and / Vector3 --- lib/types/Vector3.lua | 12 ++++++++---- lib/types/Vector3_spec.lua | 16 ++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/lib/types/Vector3.lua b/lib/types/Vector3.lua index 576ce44..04494be 100644 --- a/lib/types/Vector3.lua +++ b/lib/types/Vector3.lua @@ -38,20 +38,24 @@ function metatable:__sub(other) end function metatable:__mul(other) - if typeof(other) == "Vector3" then + if typeof(self) == "Vector3" and typeof(other) == "Vector3" then return Vector3.new(self.X * other.X, self.Y * other.Y, self.Z * other.Z) - elseif typeof(other) == "number" then + elseif typeof(self) == "Vector3" and typeof(other) == "number" then return Vector3.new(self.X * other, self.Y * other, self.Z * other) + elseif typeof(self) == "number" and typeof(other) == "Vector3" then + return Vector3.new(other.X * self, other.Y * self, other.Z * self) else error("attempt to multiply a Vector3 with an incompatible value type or nil") end end function metatable:__div(other) - if typeof(other) == "Vector3" then + if typeof(self) == "Vector3" and typeof(other) == "Vector3" then return Vector3.new(self.X / other.X, self.Y / other.Y, self.Z / other.Z) - elseif typeof(other) == "number" then + elseif typeof(self) == "Vector3" and typeof(other) == "number" then return Vector3.new(self.X / other, self.Y / other, self.Z / other) + elseif typeof(self) == "number" and typeof(other) == "Vector3" then + return Vector3.new(other.X / self, other.Y / self, other.Z / self) else error("attempt to divide a Vector3 with an incompatible value type or nil") end diff --git a/lib/types/Vector3_spec.lua b/lib/types/Vector3_spec.lua index e7660be..ded84cb 100644 --- a/lib/types/Vector3_spec.lua +++ b/lib/types/Vector3_spec.lua @@ -68,6 +68,14 @@ describe("types.Vector3", function() assert.are.same({3, 150, 600}, extractValues(v)) end) + it("should multiply by a number reversed", function() + local vectorA = Vector3.new(1, 50, 200) + local v = 3 * vectorA + + assert.not_nil(v) + assert.are.same({3, 150, 600}, extractValues(v)) + end) + it("should throw an error when multiplied by an incompatible type", function() assert.has.errors(function() return Vector3.new(1, 2, 3) * nil @@ -91,6 +99,14 @@ describe("types.Vector3", function() assert.are.same({0.25, 12.5, 50}, extractValues(v)) end) + it("should divide by a number reversed", function() + local vectorA = Vector3.new(1, 50, 200) + local v = 4 / vectorA + + assert.not_nil(v) + assert.are.same({0.25, 12.5, 50}, extractValues(v)) + end) + it("should throw an error when divided by an incompatible type", function() assert.has.errors(function() return Vector3.new(1, 2, 3) / "abc" From 714cf6b847f677de9df58bf5e7fac2335d5a1282 Mon Sep 17 00:00:00 2001 From: jeparlefrancais <35781636+jeparlefrancais@users.noreply.github.com> Date: Fri, 12 Jul 2019 18:14:00 -0400 Subject: [PATCH 6/8] ImageRectOffset and ImageRectSize for ImageLabel and ImageButton (#202) * Add ImageLabel ImageRectSize and ImageRectOffset * Add ImageRectOffset and ImageRectSize to ImageButton * Sort imports --- FEATURES.md | 4 ++++ lib/instances/ImageButton.lua | 13 +++++++++++++ lib/instances/ImageButton_spec.lua | 2 ++ lib/instances/ImageLabel.lua | 13 +++++++++++++ lib/instances/ImageLabel_spec.lua | 2 ++ 5 files changed, 34 insertions(+) diff --git a/FEATURES.md b/FEATURES.md index 1648d55..79b447f 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -97,11 +97,15 @@ This document should remain up-to-date with current API coverage and status. * ImageButton * Image * ImageColor3 + * ImageRectOffset + * ImageRectSize * ScaleType * SliceCenter * ImageLabel * Image * ImageColor3 + * ImageRectOffset + * ImageRectSize * ScaleType * SliceCenter * Instance diff --git a/lib/instances/ImageButton.lua b/lib/instances/ImageButton.lua index f308672..228206e 100644 --- a/lib/instances/ImageButton.lua +++ b/lib/instances/ImageButton.lua @@ -3,6 +3,7 @@ local GuiButton = import("./GuiButton") local InstanceProperty = import("../InstanceProperty") local Rect = import("../types/Rect") local ScaleType = import("../Enum/ScaleType") +local Vector2 = import("../types/Vector2") local ImageButton = GuiButton:extend("ImageButton", { creatable = true, @@ -20,6 +21,18 @@ ImageButton.properties.ImageColor3 = InstanceProperty.typed("Color3", { end, }) +ImageButton.properties.ImageRectOffset = InstanceProperty.typed("Vector2", { + getDefault = function() + return Vector2.new(0, 0) + end, +}) + +ImageButton.properties.ImageRectSize = InstanceProperty.typed("Vector2", { + getDefault = function() + return Vector2.new(0, 0) + end, +}) + ImageButton.properties.ScaleType = InstanceProperty.enum(ScaleType, { getDefault = function() return ScaleType.Stretch diff --git a/lib/instances/ImageButton_spec.lua b/lib/instances/ImageButton_spec.lua index b739fcf..fee9bac 100644 --- a/lib/instances/ImageButton_spec.lua +++ b/lib/instances/ImageButton_spec.lua @@ -13,6 +13,8 @@ describe("instances.ImageButton", function() local instance = Instance.new("ImageButton") assert.equals(typeof(instance.Image), "string") assert.equals(typeof(instance.ImageColor3), "Color3") + assert.equals(typeof(instance.ImageRectOffset), "Vector2") + assert.equals(typeof(instance.ImageRectSize), "Vector2") assert.equals(typeof(instance.ScaleType), "EnumItem") assert.equal(instance.ScaleType.EnumType, ScaleType) assert.equals(typeof(instance.SliceCenter), "Rect") diff --git a/lib/instances/ImageLabel.lua b/lib/instances/ImageLabel.lua index 35ea578..83ddc2a 100644 --- a/lib/instances/ImageLabel.lua +++ b/lib/instances/ImageLabel.lua @@ -3,6 +3,7 @@ local GuiObject = import("./GuiObject") local InstanceProperty = import("../InstanceProperty") local Rect = import("../types/Rect") local ScaleType = import("../Enum/ScaleType") +local Vector2 = import("../types/Vector2") local ImageLabel = GuiObject:extend("ImageLabel", { creatable = true, @@ -20,6 +21,18 @@ ImageLabel.properties.ImageColor3 = InstanceProperty.typed("Color3", { end, }) +ImageLabel.properties.ImageRectOffset = InstanceProperty.typed("Vector2", { + getDefault = function() + return Vector2.new(0, 0) + end, +}) + +ImageLabel.properties.ImageRectSize = InstanceProperty.typed("Vector2", { + getDefault = function() + return Vector2.new(0, 0) + end, +}) + ImageLabel.properties.ScaleType = InstanceProperty.enum(ScaleType, { getDefault = function() return ScaleType.Stretch diff --git a/lib/instances/ImageLabel_spec.lua b/lib/instances/ImageLabel_spec.lua index ba3d985..6499dbe 100644 --- a/lib/instances/ImageLabel_spec.lua +++ b/lib/instances/ImageLabel_spec.lua @@ -13,6 +13,8 @@ describe("instances.ImageLabel", function() local instance = Instance.new("ImageLabel") assert.equals(typeof(instance.Image), "string") assert.equals(typeof(instance.ImageColor3), "Color3") + assert.equals(typeof(instance.ImageRectOffset), "Vector2") + assert.equals(typeof(instance.ImageRectSize), "Vector2") assert.equals(typeof(instance.ScaleType), "EnumItem") assert.equals(instance.ScaleType.EnumType, ScaleType) assert.equals(typeof(instance.SliceCenter), "Rect") From bf2f27030e57979a7c320da674ee54c2aefa7545 Mon Sep 17 00:00:00 2001 From: jeparlefrancais <35781636+jeparlefrancais@users.noreply.github.com> Date: Fri, 26 Jul 2019 16:19:14 -0400 Subject: [PATCH 7/8] MouseEnter and MouseLeave (#205) * Add MouseEnter and MouseLeave events * Add MouseEnter and MouseLeave to features --- FEATURES.md | 2 ++ lib/instances/GuiObject.lua | 12 ++++++++++++ lib/instances/GuiObject_spec.lua | 2 ++ 3 files changed, 16 insertions(+) diff --git a/FEATURES.md b/FEATURES.md index 79b447f..d2f8bd4 100644 --- a/FEATURES.md +++ b/FEATURES.md @@ -85,6 +85,8 @@ This document should remain up-to-date with current API coverage and status. * InputBegan * InputEnded * LayoutOrder + * MouseEnter + * MouseLeave * Position * Selectable * Size diff --git a/lib/instances/GuiObject.lua b/lib/instances/GuiObject.lua index 0b6a2ea..34bd192 100644 --- a/lib/instances/GuiObject.lua +++ b/lib/instances/GuiObject.lua @@ -107,6 +107,18 @@ GuiObject.properties.LayoutOrder = InstanceProperty.typed("number", { end, }) +GuiObject.properties.MouseEnter = InstanceProperty.readOnly({ + getDefault = function() + return Signal.new() + end, +}) + +GuiObject.properties.MouseLeave = InstanceProperty.readOnly({ + getDefault = function() + return Signal.new() + end, +}) + GuiObject.properties.Position = InstanceProperty.typed("UDim2", { getDefault = function() return UDim2.new() diff --git a/lib/instances/GuiObject_spec.lua b/lib/instances/GuiObject_spec.lua index c713698..e895c03 100644 --- a/lib/instances/GuiObject_spec.lua +++ b/lib/instances/GuiObject_spec.lua @@ -29,6 +29,8 @@ describe("instances.GuiObject", function() assert.equal(typeof(instance.InputBegan), "RBXScriptSignal") assert.equal(typeof(instance.InputEnded), "RBXScriptSignal") assert.equal(typeof(instance.LayoutOrder), "number") + assert.equal(typeof(instance.MouseEnter), "RBXScriptSignal") + assert.equal(typeof(instance.MouseLeave), "RBXScriptSignal") assert.equal(typeof(instance.Position), "UDim2") assert.equal(typeof(instance.Selectable), "boolean") assert.equal(typeof(instance.Size), "UDim2") From cba91fbcf9862118c4c02924af9aedfc70904fc3 Mon Sep 17 00:00:00 2001 From: dbrooks-roblox <42393327+dbrooks-roblox@users.noreply.github.com> Date: Wed, 31 Jul 2019 12:38:51 -0700 Subject: [PATCH 8/8] Add Enabled and OnTopOfCoreBlur to ScreenGui (#206) * Add Enabled prop to ScreenGui This change adds the Enabled property to ScreenGui to facilitate writing tests with more modern API. * Add OnTopOfCoreBlur to ScreenGui * Add tests for ScreenGui/Enabled+OnTopOfCoreBlur Add missing unit tests for ScreenGui. --- lib/instances/ScreenGui.lua | 6 ++++++ lib/instances/ScreenGui_spec.lua | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/lib/instances/ScreenGui.lua b/lib/instances/ScreenGui.lua index a015d19..1baa6c8 100644 --- a/lib/instances/ScreenGui.lua +++ b/lib/instances/ScreenGui.lua @@ -49,4 +49,10 @@ ScreenGui.properties.Enabled = InstanceProperty.typed("boolean", { end, }) +ScreenGui.properties.OnTopOfCoreBlur = InstanceProperty.typed("boolean", { + getDefault = function() + return false + end, +}) + return ScreenGui diff --git a/lib/instances/ScreenGui_spec.lua b/lib/instances/ScreenGui_spec.lua index f9b01ed..59f091d 100644 --- a/lib/instances/ScreenGui_spec.lua +++ b/lib/instances/ScreenGui_spec.lua @@ -18,6 +18,8 @@ describe("instances.ScreenGui", function() assert.equals(typeof(instance.AutoLocalize), "boolean") assert.equals(typeof(instance.IgnoreGuiInset), "boolean") assert.equals(typeof(instance.ZIndexBehavior), "EnumItem") + assert.equals(typeof(instance.OnTopOfCoreBlur), "boolean") + assert.equals(typeof(instance.Enabled), "boolean") assert.equals(instance.ZIndexBehavior.EnumType, ZIndexBehavior) end) -end) \ No newline at end of file +end)