Skip to content
Snippets Groups Projects
Commit 1e2edcbb authored by Dmitry Simonenko's avatar Dmitry Simonenko
Browse files

core-lua-i64: some refactoring, console prefix-less output, tests

parent cbb740cc
Branches
Tags
No related merge requests found
......@@ -194,8 +194,8 @@ lbox_pack(struct lua_State *L)
case 'L':
case 'l':
{
u64 v = lua_tointeger64(L, i);
luaL_addlstring(&b, (char *) &v, sizeof(u64));
u64buf = lua_tointeger64(L, i);
luaL_addlstring(&b, (char *) &u64buf, sizeof(u64));
break;
}
/* Perl 'pack' BER-encoded integer */
......@@ -766,9 +766,15 @@ static void
tarantool_lua_printstack_yaml(struct lua_State *L, struct tbuf *out)
{
int top = lua_gettop(L);
for (int i = 1; i <= top; i++)
for (int i = 1; i <= top; i++) {
if (lua_type(L, i) == LUA_TCDATA) {
const char *sz = tarantool_lua_tostring(L, i);
int len = strlen(sz);
tbuf_printf(out, " - %-.*s\r\n", len - 3, sz);
} else
tbuf_printf(out, " - %s\r\n", tarantool_lua_tostring(L, i));
}
}
/*
* A helper to serialize arguments of 'print' Lua built-in
......@@ -778,9 +784,15 @@ static void
tarantool_lua_printstack(struct lua_State *L, struct tbuf *out)
{
int top = lua_gettop(L);
for (int i = 1; i <= top; i++)
for (int i = 1; i <= top; i++) {
if (lua_type(L, i) == LUA_TCDATA) {
const char *sz = tarantool_lua_tostring(L, i);
int len = strlen(sz);
tbuf_printf(out, "%-.*s\r\n", len - 3, sz);
} else
tbuf_printf(out, "%s", tarantool_lua_tostring(L, i));
}
}
/**
* Redefine lua 'print' built-in to print either to the log file
......
No preview for this file type
......@@ -276,3 +276,10 @@ print """
# run fiber's test
"""
exec admin "lua box_fiber_run_test()"
# Testing 64bit
exec admin "lua tonumber64(123)"
exec admin "lua tonumber64('123')"
exec admin "lua type(tonumber64('123')) == 'cdata'"
exec admin "lua tonumber64('9223372036854775807') == tonumber64('9223372036854775807')"
exec admin "lua tonumber64('9223372036854775807') - tonumber64('9223372036854775800')"
exec admin "lua string.byte(box.pack('p', tonumber64(123)))"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment