mirror of
https://github.com/ilyakooo0/elm-bridge.git
synced 2024-10-26 14:31:57 +03:00
Add toElmType spec for primitive types
This commit is contained in:
parent
38289cc4d0
commit
c99f8cd96a
@ -59,6 +59,7 @@ test-suite derive-elm-tests
|
||||
Elm.TyRenderSpec
|
||||
Elm.JsonSpec
|
||||
Elm.ModuleSpec
|
||||
Elm.TyRepSpec
|
||||
build-depends:
|
||||
base,
|
||||
hspec >= 2.0,
|
||||
|
21
test/Elm/TyRepSpec.hs
Normal file
21
test/Elm/TyRepSpec.hs
Normal file
@ -0,0 +1,21 @@
|
||||
module Elm.TyRepSpec (spec) where
|
||||
|
||||
import Elm.TyRep
|
||||
|
||||
import Data.Proxy
|
||||
import Test.Hspec
|
||||
|
||||
spec :: Spec
|
||||
spec =
|
||||
describe "toElmType" $
|
||||
it "should produce the correct code" $
|
||||
do toElmType (Proxy :: Proxy Int) `shouldBe` ETyCon (ETCon "Int")
|
||||
toElmType (Proxy :: Proxy Float) `shouldBe` ETyCon (ETCon "Float")
|
||||
toElmType (Proxy :: Proxy String) `shouldBe` ETyCon (ETCon "String")
|
||||
toElmType (Proxy :: Proxy Bool) `shouldBe` ETyCon (ETCon "Bool")
|
||||
toElmType (Proxy :: Proxy Char) `shouldBe` ETyCon (ETCon "Char")
|
||||
toElmType (Proxy :: Proxy [Int]) `shouldBe` ETyApp (ETyCon $ ETCon "List") (ETyCon $ ETCon "Int")
|
||||
toElmType (Proxy :: Proxy (Maybe Int)) `shouldBe` ETyApp (ETyCon $ ETCon "Maybe") (ETyCon $ ETCon "Int")
|
||||
toElmType (Proxy :: Proxy ()) `shouldBe` ETyTuple 0
|
||||
toElmType (Proxy :: Proxy (Int, Bool)) `shouldBe` ETyApp (ETyApp (ETyTuple 2) (ETyCon $ ETCon "Int")) (ETyCon $ ETCon "Bool")
|
||||
toElmType (Proxy :: Proxy (Int, Bool, String)) `shouldBe` ETyApp (ETyApp (ETyApp (ETyTuple 3) (ETyCon $ ETCon "Int")) (ETyCon $ ETCon "Bool")) (ETyCon $ ETCon "String")
|
@ -4,6 +4,7 @@ import qualified Elm.DeriveSpec
|
||||
import qualified Elm.TyRenderSpec
|
||||
import qualified Elm.JsonSpec
|
||||
import qualified Elm.ModuleSpec
|
||||
import qualified Elm.TyRepSpec
|
||||
|
||||
import Test.Hspec
|
||||
|
||||
@ -13,3 +14,4 @@ main = hspec $ do
|
||||
describe "Elm.TyRenderSpec" Elm.TyRenderSpec.spec
|
||||
describe "Elm.JsonSpec" Elm.JsonSpec.spec
|
||||
describe "Elm.ModuleSpec" Elm.ModuleSpec.spec
|
||||
describe "Elm.TyRepSpec" Elm.TyRepSpec.spec
|
||||
|
Loading…
Reference in New Issue
Block a user