Remove development unittest guardrails

main
Bram van den Heuvel 2024-05-02 01:48:08 +02:00
parent 565f0c74b2
commit f2dff7b9b9
1 changed files with 10 additions and 52 deletions

View File

@ -1,9 +1,9 @@
-- DEVELOPMENT ONLY: Timer module for debugging performance
local modpath = minetest.get_modpath(minetest.get_current_modname())
-- -- DEVELOPMENT ONLY: Timer module for debugging performance
-- local modpath = minetest.get_modpath(minetest.get_current_modname())
dofile(modpath.."/lua/timer.lua")
-- dofile(modpath.."/lua/timer.lua")
-- DEVELOPMENT ONLY: End of timer module
-- -- DEVELOPMENT ONLY: End of timer module
-- Local variables used for programming
local internal =
@ -570,15 +570,6 @@ function internal.flat_from_cave_bools(minp, maxp)
internal.reduced_shape_pos(minp),
internal.reduced_shape_pos(maxp),
function (i, pos)
-- DEVELOPMENT ONLY: Unittest
if connectivity:pos_to_index(pos) ~= i then
error("Connectivity index doesn't match local index")
end
if verticality:pos_to_index(pos) ~= i then
error("Verticality index doesn't match local index")
end
-- DEVELOPMENT ONLY: End unittest
local cnct = connectivity:get_index(i)
local vrtcl = verticality:get_index(i)
@ -759,7 +750,7 @@ function internal.generate_caves(data, minp, maxp)
-- Get cave bools
local bools = internal.flat_from_cave_bools(bminp, bmaxp)
timer.checkpoint("Calculate cave shape")
-- timer.checkpoint("Calculate cave shape")
-- Get node types
local nts = internal.flat_from_node_types(bools, bminp, bmaxp)
@ -772,7 +763,7 @@ function internal.generate_caves(data, minp, maxp)
internal.humidity_noise_params(), bminp, bmaxp
)
timer.checkpoint("Calculate block types & biomes")
-- timer.checkpoint("Calculate block types & biomes")
local air = minetest.get_content_id("air")
local schems = {}
@ -941,39 +932,6 @@ function internal.iter_3d_area(minp, maxp, callback)
for x = minp.x, maxp.x, 1 do
local pos = { x = x, y = y, z = z }
i = i + 1
-- DEVELOPMENT ONLY: This function only serves as a unittest
-- DEVELOPMENT ONLY: to verify that the iteration across a 3D
-- DEVELOPMENT ONLY: table works appropriately.
-- DEVELOPMENT ONLY: This calculation is highly inefficient and
-- DEVELOPMENT ONLY: unnecessary so it is highly recommended
-- DEVELOPMENT ONLY: to remove this code in production.
local dx = x - minp.x
local dy = y - minp.y
local dz = z - minp.z
local si = internal.from_3d_to_flat(dx, dy, dz, nx, ny)
if i ~= si then
error(
table.concat(
{ "Expected position"
, internal.pos_to_str(pos)
, "to correspond to index"
, si
, "but our iteration arrived at index"
, i
}
, " "
)
)
end
-- DEVELOPMENT ONLY:
-- DEVELOPMENT ONLY: This is the bottom of the unittest.
-- DEVELOPMENT ONLY: Please remove this code in a future commit
-- DEVELOPMENT ONLY: before the mod is assumed to be
-- DEVELOPMENT ONLY: production-ready.
-- DEVELOPMENT ONLY:
callback(i, pos)
end
end
@ -1305,7 +1263,7 @@ end
-------------------------------------------------------------------------------
-------------------------------------------------------------------------------
minetest.register_on_generated(function(minp, maxp, blockseed)
timer.start()
-- timer.start()
math.randomseed(blockseed)
@ -1313,7 +1271,7 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
local data = vm:get_data()
local flat, schems = internal.generate_caves(data, minp, maxp)
timer.checkpoint("Place caves")
-- timer.checkpoint("Place caves")
internal.place_simple_decorations(flat, schems)
@ -1321,9 +1279,9 @@ minetest.register_on_generated(function(minp, maxp, blockseed)
vm:write_to_map()
internal.place_schematic_decorations(vm, schems)
timer.checkpoint("Place decorations")
-- timer.checkpoint("Place decorations")
timer.stop()
-- timer.stop()
end)
-- Prevent v7 from spawning large caves underground