Capture current source, content data, tests, asset licenses, and original-specification traceability. Original implementation remains incomplete. The accepted matching UI generation passed 154 suites and 12,253 checks, with eight rendered staff-contract screens reviewed. Latest native Windows and full-original acceptance remain outstanding.
44 lines
2.7 KiB
GDScript
44 lines
2.7 KiB
GDScript
extends SceneTree
|
|
var checks := 0
|
|
var failures := 0
|
|
func expect(ok: bool, label: String) -> void:
|
|
checks += 1
|
|
if not ok: failures += 1; push_error(label)
|
|
func _initialize() -> void: call_deferred("run")
|
|
func fixture(capacity: int, customer_capacity: int) -> FacilityService:
|
|
var service := FacilityService.new()
|
|
expect(service.create_instance({&"instance_id": &"room", &"definition_id": &"test", &"capacity": capacity, &"customer_capacity": customer_capacity, &"queue_capacity": 10}).is_success(), "create independent service/customer limits")
|
|
return service
|
|
func enqueue(service: FacilityService, id: StringName, guests: Array[StringName]) -> void:
|
|
expect(service.enqueue_request(service.create_request(id,&"room",guests,&"test",0)).is_success(), "queue " + String(id))
|
|
func run() -> void:
|
|
for capacity: int in [2,100]:
|
|
var service := fixture(capacity,3)
|
|
enqueue(service,&"first",[&"a",&"b"])
|
|
enqueue(service,&"second",[&"c"])
|
|
enqueue(service,&"overflow",[&"d"])
|
|
# Explicit priority keeps the intended arrival ordering independent of IDs.
|
|
service.get_request(&"first").priority=3
|
|
service.get_request(&"second").priority=2
|
|
var first := service.start_next_service(&"room",0)
|
|
expect(first.is_success() and first.details.get(&"slot",-1)==0,"first group uses service slot zero regardless of headcount limit")
|
|
var saved := service.create_snapshot()
|
|
var second := service.start_next_service(&"room",0)
|
|
expect(second.is_success() and second.details.get(&"slot",-1)==1,"second group uses service slot one")
|
|
expect(service.get_instance(&"room").customer_count()==3,"two services consume three customer places")
|
|
expect(not service.start_next_service(&"room",0).is_success(),"fourth customer still rejected")
|
|
expect(service.restore_snapshot(saved),"restore first group checkpoint")
|
|
var replay := service.start_next_service(&"room",0)
|
|
expect(replay.is_success() and replay.details==second.details,"restored start returns same service and slot")
|
|
var nested := fixture(2,3)
|
|
enqueue(nested,&"a",[&"a",&"b"]);enqueue(nested,&"b",[&"c"])
|
|
var callback_results: Array[CommandResult] = []
|
|
var on_started := func(started: ServiceInstance) -> void:
|
|
if started.request_id==&"a": callback_results.append(nested.start_next_service(&"room",0))
|
|
nested.service_started.connect(on_started)
|
|
var outer := nested.start_next_service(&"room",0)
|
|
expect(outer.is_success() and outer.details.get(&"slot",-1)==0,"start result is fixed before notification callbacks")
|
|
expect(callback_results.size()==1 and callback_results[0].is_success() and callback_results[0].details.get(&"slot",-1)==1,"nested start has its own slot result")
|
|
nested.service_started.disconnect(on_started)
|
|
print("Service start slots: %d checks, %d failures" % [checks,failures]);quit(failures)
|