forked from Mirrorlandia_minetest/minetest
Fix vector.from_string returning a table without vector metatable
This commit is contained in:
parent
84fdd369d4
commit
1965628705
@ -300,6 +300,7 @@ describe("vector", function()
|
|||||||
|
|
||||||
it("from_string()", function()
|
it("from_string()", function()
|
||||||
local v = vector.new(1, 2, 3.14)
|
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, 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)")})
|
||||||
assert.same({v, 12}, {vector.from_string("(1,2,3.14,)")})
|
assert.same({v, 12}, {vector.from_string("(1,2,3.14,)")})
|
||||||
|
@ -61,7 +61,7 @@ function vector.from_string(s, init)
|
|||||||
if not (x and y and z) then
|
if not (x and y and z) then
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
return {x = x, y = y, z = z}, np
|
return fast_new(x, y, z), np
|
||||||
end
|
end
|
||||||
|
|
||||||
function vector.to_string(v)
|
function vector.to_string(v)
|
||||||
|
Loading…
Reference in New Issue
Block a user