From aa7d6b9b44b111359f536ea1b0ce95fee661235a Mon Sep 17 00:00:00 2001 From: Neil Brown Date: Sat, 18 Apr 2009 18:09:20 +0000 Subject: [PATCH] Added a function for testing that defines all the occam built-in operators, which helped fix all the failures in OccamPasses --- common/TestUtils.hs | 15 +++++++++++++++ frontends/OccamPassesTest.hs | 2 ++ 2 files changed, 17 insertions(+) diff --git a/common/TestUtils.hs b/common/TestUtils.hs index 2f48103..9af9653 100644 --- a/common/TestUtils.hs +++ b/common/TestUtils.hs @@ -49,6 +49,7 @@ import Test.QuickCheck import qualified AST as A import CompState import Errors +import Intrinsics import Metadata (emptyMeta) import Pass import Pattern @@ -645,3 +646,17 @@ instance Die (StateT CompState IO) where fail s --}}} + +defineOccamOperators :: CSM m => m () +defineOccamOperators + = sequence_ + [ let n = A.Name emptyMeta $ occamDefaultOperator rawOp ts + nd = A.NameDef emptyMeta (A.nameName n) rawOp + (A.Function emptyMeta (A.PlainSpec, A.PlainRec) + [rt] [A.Formal A.ValAbbrev t (A.Name emptyMeta $ "arg" ++ show i) + | (i, t) <- zip [0..] ts + ] Nothing) + A.Original A.NameNonce A.Unplaced + in defineName n nd + | (rawOp, rt, ts) <- occamIntrinsicOperators + ] diff --git a/frontends/OccamPassesTest.hs b/frontends/OccamPassesTest.hs index e2e1454..cec10bb 100644 --- a/frontends/OccamPassesTest.hs +++ b/frontends/OccamPassesTest.hs @@ -50,6 +50,8 @@ startState undefined defineVariable "var" A.Int + defineOccamOperators + -- | Test 'OccamPasses.foldConstants'. testFoldConstants :: Test testFoldConstants = TestList