Skip to content

Commit 5ae17cb

Browse files
committed
Merge pull request #27 from passy/psc-074-upgrade
Upgrade for psc 0.7.4
2 parents dab77ed + 5718360 commit 5ae17cb

File tree

3 files changed

+38
-30
lines changed

3 files changed

+38
-30
lines changed

.travis.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
language: node_js
2+
sudo: false
23
node_js:
34
- 0.10
45
env:
56
- TAG=v0.7.0
67
install:
7-
- wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz
8-
- sudo tar zxvf $HOME/purescript.tar.gz -C /usr/local/bin purescript/psc{,i,-docs,-bundle} --strip-components=1
9-
- sudo chmod a+x /usr/local/bin/psc{,i,-docs,-bundle}
10-
- npm install bower gulp -g
8+
- npm install -g bower gulp purescript
119
- npm install && bower install
1210
script:
13-
- gulp test-make
11+
- gulp test

bower.json

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
],
88
"license": "MIT",
99
"dependencies": {
10-
"purescript-argonaut-traversals": "^0.1.0",
11-
"purescript-argonaut-core": "^0.1.0",
12-
"purescript-argonaut-codecs": "^0.1.0"
10+
"purescript-argonaut-traversals": "^0.2.0",
11+
"purescript-argonaut-core": "^0.2.0",
12+
"purescript-argonaut-codecs": "^0.3.0"
1313
},
1414
"devDependencies": {
1515
"purescript-console": "^0.1.0",
16-
"purescript-strongcheck": "^0.10.0"
16+
"purescript-strongcheck": "^0.12.0"
1717
},
1818
"resolutions": {
19-
"purescript-lens": "^0.8.0"
19+
"purescript-lens": "^0.8.0",
20+
"purescript-argonaut-codecs": "^0.3.0"
2021
}
2122
}

test/Test/Main.purs

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,16 @@ import Data.Argonaut.Core (Json())
88
import Data.Either
99
import Data.Tuple
1010
import Data.Maybe
11-
import Data.Array
11+
import Data.Array
1212
import Data.List (toList)
1313
import Control.Monad.Eff.Console
1414
import qualified Data.StrMap as M
1515

1616
import Test.StrongCheck
1717
import Test.StrongCheck.Gen
1818

19+
newtype TestJson = TestJson Json
20+
1921
genJNull :: Gen Json
2022
genJNull = pure jsonNull
2123

@@ -48,30 +50,38 @@ genJson n = frequency (Tuple 1.0 genJNull) rest where
4850
Tuple 1.0 (genJArray n),
4951
Tuple 1.0 (genJObject n)]
5052

51-
instance arbitraryJson :: Arbitrary Json where
52-
arbitrary = sized genJson
5353

54-
prop_encode_then_decode :: Json -> Boolean
55-
prop_encode_then_decode json =
54+
instance arbitraryJson :: Arbitrary TestJson where
55+
arbitrary = TestJson <$> sized genJson
56+
57+
prop_encode_then_decode :: TestJson -> Boolean
58+
prop_encode_then_decode (TestJson json) =
5659
Right json == (decodeJson $ encodeJson $ json)
5760

58-
prop_decode_then_encode :: Json -> Boolean
59-
prop_decode_then_encode json =
61+
prop_decode_then_encode :: TestJson -> Boolean
62+
prop_decode_then_encode (TestJson json) =
6063
let decoded = (decodeJson json) :: Either String Json in
6164
Right json == (decoded >>= (encodeJson >>> pure))
6265

63-
prop_toPrims_fromPrims :: Json -> Result
64-
prop_toPrims_fromPrims j = Just j == fromPrims (toPrims j) <?> "fromPrims.toPrims: " ++ show (toPrims j) ++ "\n\n" ++ show (fromPrims (toPrims j))
66+
prop_toPrims_fromPrims :: TestJson -> Result
67+
prop_toPrims_fromPrims (TestJson j) =
68+
Just j == fromPrims (toPrims j) <?> "fromPrims.toPrims: " ++ show (toPrims j) ++ "\n\n" ++ show (fromPrims (toPrims j))
69+
70+
newtype TestJCursor = TestJCursor JCursor
6571

66-
instance arbJCursor :: Arbitrary JCursor where
67-
arbitrary = do i <- chooseInt 0.0 2.0
68-
r <- if i == 0 then pure JCursorTop
69-
else if i == 1 then JField <$> arbitrary <*> arbitrary
70-
else JIndex <$> arbitrary <*> arbitrary
71-
return r
72+
runTestJCursor :: TestJCursor -> JCursor
73+
runTestJCursor (TestJCursor j) = j
7274

73-
prop_jcursor_serialization :: JCursor -> Result
74-
prop_jcursor_serialization c =
75+
instance arbJCursor :: Arbitrary TestJCursor where
76+
arbitrary = do
77+
i <- chooseInt 0.0 2.0
78+
r <- if i == 0 then pure JCursorTop
79+
else if i == 1 then JField <$> arbitrary <*> (runTestJCursor <$> arbitrary)
80+
else JIndex <$> arbitrary <*> (runTestJCursor <$> arbitrary)
81+
return $ TestJCursor r
82+
83+
prop_jcursor_serialization :: TestJCursor -> Result
84+
prop_jcursor_serialization (TestJCursor c) =
7585
(decodeJson (encodeJson c) == Right c) <?> "JCursor: " ++ show c
7686

7787
main = do
@@ -91,6 +101,5 @@ main = do
91101
quickCheck' 20 prop_jcursor_serialization
92102

93103
log "Testing .? combinator"
94-
assert $ let bar = fromString "bar"
95-
in (M.singleton "foo" bar) .? "foo" == Right bar
96-
104+
assert $ let bar = fromString "bar"
105+
in (M.singleton "foo" bar) .? "foo" == Right bar

0 commit comments

Comments
 (0)