Skip to content

Commit

Permalink
Updates for 0.12 (#13)
Browse files Browse the repository at this point in the history
* Updates for 0.12

* Use versions in travis file

* Use stable node
  • Loading branch information
natefaubion authored and paulyoung committed Jun 20, 2018
1 parent 32fbcea commit 0ecb709
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 26 deletions.
4 changes: 2 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
language: node_js
dist: trusty
sudo: required
node_js: 6
node_js: stable
install:
- npm install -g yarn
- yarn global add purescript pulp bower purescript-psa
- yarn global add purescript@^0.12.0 pulp@^12.3.0 bower purescript-psa@^0.6.0
- export PATH="$PATH:`yarn global bin`"
- bower install
script:
Expand Down
16 changes: 8 additions & 8 deletions bower.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
"output"
],
"dependencies": {
"purescript-prelude": "^3.1.1",
"purescript-console": "^3.0.0",
"purescript-lists": "^4.12.0",
"purescript-tuples": "^4.1.0",
"purescript-spec-quickcheck": "^2.0.0"
"purescript-prelude": "^4.0.0",
"purescript-console": "^4.0.0",
"purescript-lists": "^5.0.0",
"purescript-tuples": "^5.0.0"
},
"devDependencies": {
"purescript-psci-support": "^3.0.0",
"purescript-spec": "^2.0.0",
"purescript-spec-discovery": "^2.0.0"
"purescript-quickcheck": "^5.0.0",
"purescript-psci-support": "^4.0.0",
"purescript-spec": "^3.0.0",
"purescript-spec-discovery": "owickstrom/purescript-spec-discovery#a1a8dfd5fadb3f00199d68d20af4bbf56a048c6e"
}
}
1 change: 0 additions & 1 deletion src/Prettier/Printer.purs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ import Data.Array as Array
import Data.Foldable (intercalate)
import Data.List (List(Cons), (:))
import Data.List as List
import Data.Monoid (class Monoid)
import Data.String (Pattern(..))
import Data.String as String
import Data.Tuple (Tuple(..))
Expand Down
7 changes: 3 additions & 4 deletions test/Main.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ module Test.Main where

import Prelude

import Control.Monad.Eff (Eff)
import Node.FS (FS)
import Effect (Effect)
import Test.Spec.Discovery (discover)
import Test.Spec.Reporter.Console (consoleReporter)
import Test.Spec.Runner (RunnerEffects, run)
import Test.Spec.Runner (run)

main :: Eff (RunnerEffects (fs :: FS)) Unit
main :: Effect Unit
main = discover "Test\\.Prettier.Printer\\.*" >>= run [consoleReporter]
22 changes: 11 additions & 11 deletions test/Prettier/Printer.purs
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ module Test.Prettier.Printer where

import Prelude

import Control.Monad.Gen (oneOf)
import Data.NonEmpty ((:|))
import Effect.Class (liftEffect)
import Prettier.Printer (DOC, line, nest, nil, pretty, text)
import Test.QuickCheck (class Arbitrary, arbitrary, (===))
import Test.QuickCheck.Gen (oneOf)
import Test.QuickCheck (class Arbitrary, arbitrary, quickCheck, (===))
import Test.Spec (Spec, describe, it)
import Test.Spec.QuickCheck (QCRunnerEffects, quickCheck)

newtype DOC' = DOC' DOC

Expand All @@ -18,31 +18,31 @@ instance arbDOC' :: Arbitrary DOC' where
, pure <<< DOC' $ line
]

spec :: Spec (QCRunnerEffects ()) Unit
spec :: Spec Unit
spec = describe "Prettier.Printer" do
describe "text" do
it "is a homomorphism from string concatenation to document concatenation" do
quickCheck \w s t ->
liftEffect $ quickCheck \w s t ->
pretty w (text (s <> t)) === pretty w ((text s <> text t))

quickCheck \w ->
liftEffect $ quickCheck \w ->
pretty w (text "") === pretty w nil

describe "nest" do
it "is a homomorphism from addition to composition" do
quickCheck \w i j (DOC' x) ->
liftEffect $ quickCheck \w i j (DOC' x) ->
pretty w (nest (i + j) x) == pretty w (nest i (nest j x))

quickCheck \w (DOC' x) ->
liftEffect $ quickCheck \w (DOC' x) ->
pretty w (nest 0 x) == pretty w x

it "distributes through concatenation" do
quickCheck \w i (DOC' x) (DOC' y) ->
liftEffect $ quickCheck \w i (DOC' x) (DOC' y) ->
pretty w (nest i (x <> y)) == pretty w (nest i x <> nest i y)

quickCheck \w i ->
liftEffect $ quickCheck \w i ->
pretty w (nest i nil) == pretty w nil

it "is absorbed by text" do
quickCheck \w i s ->
liftEffect $ quickCheck \w i s ->
pretty w (nest i (text s)) == pretty w (text s)

0 comments on commit 0ecb709

Please sign in to comment.