luau/tests/conformance/native_userdata.lua
Andy Friesen 0fa6a51c91
Sync to upstream/release/629 (#1290)
### What's new

* Implemented parsing logic for attributes
* Added `lua_setuserdatametatable` and `lua_getuserdatametatable` C API
methods for a faster userdata metatable fetch compared to
`luaL_getmetatable`. Note that metatable reference has to still be
pinned in memory!

### New Solver

* Further improvement to the assignment inference logic
* Fix many bugs surrounding constraint dispatch order

### Native Codegen

* Add IR lowering hooks for custom host userdata types
* Add IR to create new tagged userdata objects
* Remove outdated NativeState

---
### Internal Contributors

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: Vighnesh Vijay <vvijay@roblox.com>
Co-authored-by: Vyacheslav Egorov <vegorov@roblox.com>
2024-06-07 10:51:12 -07:00

43 lines
797 B
Lua

-- This file is part of the Luau programming language and is licensed under MIT License; see LICENSE.txt for details
print('testing userdata')
function ecall(fn, ...)
local ok, err = pcall(fn, ...)
assert(not ok)
return err:sub((err:find(": ") or -1) + 2, #err)
end
local function realmad(a: vec2, b: vec2, c: vec2): vec2
return -c + a * b;
end
local function dm(s: vec2, t: vec2, u: vec2)
local x = s:Dot(t)
assert(x == 13)
local t = u:Min(s)
assert(t.X == 5)
assert(t.Y == 4)
end
local s: vec2 = vec2(5, 4)
local t: vec2 = vec2(1, 2)
local u: vec2 = vec2(10, 20)
local x: vec2 = realmad(s, t, u)
assert(x.X == -5)
assert(x.Y == -12)
dm(s, t, u)
local function mu(v: vec2)
assert(v.Magnitude == 2)
assert(v.Unit.X == 0)
assert(v.Unit.Y == 1)
end
mu(vec2(0, 2))
return 'OK'