stagedConditionalRunner.tri (1601B)
1 !import prelude * 2 !import parser * 3 !import source_resolve * 4 !import source_unit * 5 !import source_staged_conditional_experiment as E 6 !export * 7 8 -- Fixture = (environment, (source, (arguments, (success?, expected)))). 9 -- The experimental compiler receives text at runtime, not pre-lowered IR. 10 matches fixture = (let environment = fst fixture in 11 let source = fst (snd fixture) in let arguments = fst (snd (snd fixture)) in 12 let expected = snd (snd (snd fixture)) in 13 lazyResult 14 (problem rest : and? (not? (fst expected)) 15 (equal? (parserDiagnosticExpected problem) (snd expected))) 16 (definitions rest : lazyMaybe (_ : false) 17 (main : and? (fst expected) 18 (equal? (foldl (f argument : f argument) main arguments) (snd expected))) 19 (sourceFindExternal definitions "main")) 20 (E.stagedIfCompileDefinitions environment source)) 21 22 matchesPublished executable fixture = equal? (foldl (f argument : f argument) executable (fst (snd (snd fixture)))) (snd (snd (snd (snd fixture)))) 23 24 -- Ordinary source must retain the canonical compiler's actual tree output, 25 -- not merely agree on one application. 26 ordinarySame fixture = equal? (E.stagedIfCompileDefinitions (fst fixture) (fst (snd fixture))) (compileModuleDefinitions (fst fixture) (fst (snd fixture))) 27 28 -- Force every compiled definition tree before applying main to any input. 29 -- Merely applying a lazy compiler result can hide a construction hazard. 30 constructionReady fixture = (lazyResult (_ _ : false) 31 (definitions _ : equal? definitions definitions) 32 (E.stagedIfCompileDefinitions (fst fixture) (fst (snd fixture))))