
RecencyTest.pudu
Pudu28 lines1.3 KB
1/** @Test.Domain.Recency.Suite — least recently used ordering of keys */2module PuduLangLog.Domain.RecencyTest34import Std.Io as Io5import Std.Test as Test6import PuduLangLog.Domain.Recency as Recency789fn main() -> Int {10 let none: Array[Str] = []11 let checks = Test.suite("Domain.Recency", &[12 Test.equals("a new key goes last", &Recency.touch(&["a", "b"], "c"), &["a", "b", "c"]),13 Test.equals("a used key moves last", &Recency.touch(&["a", "b", "c"], "a"), &["b", "c", "a"]),14 Test.equals("the last key stays last", &Recency.touch(&["a", "b"], "b"), &["a", "b"]),15 Test.equals("touching an empty order", &Recency.touch(&none, "a"), &["a"]),16 Test.equals("nothing overflows within the limit", &Recency.overflow(&["a", "b"], 2), &none),17 Test.equals("nothing overflows below the limit", &Recency.overflow(&["a"], 3), &none),18 Test.equals("the least recent overflow first", &Recency.overflow(&["a", "b", "c", "d"], 2), &["a", "b"]),19 Test.equals("a limit of zero retires every key", &Recency.overflow(&["a", "b"], 0), &["a", "b"]),20 Test.equals("a negative limit counts as zero", &Recency.overflow(&["a", "b"], -1), &["a", "b"])21 ])22 let ran = Test.run(&checks)23 for failure in Test.failuresOf(&ran) {24 let _reported = Io.writeErrorLine(failure)25 }26 Test.report(&ran)27}28