extends SceneTree const Clock = preload("res://world/owniverse/simulation_time.gd") var checks: int = 0 var failures: int = 0 func _initialize() -> void: call_deferred("run") func check(condition: bool, message: String) -> void: checks += 1 if not condition: failures += 1 push_error(message) func fixture(): var world = load("res://world/owniverse/owniverse.gd").new() var global: Node = root.get_node("Global") for id in global.OwniverseEntities: var entity = load("res://world/owniverse/owniverse_entity.gd").new(global.OwniverseEntities[id]) world.entities[id] = entity world.state.amount[id] = 0.0 world.state.stats.total_amount[id] = 0.0 if entity.group_as != "": world.state.amount[entity.group_as] = 0.0 world.state.stats.total_amount[entity.group_as] = 0.0 world.entities["N"].life_product = {} world.entities["N"].product_per_year_type = "H" world.entities["N"].product_per_year_amount = 10.0 world.entities["N"].auto = 0.0 world.state.amount.N = 1.0 return world func dispose(world) -> void: for entity in world.entities.values(): entity.free() world.free() func run() -> void: var world = fixture() world.state.batch_origins.LGRB = 10357034.80000000074505806 var boundary: float = 41215289.79999999701976776 for interval in [[boundary - 2.5, boundary + 2.25], [boundary, boundary + 2.0]]: world.state.batches.LGRB = [] world._append_batch(world.state, "LGRB", 100.0, interval[0], interval[1]) var total: float = 0.0 var last: float = -INF for batch: Dictionary in world.state.batches.LGRB: total += batch.amount check(batch.created_from > last, "Batch windows advance monotonically") check(batch.created_to > batch.created_from, "Positive window duration") check(batch.amount >= 0.0, "No negative batch amounts") last = batch.created_from check(total == 100.0, "Boundary correction preserves all objects") check(world.state.batches.LGRB.size() <= 7, "Finite number of windows") dispose(world) print("Batch boundaries: %d checks, %d failures" % [checks, failures]) quit(0 if failures == 0 else 1)