tricu

An interpreted language for exploring Tree Calculus
Log | Files | Refs | README | LICENSE

sourcePatternRunner.tri (1148B)


      1 -- Runtime comparator: fixture descriptions, bodies, inputs and expectations
      2 -- are supplied as trees after this compiler artifact has been exported.
      3 !import "prelude" !Local
      4 !import "source.pattern" P
      5 !import "source.compile" K
      6 
      7 -- Fixture = (equations, (extra outer lambda markers, (arguments, expected))).
      8 runFixtureWith lower fixture = (let equations = fst fixture in
      9   let wrappers = fst (snd fixture) in
     10   let arguments = fst (snd (snd fixture)) in
     11   lazyResult (problem rest : err problem rest)
     12     (core rest : lazyResult (problem rest : err problem rest)
     13       (function rest : ok (foldl (f argument : f argument) function arguments) t)
     14       (K.sourceCompileCore (P.spWrap wrappers core)))
     15     (lower equations))
     16 runFixture fixture = runFixtureWith P.sourceLowerEquations fixture
     17 matchesFixtureWith lower fixture = equal? (runFixtureWith lower fixture) (snd (snd (snd fixture)))
     18 matchesFixture fixture = matchesFixtureWith P.sourceLowerEquations fixture
     19 -- Force the lowered syntax too, without normalizing an open core as code.
     20 matchesLowered equations expected = equal? (P.sourceLowerEquations equations) expected
     21 main = matchesFixture