Skip to content

Commit

Permalink
tests: add test for exponentiation
Browse files Browse the repository at this point in the history
  • Loading branch information
hishamhm committed Oct 17, 2017
1 parent 4740f3d commit 0d9a762
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions spec/coder_spec.lua
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,23 @@ describe("Titan code generator ", function()
local ok, err = call("titan_test", "assert(6==titan_test.sum(1,2,3))")
assert.truthy(ok, err)
end)

it("generates code for exponentiation", function()
local code = [[
function power(a: float, b: float): float
return a ^ b
end
]]
local ast, err = parser.parse(code)
assert.truthy(ast, err)
local ok, err = checker.check(ast, code, "test.titan")
assert.truthy(ok, err)
local ok, err = generate(ast, "titan_test")
assert.truthy(ok, err)
local ok, err = call("titan_test", "assert(titan_test.power(2,3) == 8)")
assert.truthy(ok, err)
end)

end)


0 comments on commit 0d9a762

Please sign in to comment.