Skip to content

Commit 24b1101

Browse files
committed
Cleaned up a bit so that the __index field of metatables is set only once instead of in each constructor
1 parent 9b343b9 commit 24b1101

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

mock.lua

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ function mockCalled(m, name, args)
1212
return subscriber(m, name, args)
1313
end
1414

15-
ExpectedCall = {}
15+
local ExpectedCall = {}
16+
ExpectedCall.__index = ExpectedCall
1617

1718
function ExpectedCall:new(f, required, args)
1819
local o = {
@@ -23,7 +24,6 @@ function ExpectedCall:new(f, required, args)
2324
_return = {}
2425
}
2526

26-
self.__index = self
2727
setmetatable(o, self)
2828

2929
return o
@@ -63,7 +63,8 @@ function ExpectedCall:isRequired()
6363
return self._required
6464
end
6565

66-
MockExpectation = {}
66+
local MockExpectation = {}
67+
MockExpectation.__index = MockExpectation
6768

6869
function MockExpectation:new(m)
6970
local o = {
@@ -72,7 +73,6 @@ function MockExpectation:new(m)
7273
_calls = {}
7374
}
7475

75-
self.__index = self
7676
setmetatable(o, self)
7777

7878
return o

0 commit comments

Comments
 (0)