lean2/tests/lua/threads/tactic1.lua
Leonardo de Moura 97d9765992 fix(tests/lua/threads): increase timeout to make sure it passes the test on slow machines
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
2014-01-15 08:46:14 -08:00

37 lines
985 B
Lua

import("util.lua")
local env = environment()
local ios = io_state()
local Bool = Const("Bool")
env:add_var("p", Bool)
env:add_var("q", Bool)
local p, q = Consts("p, q")
local ctx = context()
S = State()
-- Create tactic t1 in a different Lua State.
-- So, t1 can be executed by a different execution
-- thread
local t1 = S:eval([[
counter1 = 0
return tactic(function(env, ios, s)
while true do
print("tactic 1")
counter1 = counter1 + 1
sleep(10)
end
end)
]])
counter2 = 0
local t2 = tactic(function(env, ios, s)
while true do
print("tactic 2")
counter2 = counter2 + 1
sleep(10)
end
end)
local T = (t1:par(t2)):try_for(500)
T:solve(env, ios, ctx, p)
assert(counter2 > 2)
S:eval([[ assert(counter1 > 2) ]])