aboutsummaryrefslogtreecommitdiff
path: root/spec/test5_spec.lua
diff options
context:
space:
mode:
authorAlexander <alex@cogarr.net>2020-06-29 15:29:03 -0400
committerAlexander <alex@cogarr.net>2020-06-29 15:29:03 -0400
commit80789508b9655d25629223b9dcc84b4cfb77ce45 (patch)
tree37e140e532af61c1ca4699c8b6254cf2cb07ed02 /spec/test5_spec.lua
parent44a1421c393632978d59c0698a93ae22243b97e9 (diff)
downloadbrokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.tar.gz
brokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.tar.bz2
brokengine-80789508b9655d25629223b9dcc84b4cfb77ce45.zip
Updates for mdoc
Also more tests
Diffstat (limited to 'spec/test5_spec.lua')
-rw-r--r--spec/test5_spec.lua108
1 files changed, 108 insertions, 0 deletions
diff --git a/spec/test5_spec.lua b/spec/test5_spec.lua
new file mode 100644
index 0000000..b4b9333
--- /dev/null
+++ b/spec/test5_spec.lua
@@ -0,0 +1,108 @@
+--[[
+physics things
+]]
+package.path = "./spec/?.lua;" .. package.path
+_G.assert = assert
+local common = require("common")
+
+local spawn_1_box = [[
+GAME.crashy()
+local box = phys.newphysbox({8,8,8}, {0,0,0}, 0)
+GAME.exit()
+]]
+
+local spawn_several_boxes = [[
+GAME.crashy()
+for i = 1,100 do
+ phys.newphysbox({8,8,8}, {0,10 * i,0}, 0)
+end
+GAME.exit()
+]]
+
+describe("physics",function()
+ it("should be able to spawn a physics box on the client",function()
+ common.writegame(spawn_1_box)
+ common.assert_game_runs()
+ end)
+ it("should be able to spawn several physics boxes on the client", function()
+ common.writegame(spawn_several_boxes)
+ common.assert_game_runs()
+ end)
+
+end)
+
+local getpos_exists = [[
+GAME.crashy()
+local box = phys.newphysbox({8,8,8}, {0,0,0}, 0)
+local pos = box:getpos()
+for i = 1,3 do
+ assert(pos[i] == 0, "Position is not 0")
+end
+GAME.exit()
+]]
+local getpos_works = [[
+GAME.crashy()
+local box = phys.newphysbox({8,8,8}, {10,20,30}, 0)
+local pos = box:getpos()
+assert(pos[1] == 10)
+assert(pos[2] == 20)
+assert(pos[3] == 30)
+GAME.exit()
+]]
+local setpos_exists = [[
+GAME.crashy()
+local box = phys.newphysbox({8,8,8}, {10,20,30}, 0)
+box:setpos({0,0,0})
+local pos = box:getpos()
+for i = 1,3 do
+ assert(pos[i] == 0)
+end
+GAME.exit()
+]]
+local setpos_works = [[
+GAME.crashy()
+local box = phys.newphysbox({8,8,8}, {0,0,0}, 0)
+box:setpos({10,20,30})
+local pos = box:getpos()
+assert(pos[1] == 10)
+assert(pos[2] == 20)
+assert(pos[3] == 30)
+GAME.exit()
+]]
+local falls = [[
+GAME.crashy()
+local box = phys.newphysbox({8,8,8}, {0,10,0}, 1)
+local ticks = 0
+GAME.tick = function()
+ print("Tick running...")
+ if box:getpos()[2] < 0 then
+ print("Getpos[2] is less, it is ", box:getpos()[2])
+ GAME.exit()
+ end
+ ticks = ticks + 1
+ assert(ticks < 1)
+end
+]]
+describe("physics box", function()
+ it("should have a .getpos() function",function()
+ common.writegame(getpos_exists)
+ common.assert_game_runs()
+ end)
+ it("should have a .getpos() function that returns the box's position",function()
+ common.writegame(getpos_works)
+ common.assert_game_runs()
+ end)
+ it("should have a .setpos() function",function()
+ common.writegame(setpos_exists)
+ common.assert_game_runs()
+ end)
+ it("should have a .setpos() function that sets the box's position",function()
+ common.writegame(setpos_works)
+ common.assert_game_runs()
+ end)
+ it("should fall when given mass",function()
+ --print("About to write should fall when given mass...")
+ common.writegame(falls)
+ common.assert_game_runs()
+ end)
+end)