From c4cb99755e86d44b61c47bb0e2e850fc42a02e05 Mon Sep 17 00:00:00 2001 From: JohnnyMorganz Date: Sun, 25 Jan 2026 02:40:35 +0000 Subject: [PATCH] Update external test cases --- .../type_instantiation.lua | 25 ------ .../type_instantiations.lua | 71 +++++++++++++++++ ...uau_full_moon@type_instantiations.lua.snap | 76 +++++++++++++++++++ 3 files changed, 147 insertions(+), 25 deletions(-) delete mode 100644 tests/inputs-luau-full_moon/type_instantiation.lua create mode 100644 tests/inputs-luau-full_moon/type_instantiations.lua create mode 100644 tests/snapshots/tests__luau_full_moon@type_instantiations.lua.snap diff --git a/tests/inputs-luau-full_moon/type_instantiation.lua b/tests/inputs-luau-full_moon/type_instantiation.lua deleted file mode 100644 index fa6be287..00000000 --- a/tests/inputs-luau-full_moon/type_instantiation.lua +++ /dev/null @@ -1,25 +0,0 @@ --- Basic type instantiation -local result = identity<>(1) - --- Multiple type parameters -local a, b = multipleReturns<>(1, "a") - --- Type packs -local c, d = typePacks<<(string, number)>>(1, "a") - --- Method call with type instantiation -local value = obj:method<>(42) - --- Chained method calls with type instantiation -local chained = obj:first<>():second<>() - --- Complex nested types -local nested = expr<>>>() -local nestedMethod = a:method<>>>() - --- Multiple suffixes -local multi = foo.bar<>() -local multiMethod = foo:bar<>().baz<>() - --- Long type parameters that may need formatting -local long = func<>(arg1, arg2) diff --git a/tests/inputs-luau-full_moon/type_instantiations.lua b/tests/inputs-luau-full_moon/type_instantiations.lua new file mode 100644 index 00000000..97edc1df --- /dev/null +++ b/tests/inputs-luau-full_moon/type_instantiations.lua @@ -0,0 +1,71 @@ +--[[ + +Taken from https://github.com/luau-lang/luau/blob/535f92589bdc304c8a2012d6cfad5e7b9faff2f7/tests/conformance/explicit_type_instantiations.luau + +MIT License + +Copyright (c) 2019-2025 Roblox Corporation +Copyright (c) 1994–2019 Lua.org, PUC-Rio. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +]] + +-- Tests to ensure explicit type instantiations don't change runtime behavior +local function identity(x: T): T + return x +end + +assert(identity<>(1) == 1) + +local function multipleReturns(x: T): (T, T) + return x, x +end + +local a, b = multipleReturns<>(1) +assert(a == 1 and b == 1) + +local function typePacks(...: T...): T... + return ... +end + +local a, b = typePacks<<(string, number)>>(1, "a") +assert(a == 1 and b == "a") + +local t = {} +function t:method(x: T): T + assert(self == t) + return x +end + +assert(t:method(1) == 1) + +function t:methodTypePacks(...: T...): T... + assert(self == t) + return ... +end + +local a, b = t:methodTypePacks<<(string, number)>>(1, "a") +assert(a == 1 and b == "a") + +-- full-moon tests +local complicatedExpr = expr<>>>() +local complicatedMethod = a:method<>>>() + +return "OK" \ No newline at end of file diff --git a/tests/snapshots/tests__luau_full_moon@type_instantiations.lua.snap b/tests/snapshots/tests__luau_full_moon@type_instantiations.lua.snap new file mode 100644 index 00000000..ec2cda37 --- /dev/null +++ b/tests/snapshots/tests__luau_full_moon@type_instantiations.lua.snap @@ -0,0 +1,76 @@ +--- +source: tests/tests.rs +expression: "format(&contents, LuaVersion::Luau)" +input_file: tests/inputs-luau-full_moon/type_instantiations.lua +--- +--[[ + +Taken from https://github.com/luau-lang/luau/blob/535f92589bdc304c8a2012d6cfad5e7b9faff2f7/tests/conformance/explicit_type_instantiations.luau + +MIT License + +Copyright (c) 2019-2025 Roblox Corporation +Copyright (c) 1994–2019 Lua.org, PUC-Rio. + +Permission is hereby granted, free of charge, to any person obtaining a copy of +this software and associated documentation files (the "Software"), to deal in +the Software without restriction, including without limitation the rights to +use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies +of the Software, and to permit persons to whom the Software is furnished to do +so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. + +]] + +-- Tests to ensure explicit type instantiations don't change runtime behavior +local function identity(x: T): T + return x +end + +assert(identity<>(1) == 1) + +local function multipleReturns(x: T): (T, T) + return x, x +end + +local a, b = multipleReturns<>(1) +assert(a == 1 and b == 1) + +local function typePacks(...: T...): T... + return ... +end + +local a, b = typePacks<<(string, number)>>(1, "a") +assert(a == 1 and b == "a") + +local t = {} +function t:method(x: T): T + assert(self == t) + return x +end + +assert(t:method(1) == 1) + +function t:methodTypePacks(...: T...): T... + assert(self == t) + return ... +end + +local a, b = t:methodTypePacks<<(string, number)>>(1, "a") +assert(a == 1 and b == "a") + +-- full-moon tests +local complicatedExpr = expr<>>>() +local complicatedMethod = a:method<>>>() + +return "OK"