diff --git a/.travis.yml b/.travis.yml index f36c61f..0165824 100644 --- a/.travis.yml +++ b/.travis.yml @@ -25,7 +25,9 @@ install: - luarocks make script: - - make lint && busted -v --coverage -o gtest --repeat 3 spec + - make lint + - busted --exclude-tags=JIT -v --coverage -o gtest --repeat 3 spec + - if [ "$LUA" == "luajit 2.1" ]; then busted -v -o gtest --tags JIT fi after_success: - luacov-coveralls -i ./src/argon2.lua diff --git a/spec/argon2_spec.lua b/spec/argon2_spec.lua index 26e6d6a..78a4423 100644 --- a/spec/argon2_spec.lua +++ b/spec/argon2_spec.lua @@ -233,6 +233,46 @@ describe("verify()", function() end) end) +describe("#JIT", function() + + local function read_trace(outfile) + local f = assert(io.open(outfile, "r")) + local t = f:read("*a") + f:close() + return t + end + + it("hash_encoded() JITs", function() + local v = require "jit.v" + local outfile = os.tmpname() + v.on(outfile) + + for _ = 1, 100 do + argon2.hash_encoded("password", "somesalt") + end + + local trace = read_trace(outfile) + assert.matches("argon2_spec%.lua:%d+ loop", trace) + assert.not_matches("NYI", trace) + end) + + it("verify() JITs", function() + local v = require "jit.v" + local outfile = os.tmpname() + v.on(outfile) + + local hash = assert(argon2.hash_encoded("password", "somesalt")) + + for _ = 1, 100 do + argon2.verify(hash, "password") + end + + local trace = read_trace(outfile) + assert.matches("argon2_spec%.lua:%d+ loop", trace) + assert.not_matches("NYI", trace) + end) +end) + --[[ pending("module settings", function()