Skip to content

Commit

Permalink
Test: convert Icicle type to Zebra schema
Browse files Browse the repository at this point in the history
  • Loading branch information
tranma committed Feb 27, 2017
1 parent 4117fe2 commit 4cb4399
Show file tree
Hide file tree
Showing 9 changed files with 341 additions and 290 deletions.
26 changes: 2 additions & 24 deletions icicle-compiler/icicle.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -218,30 +218,10 @@ test-suite test

ghc-options: -Wall -threaded -O2 -funbox-strict-fields

ld-options: -Wl,-undefined,dynamic_lookup

hs-source-dirs:
test
other-modules:
-- Icicle.Test.Sea.Bindings

include-dirs:
data/sea

install-includes:
00-includes.h
05-error.h
06-segv.h
20-simple.h
21-time.h
30-array.h
31-buffer.h
40-grisu2-powers.h
41-grisu2.h
42-text-conversion.h
50-chord.h
51-piano.h
52-psv.h
53-zebra-data.h
54-zebra.h

build-depends:
base >= 3 && < 5
Expand All @@ -261,12 +241,10 @@ test-suite test
, ambiata-zebra
, ambiata-zebra-test
, bifunctors >= 4.2 && < 5.4
, bindings-DSL >= 1.0.0 && <= 1.0.23
, aeson
, bytestring
, containers
, directory
, exceptions == 0.8.*
, filepath == 1.4.*
, geniplate-mirror >= 0.7.2 && < 0.8
, megaparsec == 5.0.*
Expand Down
1 change: 1 addition & 0 deletions icicle-compiler/src/Icicle/Sea/Eval/Base.hs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ module Icicle.Sea.Eval.Base (
, pokeWordOff
, peekWordOff

, peekOutput
, peekOutputs
, wordOfError
, errorOfWord
Expand Down
17 changes: 9 additions & 8 deletions icicle-compiler/test/Icicle/Test/Arbitrary/Core.hs
Original file line number Diff line number Diff line change
Expand Up @@ -178,19 +178,20 @@ instance Arbitrary ValType where
arbitrary =
-- Need to be careful about making smaller things.
-- It's fine if they're big, but they have to fit in memory.
oneof_sized_vals
[ IntT
, UnitT
, BoolT
, TimeT
, StringT ]
oneof_sized
[ pure IntT
, pure UnitT
, pure BoolT
, pure TimeT
, pure StringT
, StructT <$> arbitrary
, OptionT <$> arbitrary
]
[ ArrayT <$> arbitrary
, BufT <$> (getPositive <$> arbitrary) <*> arbitrary
, PairT <$> arbitrary <*> arbitrary
, SumT <$> arbitrary <*> arbitrary
, MapT <$> arbitrary <*> arbitrary
, OptionT <$> arbitrary
, StructT <$> arbitrary
]

instance Arbitrary StructType where
Expand Down
21 changes: 14 additions & 7 deletions icicle-compiler/test/Icicle/Test/Arbitrary/Program.hs
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,6 @@ isSupportedInput = \case
IntT -> True
DoubleT -> True
TimeT -> True
FactIdentifierT
-> True
StringT -> True

UnitT -> False
Expand All @@ -185,6 +183,8 @@ isSupportedInput = \case
PairT{} -> False
SumT{} -> False
OptionT{} -> False
FactIdentifierT
-> False

ArrayT t
-> isSupportedInputElem t
Expand All @@ -201,10 +201,14 @@ isSupportedInputElem = \case
IntT -> True
DoubleT -> True
TimeT -> True
FactIdentifierT
-> True
StringT -> True

OptionT BoolT -> True
OptionT IntT -> True
OptionT DoubleT -> True
OptionT TimeT -> True
OptionT StringT -> True

UnitT -> False
ErrorT -> False
ArrayT{} -> False
Expand All @@ -213,6 +217,8 @@ isSupportedInputElem = \case
PairT{} -> False
SumT{} -> False
OptionT{} -> False
FactIdentifierT
-> False

StructT (StructType fs)
-> all isSupportedInputField (Map.elems fs)
Expand All @@ -223,7 +229,6 @@ isSupportedInputField = \case
IntT -> True
DoubleT -> True
TimeT -> True
FactIdentifierT -> True
StringT -> True
OptionT BoolT -> True
OptionT IntT -> True
Expand All @@ -239,6 +244,8 @@ isSupportedInputField = \case
PairT{} -> False
SumT{} -> False
OptionT{} -> False
FactIdentifierT
-> False

StructT (StructType fs)
-> all isSupportedInputField (Map.elems fs)
Expand Down Expand Up @@ -272,14 +279,14 @@ isSupportedOutputBase = \case
IntT -> True
DoubleT -> True
TimeT -> True
FactIdentifierT
-> True
StringT -> True

UnitT -> False
ErrorT -> False
BufT{} -> False
StructT{} -> False
FactIdentifierT
-> False

_ -> False

Expand Down
Loading

0 comments on commit 4cb4399

Please sign in to comment.