1 # ez/gate: what a test file says its run must print. A test states that in a 2 # `#|` trailer, one line for each line of output, and `ez test` holds the run 3 # to it. 4 # 5 # This file imports nothing but Base, so a law about the trailer walk costs a 6 # compile of that and no more. 7 import Base 8 9 # a trailer line kept, with its `#|` dropped, or a source line ignored 10 def want.put(is_want: Bool, line: String, rest: List<&2, String>) -> List<&2, String>: 11 match is_want: 12 case True{}: 13 String.drop(line, 2n) <> rest 14 case False{}: 15 rest 16 17 # the `#|` lines of a source file, in order 18 def want(ls: List<&2, String>) -> List<&2, String>: 19 match ls: 20 case []: 21 [] 22 case +h <> t: 23 want.put(String.starts_with(h, "#|"), h, want(t)) 24 25 # what a test file says its run must print 26 def trailer(text: String) -> String: 27 String.join(want(String.lines(text)), "\n")