Skip to content

Commit

Permalink
Test: fail hard when generating a program with an unmelted type
Browse files Browse the repository at this point in the history
  • Loading branch information
tranma committed Feb 28, 2017
1 parent 11763bf commit dac0214
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions icicle-compiler/test/Icicle/Test/Arbitrary/Program.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ import P

import Test.QuickCheck

import qualified Prelude as Savage


newtype InputType = InputType {
unInputType :: ValType
Expand Down Expand Up @@ -284,7 +286,7 @@ isSupportedOutputBase = \case
_ -> False

isSupportedType :: ValType -> Bool
isSupportedType = \case
isSupportedType ty = case ty of
UnitT -> True
BoolT -> True
IntT -> True
Expand All @@ -294,17 +296,20 @@ isSupportedType = \case
-> True
StringT -> True
ErrorT -> True
MapT{} -> True
PairT{} -> True
OptionT{} -> True
StructT{} -> True
SumT{} -> True

-- can't be nested
BufT _ t -> not (isBufOrArray t)
ArrayT (ArrayT t) -> not (isBufOrArray t)
ArrayT (BufT _ t) -> not (isBufOrArray t)
ArrayT t -> not (isBufOrArray t)

-- should have been melted
MapT{} -> Savage.error ("should have been melted: " <> show ty)
PairT{} -> Savage.error ("should have been melted: " <> show ty)
OptionT{} -> Savage.error ("should have been melted: " <> show ty)
StructT{} -> Savage.error ("should have been melted: " <> show ty)

isBufOrArray :: ValType -> Bool
isBufOrArray = \case
BufT{} -> True
Expand Down

0 comments on commit dac0214

Please sign in to comment.