Fix vector.from_string returning a table without vector metatable

This commit is contained in:
Desour 2022-01-02 17:16:16 +01:00 committed by ShadowNinja
parent 84fdd369d4
commit 1965628705
2 changed files with 2 additions and 1 deletions

View File

@ -300,6 +300,7 @@ describe("vector", function()
it("from_string()", function()
local v = vector.new(1, 2, 3.14)
assert.is_true(vector.check(vector.from_string("(1, 2, 3.14)")))
assert.same({v, 13}, {vector.from_string("(1, 2, 3.14)")})
assert.same({v, 12}, {vector.from_string("(1,2 ,3.14)")})
assert.same({v, 12}, {vector.from_string("(1,2,3.14,)")})

View File

@ -61,7 +61,7 @@ function vector.from_string(s, init)
if not (x and y and z) then
return nil
end
return {x = x, y = y, z = z}, np
return fast_new(x, y, z), np
end
function vector.to_string(v)