diff options
Diffstat (limited to 'spec/test4_spec.lua')
| -rw-r--r-- | spec/test4_spec.lua | 78 |
1 files changed, 38 insertions, 40 deletions
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)
|
