mirror of
https://github.com/luau-lang/luau.git
synced 2024-11-15 22:35:43 +08:00
61766a692c
* 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
46 lines
1.1 KiB
Lua
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'
|