tricu

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

sourceEquationRunner.tri (1200B)


      1 !import "prelude" !Local
      2 !import "parser" !Local
      3 !import "source.unit" U
      4 !import "source.program" G
      5 
      6 -- Runtime fixture = (environment, (authored source, expected Result)). Keep
      7 -- the complete diagnostic, but discard compiler-private failure remainders.
      8 runFixture fixture = (lazyResult
      9   (diagnostic remainder : err diagnostic t)
     10   (tree remainder : ok tree t)
     11   (U.compileGateProgram (fst fixture) (fst (snd fixture))))
     12 matchesFixture fixture = equal? (runFixture fixture) (snd (snd fixture))
     13 matchesAst source expected = equal? expected (G.parseGateProgram source)
     14 -- Force every named outcome in one invocation. Haskell's CAS tree reader
     15 -- need not reload the large compiler tree separately for each tiny source.
     16 matchesAllFixtures_ self fixtures expected = (lazyList
     17   (_ : emptyList? expected)
     18   (entry rest : lazyList (_ : false)
     19     (wanted tail : lazyBool
     20       (_ : self rest tail) (_ : false)
     21       (and? (equal? (fst entry) (fst wanted))
     22         (equal? (matchesFixture (snd entry)) (snd wanted)))) expected)
     23   fixtures)
     24 matchesAllFixtures fixtures expected = y matchesAllFixtures_ fixtures expected
     25 matchesBatch batch = matchesAllFixtures (fst batch) (snd batch)
     26 main = matchesFixture