-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathexample_tests.lua
47 lines (34 loc) · 1.28 KB
/
example_tests.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
local cute = require("cute")
local shapes = require("src.shapes")
notion("Can compare numbers, strings, etc", function ()
check(1).is(1)
check("hello").is("hello")
end)
notion("Can compare tables", function ()
check({1,2,3}).shallowMatches({1,2,3})
check({one="two", three="four"}).shallowMatches({one="two", three="four"})
end)
notion("Can check things that draw", function ()
minion("rectangleMinion", love.graphics, 'rectangle')
minion("setColorMinion", love.graphics, 'setColor')
shapes.tiles(love.graphics)
check(report("rectangleMinion").calls).is(1938)
check(report("setColorMinion").calls).is(1938)
check(report("rectangleMinion").args[1][1]).is('fill')
end)
notion("Minions get reset after each call", function ()
minion("setColorMinion", love.graphics, "setColor")
minion("circleMinion", love.graphics, "circle")
shapes.circle(100)
check(report("setColorMinion").calls).is(1)
check(report("circleMinion").args[1]).shallowMatches({"line", 400, 300, 0, 100})
end)
notion("Can overwrite return values", function ()
minion("width", love.graphics, "getWidth").nobbleReturnValue(12345)
local foo = love.graphics.getWidth()
check(foo).is(12345)
end)
notion("Return values are reset", function ()
local bar = love.graphics.getWidth()
check(bar).is(800)
end)