diff --git a/.travis.yml b/.travis.yml index 15bacc0..2e30c22 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js dist: trusty sudo: required -node_js: 6 +node_js: stable install: - npm install -g bower - npm install diff --git a/bower.json b/bower.json index 924728f..8a65280 100644 --- a/bower.json +++ b/bower.json @@ -11,12 +11,12 @@ }, "license": "MIT", "dependencies": { - "purescript-argonaut-codecs": "^2.0.0", - "purescript-argonaut-core": "^2.0.0", - "purescript-argonaut-traversals": "^2.0.0" + "purescript-argonaut-codecs": "^3.0.0", + "purescript-argonaut-core": "^3.1.0", + "purescript-argonaut-traversals": "^3.0.0" }, "devDependencies": { - "purescript-console": "^2.0.0", - "purescript-strongcheck": "^2.0.0" + "purescript-console": "^3.0.0", + "purescript-strongcheck": "^3.1.0" } } diff --git a/package.json b/package.json index f4e6d40..4d36e03 100644 --- a/package.json +++ b/package.json @@ -6,9 +6,9 @@ "test": "pulp build --include examples --censor-lib --strict && pulp test" }, "devDependencies": { - "pulp": "^9.0.1", - "purescript-psa": "^0.3.9", - "purescript": "^0.10.1", - "rimraf": "^2.5.4" + "pulp": "^11.0.0", + "purescript-psa": "^0.5.0", + "purescript": "^0.11.1", + "rimraf": "^2.6.1" } } diff --git a/src/Data/Argonaut.purs b/src/Data/Argonaut.purs index 09fd086..8cbf605 100644 --- a/src/Data/Argonaut.purs +++ b/src/Data/Argonaut.purs @@ -4,16 +4,14 @@ module Data.Argonaut , module Data.Argonaut.Encode , module Data.Argonaut.JCursor , module Data.Argonaut.Parser - , module Data.Argonaut.Printer , module Data.Argonaut.Prisms , 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, jsonEmptyArray, jsonEmptyObject, jsonFalse, jsonNull, jsonSingletonArray, jsonSingletonObject, jsonTrue, jsonZero, toArray, toBoolean, toNull, toNumber, toObject, toString) -import Data.Argonaut.Decode (class DecodeJson, decodeJson, gDecodeJson, gDecodeJson', getField, (.?)) -import Data.Argonaut.Encode (class EncodeJson, assoc, encodeJson, extend, gEncodeJson, gEncodeJson', (:=), (~>)) -import Data.Argonaut.JCursor (JCursor(..), JsonPrim(..), cursorGet, cursorSet, downField, downIndex, exactNull, fail, fromPrims, inferEmpty, insideOut, primBool, primNull, primNum, primStr, primToJson, runJsonPrim, toPrims) +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, jsonFalse, jsonNull, jsonSingletonArray, jsonSingletonObject, jsonTrue, jsonZero, toArray, toBoolean, toNull, toNumber, toObject, toString) +import Data.Argonaut.Decode (class DecodeJson, decodeJson, getField, (.?)) +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) import Data.Argonaut.Parser (jsonParser) -import Data.Argonaut.Printer (class Printer, printJson) import Data.Argonaut.Prisms (_Array, _Boolean, _Null, _Number, _Object, _String) import Data.Argonaut.Traversals (_JsonArray, _JsonBoolean, _JsonNull, _JsonNumber, _JsonObject, _JsonString) diff --git a/test/Test/Main.purs b/test/Test/Main.purs index fc09581..45577ad 100644 --- a/test/Test/Main.purs +++ b/test/Test/Main.purs @@ -4,58 +4,21 @@ import Prelude import Control.Monad.Eff.Console (log) -import Data.Argonaut (Json, fromString, encodeJson, decodeJson, fromObject, fromArray, fromNumber, fromBoolean, jsonNull, (.?)) +import Data.Argonaut (Json, decodeJson, encodeJson, fromString, (.?)) import Data.Argonaut.JCursor (JCursor(..), toPrims, fromPrims) -import Data.Array (zipWith, nubBy, length) +import Data.Argonaut.Gen (genJson) import Data.Either (Either(..)) -import Data.List (fromFoldable) import Data.Maybe (Maybe(..)) import Data.StrMap as M -import Data.Tuple (Tuple(..), fst) import Test.StrongCheck (SC, Result, assert, quickCheck', ()) import Test.StrongCheck.Arbitrary (class Arbitrary, arbitrary) -import Test.StrongCheck.Data.AlphaNumString (AlphaNumString(..)) -import Test.StrongCheck.Gen (Gen, Size, showSample, chooseInt, sized, frequency, oneOf, vectorOf) +import Test.StrongCheck.Gen (chooseInt, resize) newtype TestJson = TestJson Json -genJNull :: Gen Json -genJNull = pure jsonNull - -genJBool :: Gen Json -genJBool = fromBoolean <$> arbitrary - -genJNumber :: Gen Json -genJNumber = fromNumber <$> arbitrary - -genJString :: Gen Json -genJString = fromString <$> arbitrary - -genJArray :: Size -> Gen Json -genJArray sz = fromArray <$> vectorOf sz (genJson $ sz - 1) - -genJObject :: Size -> Gen Json -genJObject sz = do - v <- vectorOf sz (genJson $ sz - 1) - k <- vectorOf (length v) (arbitrary :: Gen AlphaNumString) - let - f (AlphaNumString s) = s <> "x" - k' = f <$> k - pure $ fromObject <<< M.fromFoldable <<< nubBy (\a b -> (fst a) == (fst b)) $ zipWith Tuple k' v - -genJson :: Size -> Gen Json -genJson 0 = oneOf genJNull [genJBool, genJNumber, genJString] -genJson n = frequency (Tuple 1.0 genJNull) rest where - rest = fromFoldable [Tuple 2.0 genJBool, - Tuple 2.0 genJNumber, - Tuple 3.0 genJString, - Tuple 1.0 (genJArray n), - Tuple 1.0 (genJObject n)] - - instance arbitraryJson :: Arbitrary TestJson where - arbitrary = TestJson <$> sized genJson + arbitrary = TestJson <$> (resize 5 genJson) prop_encode_then_decode :: TestJson -> Boolean prop_encode_then_decode (TestJson json) = @@ -89,9 +52,6 @@ prop_jcursor_serialization (TestJCursor c) = main :: SC () Unit main = do - log "Showing small sample of JSON" - showSample (genJson 10) - log "Testing that any JSON can be encoded and then decoded" quickCheck' 20 prop_encode_then_decode