diff --git a/test/luajit-tap/fold_bug_LuaJIT_505.test.lua b/test/luajit-tap/fold_bug_LuaJIT_505.test.lua new file mode 100755 index 0000000000000000000000000000000000000000..2fee0696405a83e93baeb4e5f8f0a45fde713dd8 --- /dev/null +++ b/test/luajit-tap/fold_bug_LuaJIT_505.test.lua @@ -0,0 +1,20 @@ +#!/usr/bin/env tarantool + +tap = require('tap') + +test = tap.test("505") +test:plan(1) + +-- Test file to demonstrate Lua fold machinery icorrect behavior, details: +-- https://github.com/LuaJIT/LuaJIT/issues/505 + +jit.opt.start("hotloop=1") +for _ = 1, 20 do + local value = "abc" + local pos_c = string.find(value, "c", 1, true) + local value2 = string.sub(value, 1, pos_c - 1) + local pos_b = string.find(value2, "b", 2, true) + assert(pos_b == 2, "FAIL: position of 'b' is " .. pos_b) +end + +test:ok("PASS")