diff --git a/.jscsrc b/.jscsrc index 342da66..2561ce9 100644 --- a/.jscsrc +++ b/.jscsrc @@ -1,5 +1,10 @@ { "preset": "grunt", + "disallowSpacesInFunctionExpression": null, + "requireSpacesInFunctionExpression": { + "beforeOpeningRoundBrace": true, + "beforeOpeningCurlyBrace": true + }, "disallowSpacesInAnonymousFunctionExpression": null, "requireSpacesInAnonymousFunctionExpression": { "beforeOpeningRoundBrace": true, diff --git a/.jshintrc b/.jshintrc index f391159..620d8d7 100644 --- a/.jshintrc +++ b/.jshintrc @@ -5,7 +5,7 @@ "freeze": true, "funcscope": true, "futurehostile": true, - "globalstrict": true, + "strict": "global", "latedef": true, "maxparams": 1, "noarg": true, @@ -15,5 +15,6 @@ "singleGroups": true, "undef": true, "unused": true, - "eqnull": true + "eqnull": true, + "predef": ["exports"] } diff --git a/.travis.yml b/.travis.yml index 791313a..36183ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: node_js -sudo: false -node_js: - - 0.10 +sudo: required +dist: trusty +node_js: 5 env: - PATH=$HOME/purescript:$PATH install: @@ -9,6 +9,16 @@ install: - wget -O $HOME/purescript.tar.gz https://github.com/purescript/purescript/releases/download/$TAG/linux64.tar.gz - tar -xvf $HOME/purescript.tar.gz -C $HOME/ - chmod a+x $HOME/purescript + - npm install -g bower - npm install + - bower install script: - npm run build +after_success: +- >- + test $TRAVIS_TAG && + psc-publish > .pursuit.json && + curl -X POST http://pursuit.purescript.org/packages \ + -d @.pursuit.json \ + -H 'Accept: application/json' \ + -H "Authorization: token ${GITHUB_TOKEN}" diff --git a/README.md b/README.md index 36e52b1..ad7a8fa 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,6 @@ Basic assertions library for low level testing. This is primarily for testing th bower install purescript-assert ``` -## Module documentation +## Documentation -[`Test.Assert`](docs/Test/Assert.md) +Module documentation is [published on Pursuit](http://pursuit.purescript.org/packages/purescript-assert). diff --git a/bower.json b/bower.json index 9523a27..2ba5c6f 100644 --- a/bower.json +++ b/bower.json @@ -2,10 +2,6 @@ "name": "purescript-assert", "homepage": "https://github.com/purescript/purescript-assert", "description": "Basic assertions library for low level testing", - "keywords": [ - "purescript", - "assert" - ], "license": "MIT", "repository": { "type": "git", @@ -21,6 +17,6 @@ "package.json" ], "dependencies": { - "purescript-eff": "^0.1.0" + "purescript-eff": "^1.0.0-rc.1" } } diff --git a/docs/Test/Assert.md b/docs/Test/Assert.md deleted file mode 100644 index d41312f..0000000 --- a/docs/Test/Assert.md +++ /dev/null @@ -1,57 +0,0 @@ -## Module Test.Assert - -#### `ASSERT` - -``` purescript -data ASSERT :: ! -``` - -Assertion effect type. - -#### `assert` - -``` purescript -assert :: forall e. Boolean -> Eff (assert :: ASSERT | e) Unit -``` - -Throws a runtime exception with message "Assertion failed" when the boolean -value is false. - -#### `assert'` - -``` purescript -assert' :: forall e. String -> Boolean -> Eff (assert :: ASSERT | e) Unit -``` - -Throws a runtime exception with the specified message when the boolean -value is false. - -#### `assertThrows` - -``` purescript -assertThrows :: forall e a. (Unit -> a) -> Eff (assert :: ASSERT | e) Unit -``` - -Throws a runtime exception with message "Assertion failed: An error should -have been thrown", unless the argument throws an exception when evaluated. - -This function is specifically for testing unsafe pure code; for example, -to make sure that an exception is thrown if a precondition is not -satisfied. Functions which use `Eff (err :: EXCEPTION | eff) a` can be -tested with `catchException` instead. - -#### `assertThrows'` - -``` purescript -assertThrows' :: forall e a. String -> (Unit -> a) -> Eff (assert :: ASSERT | e) Unit -``` - -Throws a runtime exception with the specified message, unless the argument -throws an exception when evaluated. - -This function is specifically for testing unsafe pure code; for example, -to make sure that an exception is thrown if a precondition is not -satisfied. Functions which use `Eff (err :: EXCEPTION | eff) a` can be -tested with `catchException` instead. - - diff --git a/package.json b/package.json index 61f11c6..af45679 100644 --- a/package.json +++ b/package.json @@ -1,13 +1,13 @@ { "private": true, "scripts": { - "postinstall": "pulp dep install", - "build": "jshint src && jscs src && pulp build && rimraf docs && pulp docs" + "clean": "rimraf output && rimraf .pulp-cache", + "build": "jshint src && jscs src && pulp build" }, "devDependencies": { - "jscs": "^1.13.1", - "jshint": "^2.8.0", - "pulp": "^4.0.1", - "rimraf": "^2.4.1" + "jscs": "^2.8.0", + "jshint": "^2.9.1", + "pulp": "^8.1.0", + "rimraf": "^2.5.0" } } diff --git a/src/Test/Assert.js b/src/Test/Assert.js index ad1a67c..31d8a1e 100644 --- a/src/Test/Assert.js +++ b/src/Test/Assert.js @@ -1,4 +1,3 @@ -/* global exports */ "use strict"; // module Test.Assert diff --git a/src/Test/Assert.purs b/src/Test/Assert.purs index 66b8622..23e6b48 100644 --- a/src/Test/Assert.purs +++ b/src/Test/Assert.purs @@ -1,13 +1,14 @@ module Test.Assert - ( assert' + ( ASSERT , assert + , assert' , assertThrows , assertThrows' - , ASSERT() ) where -import Control.Monad.Eff (Eff()) -import Prelude +import Control.Monad.Eff (Eff) +import Control.Monad ((=<<)) +import Data.Unit (Unit) -- | Assertion effect type. foreign import data ASSERT :: ! @@ -19,7 +20,11 @@ assert = assert' "Assertion failed" -- | Throws a runtime exception with the specified message when the boolean -- | value is false. -foreign import assert' :: forall e. String -> Boolean -> Eff (assert :: ASSERT | e) Unit +foreign import assert' + :: forall e + . String + -> Boolean + -> Eff (assert :: ASSERT | e) Unit -- | Throws a runtime exception with message "Assertion failed: An error should -- | have been thrown", unless the argument throws an exception when evaluated. @@ -29,7 +34,8 @@ foreign import assert' :: forall e. String -> Boolean -> Eff (assert :: ASSERT | -- | satisfied. Functions which use `Eff (err :: EXCEPTION | eff) a` can be -- | tested with `catchException` instead. assertThrows :: forall e a. (Unit -> a) -> Eff (assert :: ASSERT | e) Unit -assertThrows = assertThrows' "Assertion failed: An error should have been thrown" +assertThrows = + assertThrows' "Assertion failed: An error should have been thrown" -- | Throws a runtime exception with the specified message, unless the argument -- | throws an exception when evaluated. @@ -38,9 +44,14 @@ assertThrows = assertThrows' "Assertion failed: An error should have been thrown -- | to make sure that an exception is thrown if a precondition is not -- | satisfied. Functions which use `Eff (err :: EXCEPTION | eff) a` can be -- | tested with `catchException` instead. -assertThrows' :: forall e a. String -> (Unit -> a) -> Eff (assert :: ASSERT | e) Unit -assertThrows' msg fn = - checkThrows fn >>= assert' msg - - -foreign import checkThrows :: forall e a. (Unit -> a) -> Eff (assert :: ASSERT | e) Boolean +assertThrows' + :: forall e a + . String + -> (Unit -> a) + -> Eff (assert :: ASSERT | e) Unit +assertThrows' msg fn = assert' msg =<< checkThrows fn + +foreign import checkThrows + :: forall e a + . (Unit -> a) + -> Eff (assert :: ASSERT | e) Boolean