Skip to content
Browse files

add includes, bump version 2.2.0

  • Loading branch information...
1 parent bf50663 commit bf012836ef48eb23e00cdb1a30d67de81cd2ab35 @dominictarr committed Nov 6, 2011
Showing with 50 additions and 7 deletions.
  1. +7 −0 "false"
  2. +22 −0 LICENCE
  3. +6 −1 extended.js
  4. +1 −1 failure.js
  5. +4 −0 nocomma_obj.json
  6. +1 −1 package.json
  7. +4 −0 test/assert.expresso.js
  8. +5 −4 test/failures.synct.js
View
7 "false"
@@ -0,0 +1,7 @@
+HTTP/1.1 400 Bad Request
+Server: CouchDB/1.1.1 (Erlang OTP/R14B04)
+Date: Sun, 06 Nov 2011 05:17:52 GMT
+Content-Type: text/plain;charset=utf-8
+Content-Length: 65
+Cache-Control: must-revalidate
+
View
22 LICENCE
@@ -0,0 +1,22 @@
+Copyright (c) 2011 Dominic Tarr
+
+Permission is hereby granted, free of charge,
+to any person obtaining a copy of this software and
+associated documentation files (the "Software"), to
+deal in the Software without restriction, including
+without limitation the rights to use, copy, modify,
+merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom
+the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice
+shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
+OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
+TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
+SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
7 extended.js
@@ -24,7 +24,7 @@ exports = module.exports = {
if(!('function' == typeof actual || 'object' == typeof actual ))
throw fail(new Error()).explain('complex: {actual:render} must be a function or an object', {actual: actual}, message)
}
-, isFunction: function (actual,message){
+, isFunction: function (actual, message){
if(!('function' == typeof actual))
throw fail(new Error()).explain('isFunction: "function" == typeof {actual:render}', {actual: actual}, message)
}
@@ -99,6 +99,11 @@ exports = module.exports = {
if(-1 === i)
throw fail(new Error()).simple('contains', actual, expected, 'contains', message)
}
+, includes: function (actual, expected, message) {
+ var i = expected.indexOf(actual)
+ if(-1 === i)
+ throw fail(new Error()).simple('includes', actual, expected, 'includes', message)
+ }
, isString: function (actual, message) {
exports.isTypeof(actual, 'string', message)
}
View
2 failure.js
@@ -60,7 +60,7 @@ function renderPath(path){
return path.map(function (e){
if(!isNaN(e))
return '[' + e + ']'
- if(/^\w+$/(e))
+ if(/^\w+$/.test(e))
return '.' + e
return '[' + JSON.stringify(e) + ']'
}).join('')
View
4 nocomma_obj.json
@@ -0,0 +1,4 @@
+{
+ "hello": "comma!"
+ "hello": "no comma"
+}
View
2 package.json
@@ -2,7 +2,7 @@
"author": "Dominic Tarr <dominic.tarr@gmail.com> (http://bit.ly/dominictarr)",
"name": "assertions",
"description": "loads of useful assert functions in one package",
- "version": "2.1.1",
+ "version": "2.2.0",
"homepage": "https://github.com/dominictarr/assertions",
"repository": {
"type": "git",
View
4 test/assert.expresso.js
@@ -138,6 +138,10 @@ var examples =
pass: [ [[1,2,3], 1], [[1,2,3], 2], [['a', 'b', 'c'], 'c'], ['hello there' , 'hell']]
, fail: [ [[], 1], ['euthoeu', 'x'] ]
}
+, includes: {
+ pass: [ [2, [1,2,3]], [3, [1,2,3]], ['c', ['a', 'b', 'c']], ['the', 'hello there']]
+ , fail: [ [1, []], ['x', 'euthoeu'] ]
+ }
, isArray: {
pass: [ [[]] ]
, fail: [ [{}], ['euthoeu'], [/ouoeu/], [42], [null], [true] ]
View
9 test/failures.synct.js
@@ -57,21 +57,22 @@ exports ['pass it a primitive'] = function () {
}
-exports [ 'integrate AssernionErrors (keep messages)'] = function () {
+exports [ 'integrate AssertionErrors (keep messages)'] = function () {
var err = (function () { try { assert.ok(false, 'message is here') } catch (err) {return err} } )()
var f = failure.fail(err)
assert.equal(typeof f.explain, 'function')
- assert.ok(~f.stack.indexOf('false == true'), 'should still have any preexisting error message')
+ assert.ok(~f.stack.indexOf('false must == true'), 'should still have any preexisting error message')
assert.ok(~f.stack.indexOf('message is here'), 'should still have any preexisting error message')
}
-exports [ 'integrate AssernionErrors add second explaination'] = function () {
+exports [ 'integrate AssertionErrors add second explaination'] = function () {
var err = (function () { try { assert.ok(false, 'message is here') } catch (err) {return err} } )()
var f = failure.fail(err).explain('adding another message!', {}, 'more message')
+ console.error(f.stack)
assert.equal(typeof f.explain, 'function')
- assert.ok(~f.stack.indexOf('false == true'), 'should still have any preexisting error message')
+ assert.ok(~f.stack.indexOf('false must == true'), 'should still have any preexisting error message')
assert.ok(~f.stack.indexOf('message is here'), 'should still have any preexisting error message')
assert.ok(~f.stack.indexOf('adding another message!'), 'should have 2nd message: "adding another message!"')
assert.ok(~f.stack.indexOf('more message'), 'should have 2nd message: "more message"')

0 comments on commit bf01283

Please sign in to comment.
Something went wrong with that request. Please try again.