From ba04b0f24780b8254f5867e80ee1edf28f37a502 Mon Sep 17 00:00:00 2001 From: Alexander M Pickering Date: Fri, 24 Nov 2023 22:07:21 -0600 Subject: fix gui tests again --- spec/test4_spec.lua | 78 ++++++++++++++++++++++++++--------------------------- 1 file changed, 38 insertions(+), 40 deletions(-) (limited to 'spec') diff --git a/spec/test4_spec.lua b/spec/test4_spec.lua index 111b5b6..5063d58 100644 --- a/spec/test4_spec.lua +++ b/spec/test4_spec.lua @@ -124,47 +124,45 @@ end function generate_boolean() return "true" end -describe("Brok[en]gine",function() - describe("gui system",function() - for k,v in pairs(gui_api) do - describe(k,function() - local paramstring = {} - local num_optional_args = 0 - local num_required_args = 0 - for i,j in pairs(v.params) do - assert(_G["generate_" .. j.type], "Could not find a generator for type: " .. j.type) - if j.required then - num_required_args = num_required_args + 1 - else - num_optional_args = num_optional_args + 1 - end - paramstring[#paramstring + 1] = _G["generate_" .. j.type]() +describe("Brok[en]gine gui system",function() + for k,v in pairs(gui_api) do + describe(k,function() + local paramstring = {} + local num_optional_args = 0 + local num_required_args = 0 + for i,j in pairs(v.params) do + assert(getfenv()["generate_" .. j.type], "Could not find a generator for type: " .. j.type) + if j.required then + num_required_args = num_required_args + 1 + else + num_optional_args = num_optional_args + 1 end - for i = num_required_args, num_required_args + num_optional_args do - it(string.format(" with %d params", i),function() + paramstring[#paramstring + 1] = getfenv()["generate_" .. j.type]() + end + for i = num_required_args, num_required_args + num_optional_args do + it(string.format(" with %d params", i),function() + local truncated_params = {} + for j = 1, i do + truncated_params[j] = paramstring[j] + end + local game_file = string.format("%s(%s)",v.func,table.concat(truncated_params, ",")) + --print("running:",game_file) + writegame(game_file) + assert_game_runs() + end) + it(string.format(" 100 elemants with %d params", i),function() + local game_file = {} + for j = 1,100 do local truncated_params = {} - for j = 1, i do - truncated_params[j] = paramstring[j] - end - local game_file = string.format("%s(%s)",v.func,table.concat(truncated_params, ",")) - --print("running:",game_file) - writegame(game_file) - assert_game_runs() - end) - it(string.format(" 100 elemants with %d params", i),function() - local game_file = {} - for j = 1,100 do - local truncated_params = {} - for k = 1, i do - truncated_params[k] = paramstring[k] - end - game_file[#game_file + 1] = string.format("%s(%s)",v.func,table.concat(truncated_params, ",")) + for k = 1, i do + truncated_params[k] = paramstring[k] end - writegame(table.concat(game_file,"\n")) - assert_game_runs() - end) - end - end) - end - end) + game_file[#game_file + 1] = string.format("%s(%s)",v.func,table.concat(truncated_params, ",")) + end + writegame(table.concat(game_file,"\n")) + assert_game_runs() + end) + end + end) + end end) -- cgit v1.2.3-70-g09d2