@@ -20,6 +20,13 @@ function mock_called(m, name, args)
20
20
return subscriber (m , name , args )
21
21
end
22
22
23
+ function create_expectation (_ , method )
24
+ return function (self , ...)
25
+ local expectation = Expectation (self )
26
+ return expectation [method ](expectation , ... )
27
+ end
28
+ end
29
+
23
30
function mach .mock_function (name )
24
31
name = name or ' <anonymous>'
25
32
local f = {}
@@ -29,12 +36,7 @@ function mach.mock_function(name)
29
36
return mock_called (f , name , table.pack (... ))
30
37
end ,
31
38
32
- __index = function (_ , method )
33
- return function (self , ...)
34
- local expectation = Expectation (self )
35
- return expectation [method ](expectation , ... )
36
- end
37
- end
39
+ __index = create_expectation
38
40
})
39
41
40
42
return f
@@ -50,12 +52,7 @@ function mach.mock_method(name)
50
52
return mock_called (m , name , args )
51
53
end ,
52
54
53
- __index = function (_ , method )
54
- return function (self , ...)
55
- local expectation = Expectation (self )
56
- return expectation [method ](expectation , ... )
57
- end
58
- end
55
+ __index = create_expectation
59
56
})
60
57
61
58
return m
0 commit comments