mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 14:25:44 +08:00
f31232d301
# Old Solver: - Fix a bug in the old solver where a user could use the keyword `typeof` as the name of a type alias. - Fix stringification of scientific notation to omit a trailing decimal place when not followed by a digit e.g. `1.e+20` -> `1e+20` # New Solver - Continuing work on the New non-strict mode - Introduce `keyof` and `rawkeyof` type function for acquiring the type of all keys in a table or class (https://github.com/luau-lang/rfcs/pull/16) --- Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Alexander McCord <amccord@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: Lily Brown <lbrown@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com> Co-authored-by: Vighnesh Vijay <vvijay@roblox.com> --------- Co-authored-by: Aaron Weiss <aaronweiss@roblox.com> Co-authored-by: Alexander McCord <amccord@roblox.com> Co-authored-by: Andy Friesen <afriesen@roblox.com> Co-authored-by: Aviral Goel <agoel@roblox.com> Co-authored-by: David Cope <dcope@roblox.com> Co-authored-by: Lily Brown <lbrown@roblox.com> Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
58 lines
2.3 KiB
Lua
58 lines
2.3 KiB
Lua
-- This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
|
|
-- This file is based on Lua 5.x tests -- https://github.com/lua/lua/tree/master/testes
|
|
print("testing string-number conversion")
|
|
|
|
-- zero
|
|
assert(tostring(0) == "0")
|
|
assert(tostring(0/-1) == "-0")
|
|
|
|
-- specials
|
|
assert(tostring(1/0) == "inf")
|
|
assert(tostring(-1/0) == "-inf")
|
|
assert(tostring(0/0) == "nan")
|
|
|
|
-- integers
|
|
assert(tostring(1) == "1")
|
|
assert(tostring(42) == "42")
|
|
assert(tostring(-4294967296) == "-4294967296")
|
|
assert(tostring(9007199254740991) == "9007199254740991")
|
|
|
|
-- decimals
|
|
assert(tostring(0.5) == "0.5")
|
|
assert(tostring(0.1) == "0.1")
|
|
assert(tostring(-0.17) == "-0.17")
|
|
assert(tostring(math.pi) == "3.141592653589793")
|
|
|
|
-- scientific
|
|
assert(tostring(1e+30) == "1e+30")
|
|
assert(tostring(-1e+24) == "-1e+24")
|
|
|
|
-- fuzzing corpus
|
|
-- Note: If the assert below fires it may indicate floating point denormalized values
|
|
-- are not handled as expected.
|
|
assert(tostring(5.4536123983019448e-311) == "5.453612398302e-311")
|
|
assert(tostring(5.4834368411298348e-311) == "5.48343684113e-311")
|
|
assert(tostring(4.4154895841930002e-305) == "4.415489584193e-305")
|
|
assert(tostring(1125968630513728) == "1125968630513728")
|
|
assert(tostring(3.3951932655938423e-313) == "3.3951932656e-313")
|
|
assert(tostring(1.625) == "1.625")
|
|
assert(tostring(4.9406564584124654e-324) == "5e-324")
|
|
assert(tostring(2.0049288280105384) == "2.0049288280105384")
|
|
assert(tostring(3.0517578125e-05) == "0.000030517578125")
|
|
assert(tostring(1.383544921875) == "1.383544921875")
|
|
assert(tostring(3.0053350932691001) == "3.0053350932691")
|
|
assert(tostring(0.0001373291015625) == "0.0001373291015625")
|
|
assert(tostring(-1.9490628022799998e+289) == "-1.94906280228e+289")
|
|
assert(tostring(-0.00610404721867928) == "-0.00610404721867928")
|
|
assert(tostring(0.00014495849609375) == "0.00014495849609375")
|
|
assert(tostring(0.453125) == "0.453125")
|
|
assert(tostring(-4.2375343999999997e+73) == "-4.2375344e+73")
|
|
assert(tostring(1.3202313930270133e-192) == "1.3202313930270133e-192")
|
|
assert(tostring(3.6984408976312836e+19) == "36984408976312840000")
|
|
assert(tostring(2.0563000527063302) == "2.05630005270633")
|
|
assert(tostring(4.8970527433648997e-260) == "4.8970527433649e-260")
|
|
assert(tostring(1.62890625) == "1.62890625")
|
|
assert(tostring(1.1295093211933533e+65) == "1.1295093211933533e+65")
|
|
|
|
return "OK"
|