From aaee7cbfda08985f2c9e8208f35c28777748a5a8 Mon Sep 17 00:00:00 2001 From: Maxim Zimaliev Date: Mon, 14 May 2018 18:49:13 +0300 Subject: [PATCH 1/5] 0.12 update --- bower.json | 10 +++++----- package.json | 6 +++--- src/Data/Argonaut.purs | 2 +- test/Test/Main.purs | 20 ++++++++++---------- 4 files changed, 19 insertions(+), 19 deletions(-) diff --git a/bower.json b/bower.json index 8a65280..8398ab0 100644 --- a/bower.json +++ b/bower.json @@ -11,12 +11,12 @@ }, "license": "MIT", "dependencies": { - "purescript-argonaut-codecs": "^3.0.0", - "purescript-argonaut-core": "^3.1.0", - "purescript-argonaut-traversals": "^3.0.0" + "purescript-argonaut-codecs": "cryogenian/purescript-argonaut-codecs#compiler/0.12", + "purescript-argonaut-core": "#compiler/0.12", + "purescript-argonaut-traversals": "cryogenian/purescript-argonaut-traversals#compiler/0.12" }, "devDependencies": { - "purescript-console": "^3.0.0", - "purescript-strongcheck": "^3.1.0" + "purescript-console": "#compiler/0.12", + "purescript-strongcheck": "#compiler/0.12" } } diff --git a/package.json b/package.json index c9ad9ff..a263d27 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,9 @@ "test": "pulp build --include examples -- --censor-lib --strict && pulp test" }, "devDependencies": { - "pulp": "^11.0.2", - "purescript-psa": "^0.5.1", - "purescript": "^0.11.6", + "pulp": "^12.0.1", + "purescript-psa": "^0.6.0", + "purescript": "cryogenian/node-purescript-bin#master", "rimraf": "^2.6.2" } } diff --git a/src/Data/Argonaut.purs b/src/Data/Argonaut.purs index ca9b26a..d423bd0 100644 --- a/src/Data/Argonaut.purs +++ b/src/Data/Argonaut.purs @@ -8,7 +8,7 @@ module Data.Argonaut , module Data.Argonaut.Traversals ) where -import Data.Argonaut.Core (JArray, JAssoc, JBoolean, JNull, JNumber, JObject, JString, Json, foldJson, foldJsonArray, foldJsonBoolean, foldJsonNull, foldJsonNumber, foldJsonObject, foldJsonString, fromArray, fromBoolean, fromNull, fromNumber, fromObject, fromString, isArray, isBoolean, isNull, isNumber, isObject, isString, jNull, jsonEmptyArray, jsonEmptyObject, jsonEmptyString, jsonFalse, jsonNull, jsonSingletonArray, jsonSingletonObject, jsonTrue, jsonZero, stringify, toArray, toBoolean, toNull, toNumber, toObject, toString) +import Data.Argonaut.Core (Json, caseJson, caseJsonArray, caseJsonBoolean, caseJsonNull, caseJsonNumber, caseJsonObject, caseJsonString, fromArray, fromBoolean, fromNumber, fromObject, fromString, isArray, isBoolean, isNull, isNumber, isObject, isString, jsonNull, jsonEmptyArray, jsonEmptyObject, jsonEmptyString, jsonFalse, jsonNull, jsonSingletonArray, jsonSingletonObject, jsonTrue, jsonZero, stringify, toArray, toBoolean, toNull, toNumber, toObject, toString) import Data.Argonaut.Decode (class DecodeJson, decodeJson, defaultField, getField, getFieldOptional, (.?), (.?=), (.??)) import Data.Argonaut.Encode (class EncodeJson, assoc, encodeJson, extend, (:=), (~>)) import Data.Argonaut.JCursor (JCursor(..), JsonPrim(..), cursorGet, cursorSet, downField, downIndex, fail, fromPrims, inferEmpty, insideOut, primBool, primNull, primNum, primStr, primToJson, runJsonPrim, toPrims) diff --git a/test/Test/Main.purs b/test/Test/Main.purs index 45577ad..74db4e5 100644 --- a/test/Test/Main.purs +++ b/test/Test/Main.purs @@ -2,16 +2,16 @@ module Test.Main where import Prelude -import Control.Monad.Eff.Console (log) - -import Data.Argonaut (Json, decodeJson, encodeJson, fromString, (.?)) -import Data.Argonaut.JCursor (JCursor(..), toPrims, fromPrims) +import Data.Argonaut (Json, decodeJson, encodeJson, fromString, (.?), stringify) import Data.Argonaut.Gen (genJson) +import Data.Argonaut.JCursor (JCursor(..), toPrims, fromPrims) +import Data.Foldable (foldMap) import Data.Either (Either(..)) import Data.Maybe (Maybe(..)) -import Data.StrMap as M - -import Test.StrongCheck (SC, Result, assert, quickCheck', ()) +import Effect (Effect) +import Effect.Console (log) +import Foreign.Object as FO +import Test.StrongCheck (Result, assert, quickCheck', ()) import Test.StrongCheck.Arbitrary (class Arbitrary, arbitrary) import Test.StrongCheck.Gen (chooseInt, resize) @@ -31,7 +31,7 @@ prop_decode_then_encode (TestJson json) = prop_toPrims_fromPrims :: TestJson -> Result prop_toPrims_fromPrims (TestJson j) = - Just j == fromPrims (toPrims j) "fromPrims.toPrims: " <> show (toPrims j) <> "\n\n" <> show (fromPrims (toPrims j)) + Just j == fromPrims (toPrims j) "fromPrims.toPrims: " <> show (toPrims j) <> "\n\n" <> foldMap stringify (fromPrims (toPrims j)) newtype TestJCursor = TestJCursor JCursor @@ -50,7 +50,7 @@ prop_jcursor_serialization :: TestJCursor -> Result prop_jcursor_serialization (TestJCursor c) = (decodeJson (encodeJson c) == Right c) "JCursor: " <> show c -main :: SC () Unit +main :: Effect Unit main = do log "Testing that any JSON can be encoded and then decoded" quickCheck' 20 prop_encode_then_decode @@ -66,4 +66,4 @@ main = do log "Testing .? combinator" assert $ let bar = fromString "bar" - in (M.singleton "foo" bar) .? "foo" == Right bar + in (FO.singleton "foo" bar) .? "foo" == Right bar From 3fe010f7ed2cc098fc44d4d292e6218c51c0cea6 Mon Sep 17 00:00:00 2001 From: Christoph Date: Mon, 21 May 2018 17:07:25 +0200 Subject: [PATCH 2/5] deps, remove duplicate import --- bower.json | 4 ++-- package.json | 2 +- src/Data/Argonaut.purs | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/bower.json b/bower.json index 8398ab0..9642f4a 100644 --- a/bower.json +++ b/bower.json @@ -11,9 +11,9 @@ }, "license": "MIT", "dependencies": { - "purescript-argonaut-codecs": "cryogenian/purescript-argonaut-codecs#compiler/0.12", + "purescript-argonaut-codecs": "#compiler/0.12", "purescript-argonaut-core": "#compiler/0.12", - "purescript-argonaut-traversals": "cryogenian/purescript-argonaut-traversals#compiler/0.12" + "purescript-argonaut-traversals": "#compiler/0.12" }, "devDependencies": { "purescript-console": "#compiler/0.12", diff --git a/package.json b/package.json index a263d27..076a8f0 100644 --- a/package.json +++ b/package.json @@ -8,7 +8,7 @@ "devDependencies": { "pulp": "^12.0.1", "purescript-psa": "^0.6.0", - "purescript": "cryogenian/node-purescript-bin#master", + "purescript": "^0.11.1", "rimraf": "^2.6.2" } } diff --git a/src/Data/Argonaut.purs b/src/Data/Argonaut.purs index d423bd0..74981dd 100644 --- a/src/Data/Argonaut.purs +++ b/src/Data/Argonaut.purs @@ -8,7 +8,7 @@ module Data.Argonaut , module Data.Argonaut.Traversals ) where -import Data.Argonaut.Core (Json, caseJson, caseJsonArray, caseJsonBoolean, caseJsonNull, caseJsonNumber, caseJsonObject, caseJsonString, fromArray, fromBoolean, fromNumber, fromObject, fromString, isArray, isBoolean, isNull, isNumber, isObject, isString, jsonNull, jsonEmptyArray, jsonEmptyObject, jsonEmptyString, jsonFalse, jsonNull, jsonSingletonArray, jsonSingletonObject, jsonTrue, jsonZero, stringify, toArray, toBoolean, toNull, toNumber, toObject, toString) +import Data.Argonaut.Core (Json, caseJson, caseJsonArray, caseJsonBoolean, caseJsonNull, caseJsonNumber, caseJsonObject, caseJsonString, fromArray, fromBoolean, fromNumber, fromObject, fromString, isArray, isBoolean, isNull, isNumber, isObject, isString, jsonEmptyArray, jsonEmptyObject, jsonEmptyString, jsonFalse, jsonNull, jsonSingletonArray, jsonSingletonObject, jsonTrue, jsonZero, stringify, toArray, toBoolean, toNull, toNumber, toObject, toString) import Data.Argonaut.Decode (class DecodeJson, decodeJson, defaultField, getField, getFieldOptional, (.?), (.?=), (.??)) import Data.Argonaut.Encode (class EncodeJson, assoc, encodeJson, extend, (:=), (~>)) import Data.Argonaut.JCursor (JCursor(..), JsonPrim(..), cursorGet, cursorSet, downField, downIndex, fail, fromPrims, inferEmpty, insideOut, primBool, primNull, primNum, primStr, primToJson, runJsonPrim, toPrims) From 89a7c5c060ed9c64d05db6282b3817de98ff5b6e Mon Sep 17 00:00:00 2001 From: kRITZCREEK Date: Sat, 9 Jun 2018 12:33:10 +0200 Subject: [PATCH 3/5] updates deps --- bower.json | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/bower.json b/bower.json index 9642f4a..579508e 100644 --- a/bower.json +++ b/bower.json @@ -11,12 +11,12 @@ }, "license": "MIT", "dependencies": { - "purescript-argonaut-codecs": "#compiler/0.12", - "purescript-argonaut-core": "#compiler/0.12", - "purescript-argonaut-traversals": "#compiler/0.12" + "purescript-argonaut-codecs": "^4.0.0", + "purescript-argonaut-core": "^4.0.0", + "purescript-argonaut-traversals": "^4.0.0" }, "devDependencies": { - "purescript-console": "#compiler/0.12", - "purescript-strongcheck": "#compiler/0.12" + "purescript-console": "^4.0.0", + "purescript-quickcheck": "^5.0.0" } } From a29aa1438297e4a21d60dfde8ba5c76b46317371 Mon Sep 17 00:00:00 2001 From: kRITZCREEK Date: Sat, 9 Jun 2018 12:33:17 +0200 Subject: [PATCH 4/5] removes duplicate tests (these already exist in purescript-codec) --- test/Test/Main.purs | 69 +++++++++++++++------------------------------ 1 file changed, 22 insertions(+), 47 deletions(-) diff --git a/test/Test/Main.purs b/test/Test/Main.purs index 74db4e5..3435a44 100644 --- a/test/Test/Main.purs +++ b/test/Test/Main.purs @@ -2,68 +2,43 @@ module Test.Main where import Prelude -import Data.Argonaut (Json, decodeJson, encodeJson, fromString, (.?), stringify) +import Data.Argonaut (Json, decodeJson, encodeJson, stringify) import Data.Argonaut.Gen (genJson) import Data.Argonaut.JCursor (JCursor(..), toPrims, fromPrims) -import Data.Foldable (foldMap) import Data.Either (Either(..)) +import Data.Foldable (foldMap) import Data.Maybe (Maybe(..)) +import Data.String.Gen (genUnicodeString) import Effect (Effect) import Effect.Console (log) -import Foreign.Object as FO -import Test.StrongCheck (Result, assert, quickCheck', ()) -import Test.StrongCheck.Arbitrary (class Arbitrary, arbitrary) -import Test.StrongCheck.Gen (chooseInt, resize) - -newtype TestJson = TestJson Json - -instance arbitraryJson :: Arbitrary TestJson where - arbitrary = TestJson <$> (resize 5 genJson) - -prop_encode_then_decode :: TestJson -> Boolean -prop_encode_then_decode (TestJson json) = - Right json == (decodeJson $ encodeJson $ json) +import Test.QuickCheck (Result, quickCheck, ()) +import Test.QuickCheck.Gen (Gen, chooseInt, resize) -prop_decode_then_encode :: TestJson -> Boolean -prop_decode_then_encode (TestJson json) = - let decoded = (decodeJson json) :: Either String Json in - Right json == (decoded >>= (encodeJson >>> pure)) +genTestJson :: Gen Json +genTestJson = resize 5 genJson -prop_toPrims_fromPrims :: TestJson -> Result -prop_toPrims_fromPrims (TestJson j) = - Just j == fromPrims (toPrims j) "fromPrims.toPrims: " <> show (toPrims j) <> "\n\n" <> foldMap stringify (fromPrims (toPrims j)) +prop_toPrims_fromPrims :: Gen Result +prop_toPrims_fromPrims = do + j <- genTestJson + pure $ Just j == fromPrims (toPrims j) "fromPrims.toPrims: " <> show (toPrims j) <> "\n\n" <> foldMap stringify (fromPrims (toPrims j)) -newtype TestJCursor = TestJCursor JCursor - -runTestJCursor :: TestJCursor -> JCursor -runTestJCursor (TestJCursor j) = j - -instance arbJCursor :: Arbitrary TestJCursor where - arbitrary = do +genTestJCursor :: Gen JCursor +genTestJCursor = do i <- chooseInt 0 2 r <- if i == 0 then pure JCursorTop - else if i == 1 then JField <$> arbitrary <*> (runTestJCursor <$> arbitrary) - else JIndex <$> arbitrary <*> (runTestJCursor <$> arbitrary) - pure $ TestJCursor r + else if i == 1 then JField <$> genUnicodeString <*> genTestJCursor + else JIndex <$> chooseInt bottom top <*> genTestJCursor + pure r -prop_jcursor_serialization :: TestJCursor -> Result -prop_jcursor_serialization (TestJCursor c) = - (decodeJson (encodeJson c) == Right c) "JCursor: " <> show c +prop_jcursor_serialization :: Gen Result +prop_jcursor_serialization = do + c <- genTestJCursor + pure $ (decodeJson (encodeJson c) == Right c) "JCursor: " <> show c main :: Effect Unit main = do - log "Testing that any JSON can be encoded and then decoded" - quickCheck' 20 prop_encode_then_decode - - log "Testing that any JSON can be decoded and then encoded" - quickCheck' 20 prop_decode_then_encode - log "Testing that toPrims / fromPrims inverses" - quickCheck' 20 prop_toPrims_fromPrims + quickCheck prop_toPrims_fromPrims log "Testing that JCursor can be encoded / decoded from JSON" - quickCheck' 20 prop_jcursor_serialization - - log "Testing .? combinator" - assert $ let bar = fromString "bar" - in (FO.singleton "foo" bar) .? "foo" == Right bar + quickCheck prop_jcursor_serialization From cb7c83ed6241a25e193903b0150cdac0cfd01370 Mon Sep 17 00:00:00 2001 From: kRITZCREEK Date: Sat, 9 Jun 2018 12:34:51 +0200 Subject: [PATCH 5/5] update package.json deps --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 076a8f0..85c3e1f 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,9 @@ "test": "pulp build --include examples -- --censor-lib --strict && pulp test" }, "devDependencies": { - "pulp": "^12.0.1", + "pulp": "^12.0.0", "purescript-psa": "^0.6.0", - "purescript": "^0.11.1", + "purescript": "^0.12.0", "rimraf": "^2.6.2" } }