[Tarantool-patches] [PATCH v2 luajit 26/26] test: enable <catch_cpp.lua> LuaJIT test

Sergey Bronnikov sergeyb at tarantool.org
Mon Feb 5 16:32:45 MSK 2024


Hi, Sergey

thanks for the patch! LGTM

On 1/29/24 13:45, Sergey Kaplun wrote:
> This patch moves the <catch_cpp.lua> test from the <sysdep> to <lang>
> directory, includes it in <index>, and names subtests.
>
> Resolves of tarantool/tarantool#7834
> Part of tarantool/tarantool#9398
> ---
>   .../{sysdep => lang}/catch_cpp.lua            | 36 ++++++++++---------
>   test/LuaJIT-tests/lang/index                  |  1 +
>   2 files changed, 20 insertions(+), 17 deletions(-)
>   rename test/LuaJIT-tests/{sysdep => lang}/catch_cpp.lua (75%)
>
> diff --git a/test/LuaJIT-tests/sysdep/catch_cpp.lua b/test/LuaJIT-tests/lang/catch_cpp.lua
> similarity index 75%
> rename from test/LuaJIT-tests/sysdep/catch_cpp.lua
> rename to test/LuaJIT-tests/lang/catch_cpp.lua
> index b2251009..6c52c78c 100644
> --- a/test/LuaJIT-tests/sysdep/catch_cpp.lua
> +++ b/test/LuaJIT-tests/lang/catch_cpp.lua
> @@ -1,30 +1,30 @@
> +local cp = require("libcpptest")
>   
> -local cp = require("cpptest")
> +local unwind
>   
> -do
> +do --- catch, no error
>     local a, b = pcall(cp.catch, function() return "x" end)
>     assert(a == true and b == "x")
>   end
>   
> -do
> +do --- pcall throw
>     local a, b = pcall(function() cp.throw("foo") end)
>     assert(a == false and b == "C++ exception")
>   end
>   
> -local unwind
> -do
> +do --- catch throw
>     local a, b = pcall(cp.catch, function() cp.throw("foo") end)
>     unwind = a
>     assert((a == false and b == "C++ exception") or (a == true and b == "foo"))
>   end
>   
> -do
> +do --- alloc, no error
>     local st = cp.alloc(function() return cp.isalloc() end)
>     assert(st == true)
>     assert(cp.isalloc() == false)
>   end
>   
> -do
> +do --- throw in alloc
>     local a, b = pcall(cp.alloc, function()
>       assert(cp.isalloc() == true)
>       return "foo", cp.throw
> @@ -33,21 +33,23 @@ do
>     assert(cp.isalloc() == false)
>   end
>   
> -if unwind then
> -  local a, b = pcall(cp.alloc, function()
> -    assert(cp.isalloc() == true)
> -    return "foo", error
> -  end)
> -  assert(a == false and b == "foo")
> -  assert(cp.isalloc() == false)
> +do --- error in alloc
> +  if unwind then
> +    local a, b = pcall(cp.alloc, function()
> +      assert(cp.isalloc() == true)
> +      return "foo", error
> +    end)
> +    assert(a == false and b == "foo")
> +    assert(cp.isalloc() == false)
> +  end
>   end
>   
> -do
> +do --- usereg nop
>     local a,b,c,d,e,f = cp.usereg(100, 50, function() end, false)
>     assert(a==164 and b==312 and c==428 and d==3696 and e==404 and f==404)
>   end
>   
> -do
> +do --- usereg error
>     local function test()
>       cp.usereg(100, 40, error, "foo")
>     end
> @@ -55,7 +57,7 @@ do
>     assert(a==164 and b==312 and c==428 and d==3696 and e==404 and f==404)
>   end
>   
> -do
> +do --- usereg trace with self table lookup
>     local t = {};
>     t.t = t;
>     local function foo()
> diff --git a/test/LuaJIT-tests/lang/index b/test/LuaJIT-tests/lang/index
> index 87b0c5a0..41f7e7db 100644
> --- a/test/LuaJIT-tests/lang/index
> +++ b/test/LuaJIT-tests/lang/index
> @@ -1,6 +1,7 @@
>   andor.lua
>   api_call.lua
>   assignment.lua
> +catch_cpp.lua
>   catch_wrap.lua
>   compare.lua
>   compare_nan.lua


More information about the Tarantool-patches mailing list