-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdemo_output.lua
More file actions
125 lines (114 loc) · 2.73 KB
/
demo_output.lua
File metadata and controls
125 lines (114 loc) · 2.73 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
local ulu=require "ulutest"
--[[
Demonstrate each combination of
Test predicate (EXPECT, EXPECT_NIL, EXPECT_EQ, ASSERT, ASSERT_NIL, ASSERT_EQ)
with result (ok, fail)
with hint (present, not present)
==> 6*2*2 = 24 Tests from 6 cases
--]]
ulu.RUN(
{
name="EXPECT",
ulu.TT("succeeds", function(t)
t:EXPECT(1<2)
end),
ulu.TT("succeeds_with_hint", function(t)
t:EXPECT(1<2, "has to be less")
end),
ulu.TT("fails", function(t)
local result=1
t:EXPECT(result>2)
end),
ulu.TT("fails_with_hint", function(t)
local result=1
t:EXPECT(result>2, "result should be greater than 2")
end)
},
{
name="EXPECT_NIL",
ulu.TT("succeeds", function(t)
t:EXPECT_NIL(nil)
end),
ulu.TT("succeeds_with_hint", function(t)
t:EXPECT_NIL(nil, "has to be nil")
end),
ulu.TT("fails", function(t)
t:EXPECT_NIL(true)
end),
ulu.TT("fails_with_hint", function(t)
local result=true
t:EXPECT_NIL(result, "result")
end)
},
{
name="EXPECT_EQ",
ulu.TT("succeeds", function(t)
local result=3
t:EXPECT_EQ(3, result)
end),
ulu.TT("succeeds_with_hint", function(t)
local result=3
t:EXPECT_EQ(3, result, "result")
end),
ulu.TT("fails", function(t)
local result=2
t:EXPECT_EQ(3, result)
end),
ulu.TT("fails_with_hint", function(t)
local result=2
t:EXPECT_EQ(3, result, "result")
end)
},
{
name="ASSERT",
ulu.TT("succeeds", function(t)
t:ASSERT(1<2)
end),
ulu.TT("succeeds_with_hint", function(t)
t:ASSERT(1<2, "has to be less")
end),
ulu.TT("fails", function(t)
local result=1
t:ASSERT(result>2)
end),
ulu.TT("fails_with_hint", function(t)
local result=1
t:ASSERT(result>2, "result should be greater than 2")
end)
},
{
name="ASSERT_NIL",
ulu.TT("succeeds_with_no_hint", function(t)
t:ASSERT_NIL(nil)
end),
ulu.TT("succeeds", function(t)
t:ASSERT_NIL(nil, "has to be nil")
end),
ulu.TT("fails_with_no_hint", function(t)
t:ASSERT_NIL(true)
end),
ulu.TT("fails", function(t)
local result=true
t:ASSERT_NIL(result, "result")
end)
},
{
name="ASSERT_EQ",
ulu.TT("succeeds_with_no_hint", function(t)
local result=3
t:ASSERT_EQ(3, result)
end),
ulu.TT("succeeds", function(t)
local result=3
t:ASSERT_EQ(3, result, "result")
end),
ulu.TT("fails", function(t)
local result=2
t:ASSERT_EQ(3, result)
end),
ulu.TT("fails_with_hint", function(t)
local result=2
t:ASSERT_EQ(3, result, "result")
end)
}
)