mirror of
https://github.com/kikito/middleclass.git
synced 2024-11-08 09:34:22 +00:00
fixes luacheck errors
This commit is contained in:
parent
443dd5e3f5
commit
bffb00b195
@ -20,7 +20,7 @@ install:
|
|||||||
- luarocks install luacov-coveralls
|
- luarocks install luacov-coveralls
|
||||||
|
|
||||||
script:
|
script:
|
||||||
- luacheck --std max+busted *.lua spec
|
- luacheck --no-unused-args --std max+busted *.lua spec
|
||||||
- busted --verbose --coverage
|
- busted --verbose --coverage
|
||||||
|
|
||||||
after_success:
|
after_success:
|
||||||
|
@ -138,8 +138,8 @@ local DefaultMixin = {
|
|||||||
|
|
||||||
local subclass = _createClass(name, self)
|
local subclass = _createClass(name, self)
|
||||||
|
|
||||||
for name, f in pairs(self.__instanceDict) do
|
for methodName, f in pairs(self.__instanceDict) do
|
||||||
_propagateInstanceMethod(subclass, name, f)
|
_propagateInstanceMethod(subclass, methodName, f)
|
||||||
end
|
end
|
||||||
subclass.initialize = function(instance, ...) return self.initialize(instance, ...) end
|
subclass.initialize = function(instance, ...) return self.initialize(instance, ...) end
|
||||||
|
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local class = require 'middleclass'
|
local class = require 'middleclass'
|
||||||
local Object = class.Object
|
|
||||||
|
|
||||||
describe('class()', function()
|
describe('class()', function()
|
||||||
|
|
||||||
|
@ -204,7 +204,7 @@ describe('Default methods', function()
|
|||||||
describe('A ' .. theType, function()
|
describe('A ' .. theType, function()
|
||||||
|
|
||||||
local f1 = function() return Object.isSubclassOf(Object, primitive) end
|
local f1 = function() return Object.isSubclassOf(Object, primitive) end
|
||||||
local f2 = function() return Object.isSubclassOf(primitive, o) end
|
local f2 = function() return Object.isSubclassOf(primitive, Object:new()) end
|
||||||
local f3 = function() return Object.isSubclassOf(primitive, primitive) end
|
local f3 = function() return Object.isSubclassOf(primitive, primitive) end
|
||||||
|
|
||||||
describe('does not throw errors', function()
|
describe('does not throw errors', function()
|
||||||
|
@ -6,7 +6,7 @@ local before_each = require('busted').before_each
|
|||||||
local assert = require('busted').assert
|
local assert = require('busted').assert
|
||||||
|
|
||||||
describe('Lua 5.2 Metamethods', function()
|
describe('Lua 5.2 Metamethods', function()
|
||||||
local Vector, a, b
|
local Vector, v
|
||||||
before_each(function()
|
before_each(function()
|
||||||
Vector= class('Vector')
|
Vector= class('Vector')
|
||||||
function Vector.initialize(a,x,y,z) a.x, a.y, a.z = x,y,z end
|
function Vector.initialize(a,x,y,z) a.x, a.y, a.z = x,y,z end
|
||||||
@ -16,69 +16,67 @@ describe('Lua 5.2 Metamethods', function()
|
|||||||
function Vector.__pairs(a)
|
function Vector.__pairs(a)
|
||||||
local t = {x=a.x,y=a.y,z=a.z}
|
local t = {x=a.x,y=a.y,z=a.z}
|
||||||
return coroutine.wrap(function()
|
return coroutine.wrap(function()
|
||||||
for k,v in pairs(t) do
|
for k,val in pairs(t) do
|
||||||
coroutine.yield(k,v)
|
coroutine.yield(k,val)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
function Vector.__ipairs(a)
|
function Vector.__ipairs(a)
|
||||||
local t = {a.x,a.y,a.z}
|
local t = {a.x,a.y,a.z}
|
||||||
return coroutine.wrap(function()
|
return coroutine.wrap(function()
|
||||||
for k,v in ipairs(t) do
|
for k,val in ipairs(t) do
|
||||||
coroutine.yield(k,v)
|
coroutine.yield(k,val)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
a = Vector:new(1,2,3)
|
v = Vector:new(1,2,3)
|
||||||
b = Vector:new(2,4,6)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __len', function()
|
it('implements __len', function()
|
||||||
assert.equal(#a, 3)
|
assert.equal(#v, 3)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __pairs',function()
|
it('implements __pairs',function()
|
||||||
local output = {}
|
local output = {}
|
||||||
for k,v in pairs(a) do
|
for k,val in pairs(v) do
|
||||||
output[k] = v
|
output[k] = val
|
||||||
end
|
end
|
||||||
assert.are.same(output,{x=1,y=2,z=3})
|
assert.are.same(output,{x=1,y=2,z=3})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __ipairs',function()
|
it('implements __ipairs',function()
|
||||||
local output = {}
|
local output = {}
|
||||||
for _,i in ipairs(a) do
|
for _,i in ipairs(v) do
|
||||||
output[#output+1] = i
|
output[#output+1] = i
|
||||||
end
|
end
|
||||||
assert.are.same(output,{1,2,3})
|
assert.are.same(output,{1,2,3})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('Inherited Metamethods', function()
|
describe('Inherited Metamethods', function()
|
||||||
local Vector2, c, d
|
local Vector2, v2
|
||||||
before_each(function()
|
before_each(function()
|
||||||
Vector2= class('Vector2', Vector)
|
Vector2= class('Vector2', Vector)
|
||||||
function Vector2:initialize(x,y,z) Vector.initialize(self,x,y,z) end
|
function Vector2:initialize(x,y,z) Vector.initialize(self,x,y,z) end
|
||||||
|
|
||||||
c = Vector2:new(1,2,3)
|
v2 = Vector2:new(1,2,3)
|
||||||
d = Vector2:new(2,4,6)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __len', function()
|
it('implements __len', function()
|
||||||
assert.equal(#c, 3)
|
assert.equal(#v2, 3)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __pairs',function()
|
it('implements __pairs',function()
|
||||||
local output = {}
|
local output = {}
|
||||||
for k,v in pairs(c) do
|
for k,val in pairs(v2) do
|
||||||
output[k] = v
|
output[k] = val
|
||||||
end
|
end
|
||||||
assert.are.same(output,{x=1,y=2,z=3})
|
assert.are.same(output,{x=1,y=2,z=3})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __ipairs',function()
|
it('implements __ipairs',function()
|
||||||
local output = {}
|
local output = {}
|
||||||
for _,i in ipairs(c) do
|
for _,i in ipairs(v2) do
|
||||||
output[#output+1] = i
|
output[#output+1] = i
|
||||||
end
|
end
|
||||||
assert.are.same(output,{1,2,3})
|
assert.are.same(output,{1,2,3})
|
||||||
|
@ -6,7 +6,7 @@ local before_each = require('busted').before_each
|
|||||||
local assert = require('busted').assert
|
local assert = require('busted').assert
|
||||||
|
|
||||||
describe('Lua 5.3 Metamethods', function()
|
describe('Lua 5.3 Metamethods', function()
|
||||||
local Vector, a, b, last_gc
|
local Vector, v, last_gc
|
||||||
before_each(function()
|
before_each(function()
|
||||||
Vector= class('Vector')
|
Vector= class('Vector')
|
||||||
function Vector.initialize(a,x,y,z) a.x, a.y, a.z = x,y,z end
|
function Vector.initialize(a,x,y,z) a.x, a.y, a.z = x,y,z end
|
||||||
@ -14,8 +14,8 @@ describe('Lua 5.3 Metamethods', function()
|
|||||||
function Vector.__pairs(a)
|
function Vector.__pairs(a)
|
||||||
local t = {x=a.x,y=a.y,z=a.z}
|
local t = {x=a.x,y=a.y,z=a.z}
|
||||||
return coroutine.wrap(function()
|
return coroutine.wrap(function()
|
||||||
for k,v in pairs(t) do
|
for k,val in pairs(t) do
|
||||||
coroutine.yield(k,v)
|
coroutine.yield(k,val)
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
@ -29,80 +29,78 @@ describe('Lua 5.3 Metamethods', function()
|
|||||||
function Vector.__shr(a,n) return a.class:new(a.x >> n, a.y >> n, a.z >> n) end
|
function Vector.__shr(a,n) return a.class:new(a.x >> n, a.y >> n, a.z >> n) end
|
||||||
function Vector.__bnot(a) return a.class:new(~a.x, ~a.y, ~a.z) end
|
function Vector.__bnot(a) return a.class:new(~a.x, ~a.y, ~a.z) end
|
||||||
|
|
||||||
a = Vector:new(1,2,3)
|
v = Vector:new(1,2,3)
|
||||||
b = Vector:new(2,4,6)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __gc', function()
|
it('implements __gc', function()
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
a = nil
|
v = nil
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
assert.are.same(last_gc, {"Vector",1,2,3})
|
assert.are.same(last_gc, {"Vector",1,2,3})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __band', function()
|
it('implements __band', function()
|
||||||
assert.equal(a & 1, Vector(1,0,1))
|
assert.equal(v & 1, Vector(1,0,1))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __bor', function()
|
it('implements __bor', function()
|
||||||
assert.equal(a | 0, Vector(1,2,3))
|
assert.equal(v | 0, Vector(1,2,3))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __bxor', function()
|
it('implements __bxor', function()
|
||||||
assert.equal(a | 1, Vector(1,3,3))
|
assert.equal(v | 1, Vector(1,3,3))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __shl', function()
|
it('implements __shl', function()
|
||||||
assert.equal(a << 1, Vector(2,4,6))
|
assert.equal(v << 1, Vector(2,4,6))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __shr', function()
|
it('implements __shr', function()
|
||||||
assert.equal(a >> 1, Vector(0,1,1))
|
assert.equal(v >> 1, Vector(0,1,1))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __bnot', function()
|
it('implements __bnot', function()
|
||||||
assert.equal(~a, Vector(-2,-3,-4))
|
assert.equal(~v, Vector(-2,-3,-4))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('Inherited Metamethods', function()
|
describe('Inherited Metamethods', function()
|
||||||
local Vector2, c, d
|
local Vector2, v2
|
||||||
before_each(function()
|
before_each(function()
|
||||||
Vector2= class('Vector2', Vector)
|
Vector2= class('Vector2', Vector)
|
||||||
function Vector2:initialize(x,y,z) Vector.initialize(self,x,y,z) end
|
function Vector2:initialize(x,y,z) Vector.initialize(self,x,y,z) end
|
||||||
|
|
||||||
c = Vector2:new(1,2,3)
|
v2 = Vector2:new(1,2,3)
|
||||||
d = Vector2:new(2,4,6)
|
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __gc', function()
|
it('implements __gc', function()
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
c = nil
|
v2 = nil
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
assert.are.same(last_gc, {"Vector2",1,2,3})
|
assert.are.same(last_gc, {"Vector2",1,2,3})
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __band', function()
|
it('implements __band', function()
|
||||||
assert.equal(c & 1, Vector2(1,0,1))
|
assert.equal(v2 & 1, Vector2(1,0,1))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __bor', function()
|
it('implements __bor', function()
|
||||||
assert.equal(c | 0, Vector2(1,2,3))
|
assert.equal(v2 | 0, Vector2(1,2,3))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __bxor', function()
|
it('implements __bxor', function()
|
||||||
assert.equal(c | 1, Vector2(1,3,3))
|
assert.equal(v2 | 1, Vector2(1,3,3))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __shl', function()
|
it('implements __shl', function()
|
||||||
assert.equal(c << 1, Vector2(2,4,6))
|
assert.equal(v2 << 1, Vector2(2,4,6))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __shr', function()
|
it('implements __shr', function()
|
||||||
assert.equal(c >> 1, Vector2(0,1,1))
|
assert.equal(v2 >> 1, Vector2(0,1,1))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __bnot', function()
|
it('implements __bnot', function()
|
||||||
assert.equal(~c, Vector2(-2,-3,-4))
|
assert.equal(~v2, Vector2(-2,-3,-4))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
@ -1,5 +1,4 @@
|
|||||||
local class = require 'middleclass'
|
local class = require 'middleclass'
|
||||||
local Object = class.Object
|
|
||||||
|
|
||||||
local function is_lua_5_2_compatible()
|
local function is_lua_5_2_compatible()
|
||||||
return type(rawlen) == 'function'
|
return type(rawlen) == 'function'
|
||||||
@ -19,7 +18,7 @@ end
|
|||||||
|
|
||||||
describe('Metamethods', function()
|
describe('Metamethods', function()
|
||||||
describe('Custom Metamethods', function()
|
describe('Custom Metamethods', function()
|
||||||
local Vector, a, b
|
local Vector, v, w
|
||||||
before_each(function()
|
before_each(function()
|
||||||
Vector= class('Vector')
|
Vector= class('Vector')
|
||||||
function Vector.initialize(a,x,y,z) a.x, a.y, a.z = x,y,z end
|
function Vector.initialize(a,x,y,z) a.x, a.y, a.z = x,y,z end
|
||||||
@ -43,62 +42,62 @@ describe('Metamethods', function()
|
|||||||
Vector.__metatable = "metatable of a vector"
|
Vector.__metatable = "metatable of a vector"
|
||||||
Vector.__mode = "k"
|
Vector.__mode = "k"
|
||||||
|
|
||||||
a = Vector:new(1,2,3)
|
v = Vector:new(1,2,3)
|
||||||
b = Vector:new(2,4,6)
|
w = Vector:new(2,4,6)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __tostring', function()
|
it('implements __tostring', function()
|
||||||
assert.equal(tostring(a), "Vector[1,2,3]")
|
assert.equal(tostring(v), "Vector[1,2,3]")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __eq', function()
|
it('implements __eq', function()
|
||||||
assert.equal(a, a)
|
assert.equal(v, v)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __lt', function()
|
it('implements __lt', function()
|
||||||
assert.is_true(a < b)
|
assert.is_true(v < w)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __le', function()
|
it('implements __le', function()
|
||||||
assert.is_true(a <= b)
|
assert.is_true(v <= w)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __add', function()
|
it('implements __add', function()
|
||||||
assert.equal(a+b, Vector(3,6,9))
|
assert.equal(v+w, Vector(3,6,9))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __sub', function()
|
it('implements __sub', function()
|
||||||
assert.equal(b-a, Vector(1,2,3))
|
assert.equal(w-v, Vector(1,2,3))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __div', function()
|
it('implements __div', function()
|
||||||
assert.equal(b/2, Vector(1,2,3))
|
assert.equal(w/2, Vector(1,2,3))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __concat', function()
|
it('implements __concat', function()
|
||||||
assert.equal(a..b, 28)
|
assert.equal(v..w, 28)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __call', function()
|
it('implements __call', function()
|
||||||
assert.equal(a(), math.sqrt(14))
|
assert.equal(v(), math.sqrt(14))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __pow', function()
|
it('implements __pow', function()
|
||||||
assert.equal(a^b, Vector(0,0,0))
|
assert.equal(v^w, Vector(0,0,0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __mul', function()
|
it('implements __mul', function()
|
||||||
assert.equal(4*a, Vector(4,8,12))
|
assert.equal(4*v, Vector(4,8,12))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __metatable', function()
|
it('implements __metatable', function()
|
||||||
assert.equal("metatable of a vector", getmetatable(a))
|
assert.equal("metatable of a vector", getmetatable(v))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __mode', function()
|
it('implements __mode', function()
|
||||||
a[{}] = true
|
v[{}] = true
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
for k in pairs(a) do assert.not_table(k) end
|
for k in pairs(v) do assert.not_table(k) end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--[[
|
--[[
|
||||||
@ -108,97 +107,97 @@ describe('Metamethods', function()
|
|||||||
--]]
|
--]]
|
||||||
|
|
||||||
describe('Inherited Metamethods', function()
|
describe('Inherited Metamethods', function()
|
||||||
local Vector2, c, d
|
local Vector2, v2, w2
|
||||||
before_each(function()
|
before_each(function()
|
||||||
Vector2= class('Vector2', Vector)
|
Vector2= class('Vector2', Vector)
|
||||||
function Vector2:initialize(x,y,z) Vector.initialize(self,x,y,z) end
|
function Vector2:initialize(x,y,z) Vector.initialize(self,x,y,z) end
|
||||||
|
|
||||||
c = Vector2:new(1,2,3)
|
v2 = Vector2:new(1,2,3)
|
||||||
d = Vector2:new(2,4,6)
|
w2 = Vector2:new(2,4,6)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __tostring', function()
|
it('implements __tostring', function()
|
||||||
assert.equal(tostring(c), "Vector2[1,2,3]")
|
assert.equal(tostring(v2), "Vector2[1,2,3]")
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __eq', function()
|
it('implements __eq', function()
|
||||||
assert.equal(c, c)
|
assert.equal(v2, v2)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __lt', function()
|
it('implements __lt', function()
|
||||||
assert.is_true(c < d)
|
assert.is_true(v2 < w2)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __le', function()
|
it('implements __le', function()
|
||||||
assert.is_true(c <= d)
|
assert.is_true(v2 <= w2)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __add', function()
|
it('implements __add', function()
|
||||||
assert.equal(c+d, Vector2(3,6,9))
|
assert.equal(v2+w2, Vector2(3,6,9))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __sub', function()
|
it('implements __sub', function()
|
||||||
assert.equal(d-c, Vector2(1,2,3))
|
assert.equal(w2-v2, Vector2(1,2,3))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __div', function()
|
it('implements __div', function()
|
||||||
assert.equal(d/2, Vector2(1,2,3))
|
assert.equal(w2/2, Vector2(1,2,3))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __concat', function()
|
it('implements __concat', function()
|
||||||
assert.equal(c..d, 28)
|
assert.equal(v2..w2, 28)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __call', function()
|
it('implements __call', function()
|
||||||
assert.equal(c(), math.sqrt(14))
|
assert.equal(v2(), math.sqrt(14))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __pow', function()
|
it('implements __pow', function()
|
||||||
assert.equal(c^d, Vector2(0,0,0))
|
assert.equal(v2^w2, Vector2(0,0,0))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __mul', function()
|
it('implements __mul', function()
|
||||||
assert.equal(4*c, Vector2(4,8,12))
|
assert.equal(4*v2, Vector2(4,8,12))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __metatable', function()
|
it('implements __metatable', function()
|
||||||
assert.equal("metatable of a vector", getmetatable(c))
|
assert.equal("metatable of a vector", getmetatable(v2))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('implements __mode', function()
|
it('implements __mode', function()
|
||||||
c[{}] = true
|
v2[{}] = true
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
for k in pairs(c) do assert.not_table(k) end
|
for k in pairs(v2) do assert.not_table(k) end
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('allows inheriting further', function()
|
it('allows inheriting further', function()
|
||||||
local Vector3 = class('Vector3', Vector2)
|
local Vector3 = class('Vector3', Vector2)
|
||||||
local e = Vector3(1,2,3)
|
local v3 = Vector3(1,2,3)
|
||||||
local f = Vector3(3,4,5)
|
local w3 = Vector3(3,4,5)
|
||||||
assert.equal(e+f, Vector3(4,6,8))
|
assert.equal(v3+w3, Vector3(4,6,8))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
describe('Updates', function()
|
describe('Updates', function()
|
||||||
it('overrides __add', function()
|
it('overrides __add', function()
|
||||||
Vector2.__add = function(a, b) return Vector.__add(a, b)/2 end
|
Vector2.__add = function(a, b) return Vector.__add(a, b)/2 end
|
||||||
assert.equal(c+d, Vector2(1.5,3,4.5))
|
assert.equal(v2+w2, Vector2(1.5,3,4.5))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('updates __add', function()
|
it('updates __add', function()
|
||||||
Vector.__add = Vector.__sub
|
Vector.__add = Vector.__sub
|
||||||
assert.equal(c+d, Vector2(-1,-2,-3))
|
assert.equal(v2+w2, Vector2(-1,-2,-3))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('does not update __add after overriding', function()
|
it('does not update __add after overriding', function()
|
||||||
Vector2.__add = function(a, b) return Vector.__add(a, b)/2 end
|
Vector2.__add = function(a, b) return Vector.__add(a, b)/2 end
|
||||||
Vector.__add = Vector.__sub
|
Vector.__add = Vector.__sub
|
||||||
assert.equal(c+d, Vector2(-0.5,-1,-1.5))
|
assert.equal(v2+w2, Vector2(-0.5,-1,-1.5))
|
||||||
end)
|
end)
|
||||||
|
|
||||||
it('reverts __add override', function()
|
it('reverts __add override', function()
|
||||||
Vector2.__add = function(a, b) return Vector.__add(a, b)/2 end
|
Vector2.__add = function(a, b) return Vector.__add(a, b)/2 end
|
||||||
Vector2.__add = nil
|
Vector2.__add = nil
|
||||||
assert.equal(c+d, Vector2(3,6,9))
|
assert.equal(v2+w2, Vector2(3,6,9))
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
end)
|
end)
|
||||||
|
Loading…
Reference in New Issue
Block a user