luau/tests/conformance/userdata.lua
rblanckaert 61766a692c
Sync to upstream/release/529 (#505)
* Adds a currently unused x86-64 assembler as a prerequisite for possible future JIT compilation
* Fix a bug in table iteration (closes Possible table iteration bug #504)
* Improved warning method when function is used as a type
* Fix a bug with unsandboxed iteration with pairs()
* Type of coroutine.status() is now a union of value types
* Bytecode output for tests/debugging now has labels
* Improvements to loop unrolling cost estimation
* Report errors when the key obviously doesn't exist in the table
2022-05-26 15:08:16 -07:00

46 lines
1.1 KiB
Lua

-- This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
print('testing userdata')
-- int64 is a userdata type defined in C++
-- equality
assert(int64(1) == int64(1))
assert(int64(1) ~= int64(2))
-- relational
assert(not (int64(1) < int64(1)))
assert(int64(1) < int64(2))
assert(int64(1) <= int64(1))
assert(int64(1) <= int64(2))
-- arithmetics
assert(-int64(2) == int64(-2))
assert(int64(1) + int64(2) == int64(3))
assert(int64(1) - int64(2) == int64(-1))
assert(int64(2) * int64(3) == int64(6))
assert(int64(4) / int64(2) == int64(2))
assert(int64(4) % int64(3) == int64(1))
assert(int64(2) ^ int64(3) == int64(8))
assert(int64(1) + 2 == int64(3))
assert(int64(1) - 2 == int64(-1))
assert(int64(2) * 3 == int64(6))
assert(int64(4) / 2 == int64(2))
assert(int64(4) % 3 == int64(1))
assert(int64(2) ^ 3 == int64(8))
-- tostring
assert(tostring(int64(2)) == "2")
-- index/newindex; note, mutable userdatas aren't very idiomatic but we need to test this
do
local v = int64(42)
assert(v.value == 42)
v.value = 4
assert(v.value == 4)
assert(v == int64(4))
end
return 'OK'