Fixed some more Rain tests related to the old method of inferring types
This commit is contained in:
parent
155f58c174
commit
d4938a166c
|
@ -212,7 +212,8 @@ testRecordInfNames0 = TestCase $ testPassWithStateCheck "testRecordInfNames0" ex
|
||||||
orig = (A.Rep m (A.ForEach m (simpleName "c") (makeLiteralStringRain "hello")) skipP)
|
orig = (A.Rep m (A.ForEach m (simpleName "c") (makeLiteralStringRain "hello")) skipP)
|
||||||
exp = orig
|
exp = orig
|
||||||
check state = assertVarDef "testRecordInfNames0" state "c"
|
check state = assertVarDef "testRecordInfNames0" state "c"
|
||||||
(tag7 A.NameDef DontCare "c" "c" A.VariableName (A.Declaration m A.Byte ) A.Abbrev A.Unplaced)
|
(tag7 A.NameDef DontCare "c" "c" A.VariableName
|
||||||
|
(A.Declaration m $ A.UnknownVarType $ Left $ simpleName "c") A.Abbrev A.Unplaced)
|
||||||
|
|
||||||
-- | checks that c's type is recorded in: ***each (c : str) {}, where str is known to be of type string
|
-- | checks that c's type is recorded in: ***each (c : str) {}, where str is known to be of type string
|
||||||
testRecordInfNames1 :: Test
|
testRecordInfNames1 :: Test
|
||||||
|
@ -223,7 +224,8 @@ testRecordInfNames1 = TestCase $ testPassWithStateCheck "testRecordInfNames1" ex
|
||||||
orig = (A.Rep m (A.ForEach m (simpleName "c") (exprVariable "str")) skipP)
|
orig = (A.Rep m (A.ForEach m (simpleName "c") (exprVariable "str")) skipP)
|
||||||
exp = orig
|
exp = orig
|
||||||
check state = assertVarDef "testRecordInfNames1" state "c"
|
check state = assertVarDef "testRecordInfNames1" state "c"
|
||||||
(tag7 A.NameDef DontCare "c" "c" A.VariableName (A.Declaration m A.Byte ) A.Abbrev A.Unplaced)
|
(tag7 A.NameDef DontCare "c" "c" A.VariableName
|
||||||
|
(A.Declaration m $ A.UnknownVarType $ Left $ simpleName "c") A.Abbrev A.Unplaced)
|
||||||
|
|
||||||
-- | checks that c's and d's type are recorded in: ***each (c : multi) { seqeach (d : c) {} } where multi is known to be of type [string]
|
-- | checks that c's and d's type are recorded in: ***each (c : multi) { seqeach (d : c) {} } where multi is known to be of type [string]
|
||||||
testRecordInfNames2 :: Test
|
testRecordInfNames2 :: Test
|
||||||
|
@ -235,15 +237,13 @@ testRecordInfNames2 = TestCase $ testPassWithStateCheck "testRecordInfNames2" ex
|
||||||
A.Only m $ A.Seq m $ A.Rep m (A.ForEach m (simpleName "d") (exprVariable "c")) skipP
|
A.Only m $ A.Seq m $ A.Rep m (A.ForEach m (simpleName "d") (exprVariable "c")) skipP
|
||||||
exp = orig
|
exp = orig
|
||||||
check state = do assertVarDef "testRecordInfNames2" state "c"
|
check state = do assertVarDef "testRecordInfNames2" state "c"
|
||||||
(tag7 A.NameDef DontCare "c" "c" A.VariableName (A.Declaration m (A.List A.Byte) ) A.Abbrev A.Unplaced)
|
(tag7 A.NameDef DontCare "c" "c" A.VariableName
|
||||||
|
(A.Declaration m $ A.UnknownVarType $ Left $ simpleName
|
||||||
|
"c") A.Abbrev A.Unplaced)
|
||||||
assertVarDef "testRecordInfNames2" state "d"
|
assertVarDef "testRecordInfNames2" state "d"
|
||||||
(tag7 A.NameDef DontCare "d" "d" A.VariableName (A.Declaration m A.Byte ) A.Abbrev A.Unplaced)
|
(tag7 A.NameDef DontCare "d" "d" A.VariableName
|
||||||
|
(A.Declaration m $ A.UnknownVarType $ Left $ simpleName
|
||||||
-- | checks that doing a foreach over a non-array type is barred:
|
"d") A.Abbrev A.Unplaced)
|
||||||
testRecordInfNames3 :: Test
|
|
||||||
testRecordInfNames3 = TestCase $ testPassShouldFail "testRecordInfNames3" (recordInfNameTypes orig) (return ())
|
|
||||||
where
|
|
||||||
orig = A.Rep m (A.ForEach m (simpleName "c") (intLiteral 0)) skipP
|
|
||||||
|
|
||||||
--Easy way to string two passes together; creates a pass-like function that applies the left-hand pass then the right-hand pass. Associative.
|
--Easy way to string two passes together; creates a pass-like function that applies the left-hand pass then the right-hand pass. Associative.
|
||||||
(>>>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
|
(>>>) :: Monad m => (a -> m b) -> (b -> m c) -> a -> m c
|
||||||
|
@ -455,7 +455,6 @@ tests = TestLabel "RainPassesTest" $ TestList
|
||||||
,testRecordInfNames0
|
,testRecordInfNames0
|
||||||
,testRecordInfNames1
|
,testRecordInfNames1
|
||||||
,testRecordInfNames2
|
,testRecordInfNames2
|
||||||
,testRecordInfNames3
|
|
||||||
,testFindMain0
|
,testFindMain0
|
||||||
,testFindMain1
|
,testFindMain1
|
||||||
,testFindMain2
|
,testFindMain2
|
||||||
|
|
|
@ -138,16 +138,15 @@ substituteUnknownTypes mt = applyDepthM sub
|
||||||
|
|
||||||
-- | A pass that records inferred types. Currently the only place where types are inferred is in seqeach\/pareach loops.
|
-- | A pass that records inferred types. Currently the only place where types are inferred is in seqeach\/pareach loops.
|
||||||
recordInfNameTypes :: PassType
|
recordInfNameTypes :: PassType
|
||||||
recordInfNameTypes = applyDepthM recordInfNameTypes'
|
recordInfNameTypes = checkDepthM recordInfNameTypes'
|
||||||
where
|
where
|
||||||
recordInfNameTypes' :: A.Replicator -> PassM A.Replicator
|
recordInfNameTypes' :: Check A.Replicator
|
||||||
recordInfNameTypes' input@(A.ForEach m n e)
|
recordInfNameTypes' input@(A.ForEach m n e)
|
||||||
= do let innerT = A.UnknownVarType $ Left n
|
= let innerT = A.UnknownVarType $ Left n in
|
||||||
defineName n A.NameDef {A.ndMeta = m, A.ndName = A.nameName n, A.ndOrigName = A.nameName n,
|
defineName n A.NameDef {A.ndMeta = m, A.ndName = A.nameName n, A.ndOrigName = A.nameName n,
|
||||||
A.ndNameType = A.VariableName, A.ndSpecType = (A.Declaration m innerT),
|
A.ndNameType = A.VariableName, A.ndSpecType = A.Declaration m innerT,
|
||||||
A.ndAbbrevMode = A.Abbrev, A.ndPlacement = A.Unplaced}
|
A.ndAbbrevMode = A.Abbrev, A.ndPlacement = A.Unplaced}
|
||||||
return input
|
recordInfNameTypes' _ = return ()
|
||||||
recordInfNameTypes' r = return r
|
|
||||||
|
|
||||||
markReplicators :: PassType
|
markReplicators :: PassType
|
||||||
markReplicators = checkDepthM mark
|
markReplicators = checkDepthM mark
|
||||||
|
|
Loading…
Reference in New Issue
Block a user