Skip to content

Commit eb2e6cb

Browse files
authored
Create test_game.lua
1 parent 0791585 commit eb2e6cb

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

tests/test_game.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
-- Basic unit test in Lua (run with `lua test_game.lua`)
2+
3+
require("game")
4+
require("data")
5+
6+
-- Test move
7+
player.location = "start"
8+
move("north")
9+
assert(player.location == "cave", "Move north failed")
10+
11+
-- Test pickup
12+
player.location = "river"
13+
pickup()
14+
assert(#player.inventory == 1 and player.inventory[1].name == "Shiny Sword", "Pickup failed")
15+
16+
print("All tests passed ✅")

0 commit comments

Comments
 (0)