diff options
Diffstat (limited to 'spec/test1_spec.lua')
| -rw-r--r-- | spec/test1_spec.lua | 58 |
1 files changed, 58 insertions, 0 deletions
diff --git a/spec/test1_spec.lua b/spec/test1_spec.lua new file mode 100644 index 0000000..bcb5756 --- /dev/null +++ b/spec/test1_spec.lua @@ -0,0 +1,58 @@ +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 = {...} + 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) |
