diff options
author | elioat <elioat@tilde.institute> | 2024-06-09 11:10:57 -0400 |
---|---|---|
committer | elioat <elioat@tilde.institute> | 2024-06-09 11:10:57 -0400 |
commit | b72b5e6ab57173afd5daa555396f8d0c7aa9c1f6 (patch) | |
tree | 6722e5f6d97a7c54d707ce0f5ff77226bef6a108 /lua/chupacabra/test_chupacabra.lua | |
parent | 0d5a8c704d517e7f880c5b704867e3d491e9ec8f (diff) | |
download | tour-b72b5e6ab57173afd5daa555396f8d0c7aa9c1f6.tar.gz |
*
Diffstat (limited to 'lua/chupacabra/test_chupacabra.lua')
-rw-r--r-- | lua/chupacabra/test_chupacabra.lua | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/lua/chupacabra/test_chupacabra.lua b/lua/chupacabra/test_chupacabra.lua new file mode 100644 index 0000000..4d75f70 --- /dev/null +++ b/lua/chupacabra/test_chupacabra.lua @@ -0,0 +1,22 @@ +local chupacabra = require("chupacabra") + +-- Define a function to run a test case +local function test_case(input, expected_output) + local output = chupacabra.run(input, {}) + assert(output == expected_output, "Test failed: " .. input .. " => " .. output .. ", expected: " .. expected_output) + print("Test passed: " .. input .. " => " .. output) +end + + +-- Run some test cases +test_case("1", 1) -- 1 +test_case("2 1 pop", 2) -- 2 +test_case("3 4 +", 7) -- 3 + 4 = 7 +test_case("5 2 -", 3) -- 5 - 2 = 3 +test_case("2 3 *", 6) -- 2 * 3 = 6 +test_case("8 2 /", 4) -- 8 / 2 = 4 +test_case("2 3 4 + *", 14) -- 2 * (3 + 4) = 14 +test_case("5 2 3 + 4 + +", 14) -- 5 + 2 + 3 + 4 = 14 +test_case("7 2 + 3 4 + +", 16) -- 7 + 2 + 3 + 4 = 16 +test_case("5 2 - 3 4 * +", 15) -- (5 - 2) + (3 * 4) = 15 +test_case("8 2 / 3 4 * +", 16) -- (8 / 2) + (3 * 4) = 16 \ No newline at end of file |