.
This commit is contained in:
@@ -20,8 +20,8 @@ return {
|
|||||||
%s
|
%s
|
||||||
ret
|
ret
|
||||||
]],
|
]],
|
||||||
replacements = {
|
scenarios = {
|
||||||
{ 2, 3, 'sum', expected_stack_top = 5 },
|
{ parameters = { 2, 3, 'sum' }, name = "Sum", expected_stack_top = 5 },
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
27
test/tests.c
27
test/tests.c
@@ -407,4 +407,31 @@ static void run_assembly_test_code(lua_State* L)
|
|||||||
|
|
||||||
static void run_assembly_test_template(lua_State* L)
|
static void run_assembly_test_template(lua_State* L)
|
||||||
{
|
{
|
||||||
|
lua_getfield(L, -1, "template");
|
||||||
|
const char* template = strdup(lua_tostring(L, -1));
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
lua_getfield(L, -1, "scenarios");
|
||||||
|
assert(!lua_isnil(L, -1));
|
||||||
|
|
||||||
|
long n_scenarios = luaL_len(L, -1);
|
||||||
|
for (long i = 0; i < n_scenarios; ++i) {
|
||||||
|
lua_geti(L, -1, (int)i + 1);
|
||||||
|
|
||||||
|
lua_getfield(L, -1, "name");
|
||||||
|
printf(" .. %s\n", lua_tostring(L, -1));
|
||||||
|
lua_pop(L, 1);
|
||||||
|
|
||||||
|
// format code
|
||||||
|
lua_dostring(L, "string.format");
|
||||||
|
lua_pushstring(L, template);
|
||||||
|
|
||||||
|
lua_pop(L, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t* bytecode; size_t bytecode_sz;
|
||||||
|
// assert(code_assemble(lua_tostring(L, -1), &bytecode, &bytecode_sz) == T_OK);
|
||||||
|
|
||||||
|
lua_pop(L, 1);
|
||||||
|
free(template);
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user