2026-09-29 20:23:20 +03:00
|
|
|
extends SceneTree
|
2026-09-30 08:08:27 +03:00
|
|
|
const E = preload("res://world/owniverse/math/exact.gd")
|
2026-09-29 20:23:20 +03:00
|
|
|
|
|
|
|
|
var checks: int = 0
|
|
|
|
|
var failures: int = 0
|
|
|
|
|
|
|
|
|
|
func _initialize() -> void:
|
|
|
|
|
call_deferred("run")
|
|
|
|
|
|
|
|
|
|
func check(condition: bool, message: String) -> void:
|
2026-09-30 08:08:27 +03:00
|
|
|
checks = E.add(checks, 1)
|
|
|
|
|
if (not condition):
|
|
|
|
|
failures = E.add(failures, 1)
|
2026-09-29 20:23:20 +03:00
|
|
|
push_error(message)
|
|
|
|
|
|
|
|
|
|
func run() -> void:
|
|
|
|
|
var World = load("res://world/owniverse/owniverse.gd")
|
|
|
|
|
var first = World.new()
|
|
|
|
|
var second = World.new()
|
|
|
|
|
var names: Array = ["batches", "ledger", "production", "automatic", "stellar", "life", "environment", "evolution"]
|
|
|
|
|
var references: Array = []
|
|
|
|
|
for name in names:
|
2026-09-30 08:08:27 +03:00
|
|
|
check(E.ne(first.get(name), second.get(name)), E.add("World has its own ", name))
|
|
|
|
|
check(E.eq(first.get(name).world, first), E.add("Module refers to its owner: ", name))
|
2026-09-29 20:23:20 +03:00
|
|
|
references.append(weakref(first.get(name)))
|
2026-09-30 08:08:27 +03:00
|
|
|
first.state.amount.H = 123
|
|
|
|
|
first.presentation.pending_amounts.H = 123
|
|
|
|
|
check(((not second.state.amount.has("H")) and second.presentation.pending_amounts.is_empty()), "State and pending presentation are isolated")
|
2026-09-29 20:23:20 +03:00
|
|
|
first.free()
|
|
|
|
|
for reference in references:
|
2026-09-30 08:08:27 +03:00
|
|
|
check(E.eq(reference.get_ref(), null), "Module is released with its world")
|
|
|
|
|
check(E.eq(second.evolution.world, second), "Other world remains usable")
|
2026-09-29 20:23:20 +03:00
|
|
|
var snapshot: Dictionary = second.state.duplicate(true)
|
|
|
|
|
second.evolute(NAN)
|
2026-09-30 08:08:27 +03:00
|
|
|
second.evolute(E.neg(1))
|
|
|
|
|
check(E.eq(second.state, snapshot), "Entry point rejects invalid time deltas")
|
2026-09-29 20:23:20 +03:00
|
|
|
second.free()
|
2026-09-30 08:08:27 +03:00
|
|
|
print(("Module lifecycle: %d checks, %d failures" % [checks, failures]))
|
|
|
|
|
quit((1 if failures else 0))
|