
CensusTest.pudu
Pudu36 lines2.1 KB
1/** @Test.Domain.Census.Suite — registration problems at their boundaries */2module PuduLangMediator.Domain.CensusTest34import Std.Io as Io5import Std.Test as Test6import PuduLangMediator.Domain.Census as Census789fn sound() -> Census.Census { Census.Census{name: "orders.get", handlers: 1, components: 2, collisions: 0, single: true} }101112fn main() -> Int {13 let checks = Test.suite("Domain.Census", &[14 Test.equals("one handler and components is sound", &Census.problems(&sound()), &[]),15 Test.equals("a kind without a name is reported", &Census.problems(&Census.Census{..sound(), name: ""}), &["a kind is registered without a name"]),16 Test.equals("one collision is reported", &Census.problems(&Census.Census{..sound(), collisions: 1}), &["'orders.get' names two different kinds"]),17 Test.equals("two handlers are reported with their count", &Census.problems(&Census.Census{..sound(), handlers: 2}), &[18 "'orders.get' has 2 handlers; a request or stream takes exactly one"19 ]),20 Test.equals("components without a handler are reported", &Census.problems(&Census.Census{..sound(), handlers: 0, components: 1}), &[21 "'orders.get' has behaviors or processors but no handler"22 ]),23 Test.equals("no handler and no components is not reported", &Census.problems(&Census.Census{..sound(), handlers: 0, components: 0}), &[]),24 Test.equals("a notification kind takes any number of handlers", &Census.problems(&Census.Census{..sound(), handlers: 3, single: false}), &[]),25 Test.equals("a notification kind needs no handler", &Census.problems(&Census.Census{..sound(), handlers: 0, single: false}), &[]),26 Test.equals("every problem is reported at once, in order", &Census.problems(&Census.Census{name: "", handlers: 2, components: 0, collisions: 2, single: true}), &[27 "a kind is registered without a name", "'' names two different kinds", "'' has 2 handlers; a request or stream takes exactly one"28 ])29 ])30 let ran = Test.run(&checks)31 for failure in Test.failuresOf(&ran) {32 let _reported = Io.writeErrorLine(failure)33 }34 Test.report(&ran)35}36