-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
packages update, fix PR #29, some cleaning
- Loading branch information
Showing
75 changed files
with
9,240 additions
and
2,087 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* This file is part of the Unit.js testing framework. | ||
* | ||
* (c) Nicolas Tallefourtane <dev@nicolab.net> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file distributed with this source code | ||
* or visit http://unitjs.com. | ||
* | ||
* @author Nicolas Tallefourtane <dev@nicolab.net> | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var Noder = require('noder.io').Noder; | ||
|
||
/** | ||
* @constructor | ||
*/ | ||
function UnitJS() { | ||
Noder.call(this); | ||
} | ||
|
||
UnitJS.prototype = Object.create(Noder.prototype, { | ||
constructor: { value: UnitJS } | ||
}); | ||
|
||
UnitJS.prototype.UnitJS = UnitJS; | ||
|
||
module.exports = new UnitJS(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
/** | ||
* This file is part of the Unit.js testing framework. | ||
* | ||
* (c) Nicolas Tallefourtane <dev@nicolab.net> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file distributed with this source code | ||
* or visit http://unitjs.com. | ||
* | ||
* @author Nicolas Tallefourtane <dev@nicolab.net> | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var nativeAssert = require('assert'); | ||
var stats = require('./helpers').stats; | ||
var methods = [ | ||
'ok', 'fail', 'equal', 'notEqual', 'deepEqual', 'notDeepEqual', 'strictEqual', | ||
'notStrictEqual', 'throws', 'doesNotThrow', 'ifError' | ||
]; | ||
|
||
function countAssertion(assertion) { | ||
assertion = assertion ? 'assert.' + assertion : 'assert'; | ||
|
||
if (typeof stats.assertions[assertion] == 'undefined') { | ||
stats.assertions[assertion] = 0; | ||
} | ||
|
||
stats.assertions[assertion]++; | ||
stats.total.assertions++; | ||
} | ||
|
||
function assert(value, message) { | ||
countAssertion(); | ||
return nativeAssert(value, message); | ||
} | ||
|
||
|
||
methods.forEach(function(method) { | ||
assert[method] = function() { | ||
countAssertion(method); | ||
return nativeAssert[method].apply(assert, arguments); | ||
}; | ||
}); | ||
|
||
module.exports = assert; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
/** | ||
* This file is part of the Unit.js testing framework. | ||
* | ||
* (c) Nicolas Tallefourtane <dev@nicolab.net> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file distributed with this source code | ||
* or visit http://unitjs.com. | ||
* | ||
* @author Nicolas Tallefourtane <dev@nicolab.net> | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// asserters are added below | ||
module.exports.array = function(actual) { var Asserter = require('./asserters/array'); return new Asserter(actual); }; | ||
module.exports.bool = function(actual) { var Asserter = require('./asserters/bool'); return new Asserter(actual); }; | ||
module.exports.date = function(actual) { var Asserter = require('./asserters/date'); return new Asserter(actual); }; | ||
module.exports.error = function(actual) { var Asserter = require('./asserters/error'); return new Asserter(actual); }; | ||
module.exports.exception = function(actual) { var Asserter = require('./asserters/exception'); return new Asserter(actual); }; | ||
module.exports.function = function(actual) { var Asserter = require('./asserters/function'); return new Asserter(actual); }; | ||
module.exports.number = function(actual) { var Asserter = require('./asserters/number'); return new Asserter(actual); }; | ||
module.exports.object = function(actual) { var Asserter = require('./asserters/object'); return new Asserter(actual); }; | ||
module.exports.regexp = function(actual) { var Asserter = require('./asserters/regexp'); return new Asserter(actual); }; | ||
module.exports.string = function(actual) { var Asserter = require('./asserters/string'); return new Asserter(actual); }; | ||
module.exports.undefined = function(actual) { var Asserter = require('./asserters/undefined'); return new Asserter(actual); }; | ||
module.exports.value = function(actual) { var Asserter = require('./asserters/value'); return new Asserter(actual); }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/** | ||
* This file is part of the Unit.js testing framework. | ||
* | ||
* (c) Nicolas Tallefourtane <dev@nicolab.net> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file distributed with this source code | ||
* or visit http://unitjs.com. | ||
* | ||
* @author Nicolas Tallefourtane <dev@nicolab.net> | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var _ = require('lodash'); | ||
|
||
// constructor | ||
var RawControlFlow = require('../control-flow'); | ||
|
||
// object | ||
var rawAssertions = require('../assertions'); | ||
|
||
// array | ||
var commonAssertions = require('../common-assertions'); | ||
|
||
// list the assertions to the current asserter (specific and common) | ||
var useAssertions = commonAssertions.concat([ | ||
|
||
// matchers | ||
'matchEach', 'notMatchEach', | ||
|
||
// types augmented | ||
'isEmpty', 'isNotEmpty', | ||
|
||
// quantifications | ||
'hasLength', 'hasNotLength', | ||
|
||
// containers | ||
'hasValue', 'notHasValue', 'hasValues', 'notHasValues', | ||
'contains', 'notContains', 'isReverseOf', 'isNotReverseOf', | ||
'isEnumerable', 'isNotEnumerable', 'hasKey', 'notHasKey', | ||
'hasProperty', 'hasNotProperty' | ||
]); | ||
|
||
/** | ||
* Expose all assertions | ||
* @type {function} | ||
* @param {mixed} actual Actual value tested | ||
* @return {Object} The current asserter | ||
*/ | ||
module.exports = function ArrayAsserter(actual) { | ||
|
||
// actual value tested | ||
this.actual = actual; | ||
|
||
// assertions with the current context | ||
var assertions = rawAssertions.call(this, actual); | ||
|
||
// Build the common API with the current context | ||
var ControlFlow = RawControlFlow.bind(this); | ||
var commonApi = new ControlFlow(); | ||
|
||
// provides the common API in the current asserter | ||
for (var method in commonApi) { | ||
this[method] = commonApi[method]; | ||
} | ||
|
||
// assert the type | ||
assertions.isArray(this.actual); | ||
|
||
// provides the assertions to the current asserter (specific and common) | ||
var asserterAssertions = _.pick(assertions, useAssertions); | ||
|
||
for (var method in asserterAssertions) { | ||
this[method] = asserterAssertions[method]; | ||
} | ||
|
||
// return this asserter | ||
return this; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/** | ||
* This file is part of the Unit.js testing framework. | ||
* | ||
* (c) Nicolas Tallefourtane <dev@nicolab.net> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file distributed with this source code | ||
* or visit http://unitjs.com. | ||
* | ||
* @author Nicolas Tallefourtane <dev@nicolab.net> | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var _ = require('lodash'); | ||
|
||
// constructor | ||
var RawControlFlow = require('../control-flow'); | ||
|
||
// object | ||
var rawAssertions = require('../assertions'); | ||
|
||
/** | ||
* Expose all assertions | ||
* @type {function} | ||
* @param {mixed} actual Actual value tested | ||
* @return {Object} The current asserter | ||
*/ | ||
module.exports = function BoolAsserter(actual) { | ||
|
||
// actual value tested | ||
this.actual = actual; | ||
|
||
// assertions with the current context | ||
var assertions = rawAssertions.call(this, actual); | ||
|
||
// Build the common API with the current context | ||
var ControlFlow = RawControlFlow.bind(this); | ||
var commonApi = new ControlFlow(); | ||
|
||
// provides the common API in the current asserter | ||
for (var method in commonApi) { | ||
this[method] = commonApi[method]; | ||
} | ||
|
||
// assert the type | ||
assertions.isBool(this.actual); | ||
|
||
// provides the assertions to the current asserter | ||
var useAssertions = ['isTrue', 'isNotTrue', 'isFalse', 'isNotFalse']; | ||
var asserterAssertions = _.pick(assertions, useAssertions); | ||
|
||
for (var method in asserterAssertions) { | ||
this[method] = asserterAssertions[method]; | ||
} | ||
|
||
// return this asserter | ||
return this; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/** | ||
* This file is part of the Unit.js testing framework. | ||
* | ||
* (c) Nicolas Tallefourtane <dev@nicolab.net> | ||
* | ||
* For the full copyright and license information, please view | ||
* the LICENSE file distributed with this source code | ||
* or visit http://unitjs.com. | ||
* | ||
* @author Nicolas Tallefourtane <dev@nicolab.net> | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var _ = require('lodash'); | ||
|
||
// constructor | ||
var RawControlFlow = require('../control-flow'); | ||
|
||
// object | ||
var rawAssertions = require('../assertions'); | ||
|
||
// array | ||
var commonAssertions = require('../common-assertions'); | ||
|
||
var useAssertions = commonAssertions.concat([ | ||
|
||
// quantifications | ||
'isBetween', 'isNotBetween', 'isBefore', 'isAfter' | ||
]); | ||
|
||
/** | ||
* Expose all assertions | ||
* @type {function} | ||
* @param {mixed} actual Actual value tested | ||
* @return {Object} The current asserter | ||
*/ | ||
module.exports = function DateAsserter(actual) { | ||
|
||
// actual value tested | ||
this.actual = actual; | ||
|
||
// assertions with the current context | ||
var assertions = rawAssertions.call(this, actual); | ||
|
||
// Build the common API with the current context | ||
var ControlFlow = RawControlFlow.bind(this); | ||
var commonApi = new ControlFlow(); | ||
|
||
// provides the common API in the current asserter | ||
for (var method in commonApi) { | ||
this[method] = commonApi[method]; | ||
} | ||
|
||
// assert the type | ||
assertions.isDate(); | ||
|
||
// provides the assertions to the current asserter (specific and common) | ||
var asserterAssertions = _.pick(assertions, useAssertions); | ||
|
||
for (var method in asserterAssertions) { | ||
this[method] = asserterAssertions[method]; | ||
} | ||
|
||
// return this asserter | ||
return this; | ||
}; |
Oops, something went wrong.