Skip to content

Commit c14dcdc

Browse files
committed
Add tests for json compatibility
refs #2655, #3494
1 parent 34fa25d commit c14dcdc

5 files changed

Lines changed: 24 additions & 2 deletions

File tree

‎package.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ extra-source-files:
2020
- tests/purs/**/*.js
2121
- tests/purs/**/*.purs
2222
- tests/purs/**/*.json
23+
- tests/json-compat/**/*.json
2324
- tests/support/*.json
2425
- tests/support/setup-win.cmd
2526
- tests/support/psci/**.purs

‎tests/TestPscPublish.hs‎

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,26 +11,44 @@ import Data.ByteString.Lazy (ByteString)
1111
import Data.Time.Clock (getCurrentTime)
1212
import qualified Data.Aeson as A
1313
import Data.Version
14+
import Data.Foldable (forM_)
1415
import qualified Text.PrettyPrint.Boxes as Boxes
16+
import System.Directory (listDirectory)
17+
import System.FilePath ((</>))
1518

1619
import Language.PureScript.Docs
1720
import Language.PureScript.Publish
1821
import Language.PureScript.Publish.ErrorsWarnings as Publish
1922

2023
import Test.Tasty
21-
import Test.Tasty.Hspec (Spec, Expectation, it, expectationFailure, testSpec)
24+
import Test.Tasty.Hspec (Spec, Expectation, runIO, context, it, expectationFailure, testSpec)
2225
import TestUtils
2326

2427
main :: IO TestTree
2528
main = testSpec "publish" spec
2629

2730
spec :: Spec
2831
spec = do
29-
it "roundtrips purescript-prelude" $ do
32+
it "roundtrips the json for purescript-prelude" $ do
3033
testPackage
3134
"tests/support/bower_components/purescript-prelude"
3235
"../../prelude-resolutions.json"
3336

37+
context "json compatibility" $ do
38+
let compatDir = "tests" </> "json-compat"
39+
versions <- runIO $ listDirectory compatDir
40+
forM_ versions $ \version -> do
41+
context ("json produced by " ++ version) $ do
42+
files <- runIO $ listDirectory (compatDir </> version)
43+
forM_ files $ \file -> do
44+
it file $ do
45+
result <- A.eitherDecodeFileStrict' (compatDir </> version </> file)
46+
case result of
47+
Right (_ :: VerifiedPackage) ->
48+
pure ()
49+
Left err ->
50+
expectationFailure ("JSON parsing failed: " ++ err)
51+
3452
data TestResult
3553
= ParseFailed String
3654
| Mismatch ByteString ByteString -- ^ encoding before, encoding after

‎tests/json-compat/v0.11.3/generics-4.0.0.json‎

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"uploader":"paf31","packageMeta":{"homepage":"https://github.com/purescript/purescript-symbols","repository":{"url":"git://github.com/purescript/purescript-symbols.git","type":"git"},"ignore":["**/.*","bower_components","node_modules","output","test","bower.json","package.json"],"dependencies":{"purescript-prelude":"^3.0.0","purescript-unsafe-coerce":"^3.0.0"},"name":"purescript-symbols","license":["MIT"],"description":"Utilities for working with type-level strings"},"tagTime":"2017-03-26T00:59:23+0000","modules":[{"reExports":[],"name":"Data.Symbol","comments":null,"declarations":[{"children":[{"comments":null,"title":"SProxy","info":{"arguments":[],"declType":"dataConstructor"},"sourceSpan":null}],"comments":"A value-level proxy for a type-level symbol.\n","title":"SProxy","info":{"declType":"data","dataDeclType":"data","typeArguments":[["sym",{"tag":"NamedKind","contents":[["Prim"],"Symbol"]}]]},"sourceSpan":{"start":[12,1],"name":"/private/tmp/pursuit-staging/.psc-package/psc-0.11.3/symbols/v3.0.0/src/Data/Symbol.purs","end":[12,37]}},{"children":[{"comments":null,"title":"reflectSymbol","info":{"declType":"typeClassMember","type":{"tag":"TypeApp","contents":[{"tag":"TypeApp","contents":[{"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"tag":"TypeApp","contents":[{"tag":"TypeConstructor","contents":[["Data","Symbol"],"SProxy"]},{"tag":"TypeVar","contents":"sym"}]}]},{"tag":"TypeConstructor","contents":[["Prim"],"String"]}]}},"sourceSpan":null},{"comments":null,"title":"isSymbolTypeConcat","info":{"declType":"instance","dependencies":[{"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"tag":"TypeVar","contents":"left"}],"constraintData":null},{"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"tag":"TypeVar","contents":"right"}],"constraintData":null}],"type":{"tag":"TypeApp","contents":[{"tag":"TypeConstructor","contents":[["Data","Symbol"],"IsSymbol"]},{"tag":"ParensInType","contents":{"tag":"TypeApp","contents":[{"tag":"TypeApp","contents":[{"tag":"TypeConstructor","contents":[["Prim"],"TypeConcat"]},{"tag":"TypeVar","contents":"left"}]},{"tag":"TypeVar","contents":"right"}]}}]}},"sourceSpan":{"start":[18,1],"name":"/private/tmp/pursuit-staging/.psc-package/psc-0.11.3/symbols/v3.0.0/src/Data/Symbol.purs","end":[19,100]}}],"comments":"A class for known symbols\n","title":"IsSymbol","info":{"fundeps":[],"arguments":[["sym",{"tag":"NamedKind","contents":[["Prim"],"Symbol"]}]],"declType":"typeClass","superclasses":[]},"sourceSpan":{"start":[15,1],"name":"/private/tmp/pursuit-staging/.psc-package/psc-0.11.3/symbols/v3.0.0/src/Data/Symbol.purs","end":[16,40]}},{"children":[],"comments":null,"title":"reifySymbol","info":{"declType":"value","type":{"tag":"ForAll","contents":["r",{"tag":"TypeApp","contents":[{"tag":"TypeApp","contents":[{"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"tag":"TypeConstructor","contents":[["Prim"],"String"]}]},{"tag":"TypeApp","contents":[{"tag":"TypeApp","contents":[{"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"tag":"ParensInType","contents":{"tag":"ForAll","contents":["sym",{"tag":"ConstrainedType","contents":[{"constraintClass":[["Data","Symbol"],"IsSymbol"],"constraintArgs":[{"tag":"TypeVar","contents":"sym"}],"constraintData":null},{"tag":"TypeApp","contents":[{"tag":"TypeApp","contents":[{"tag":"TypeConstructor","contents":[["Prim"],"Function"]},{"tag":"TypeApp","contents":[{"tag":"TypeConstructor","contents":[["Data","Symbol"],"SProxy"]},{"tag":"TypeVar","contents":"sym"}]}]},{"tag":"TypeVar","contents":"r"}]}]},null]}}]},{"tag":"TypeVar","contents":"r"}]}]},null]}},"sourceSpan":{"start":[21,1],"name":"/private/tmp/pursuit-staging/.psc-package/psc-0.11.3/symbols/v3.0.0/src/Data/Symbol.purs","end":[21,86]}}]}],"resolvedDependencies":{"purescript-prelude":"3.0.0","purescript-unsafe-coerce":"3.0.0"},"version":"3.0.0","github":["purescript","purescript-symbols"],"versionTag":"v3.0.0","moduleMap":{"Data.BooleanAlgebra":"purescript-prelude","Data.Ring":"purescript-prelude","Data.Ord":"purescript-prelude","Data.Boolean":"purescript-prelude","Data.Bounded":"purescript-prelude","Data.Show":"purescript-prelude","Control.Apply":"purescript-prelude","Control.Monad":"purescript-prelude","Control.Bind":"purescript-prelude","Data.HeytingAlgebra":"purescript-prelude","Data.Ord.Unsafe":"purescript-prelude","Data.Semigroup":"purescript-prelude","Data.Semiring":"purescript-prelude","Data.CommutativeRing":"purescript-prelude","Data.NaturalTransformation":"purescript-prelude","Data.Functor":"purescript-prelude","Unsafe.Coerce":"purescript-unsafe-coerce","Control.Category":"purescript-prelude","Data.Function":"purescript-prelude","Data.Field":"purescript-prelude","Data.EuclideanRing":"purescript-prelude","Prelude":"purescript-prelude","Data.Eq":"purescript-prelude","Data.Void":"purescript-prelude","Data.Unit":"purescript-prelude","Data.Ordering":"purescript-prelude","Control.Semigroupoid":"purescript-prelude","Control.Applicative":"purescript-prelude"},"compilerVersion":"0.11.3"}

‎tests/json-compat/v0.12.1/typelevel-prelude-3.0.0.json‎

Lines changed: 1 addition & 0 deletions
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)