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
|
print("Hello, world!")
function rungame()
f = io.popen("bin\\client\\bin\\brokengine_client.exe spec/headless","r")
d = f:read("*all")
f:close()
return d
end
function writegame(...)
f = io.open("spec/headless/init.lua","w")
data = {"GAME.crashy()"}
for _,v in pairs({...}) do
data[#data + 1] = v
end
data[#data + 1] = "\nGAME.exit()\n"
f:write(table.concat(data))
f:close()
end
function assert_game_runs()
assert.truthy(rungame():find("\nGoodbye\n$"))
end
describe("Brok[en]gine",function()
it("should run",function()
writegame()
d = rungame()
assert_game_runs()
end)
it("should provide a lua environment",function()
writegame("print(\"Hello from lua!\")")
d = rungame()
assert.truthy(d:find("\nHello from lua!\n"))
end)
for k,v in pairs({
buttons = "newbutton",
checkboxes = "newcheckbox",
colorselectors = "newcolorselector",
editboxes = "neweditbox",
openfiledialogs = "newfileopendialog",
images = "newiguiimage",
labels = "newlabel",
spinboxes = "newspinbox",
treeviews = "newtreeview",
windows = "newwindow",
}) do
it("should provide functions to make gui " .. k,function()
writegame("assert(gui." .. v .. ")")
assert_game_runs()
end)
end
it("should provide functions to get the width and height of the screen",function()
writegame("assert(scrw)")
assert_game_runs()
writegame("assert(scrh)")
assert_game_runs()
end)
end)
|