mirror of
https://github.com/flynx/object.js.git
synced 2025-10-29 02:20:08 +00:00
added a set of unit tests for edge cases...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
parent
da4eef8764
commit
65dd469702
@ -16,7 +16,7 @@
|
||||
* https://github.com/flynx/object.js
|
||||
*
|
||||
*
|
||||
**********************************************************************/
|
||||
***********************************************/ /* c8 ignore next 2 */
|
||||
((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define)
|
||||
(function(require){ var module={} // make module AMD/node compatible...
|
||||
/*********************************************************************/
|
||||
|
||||
20
test.js
20
test.js
@ -768,8 +768,22 @@ module.tests = {
|
||||
// framework so as to be able to use them on more setups...
|
||||
var cases =
|
||||
module.cases = {
|
||||
'example': function(assert){
|
||||
assert(true, 'example.')
|
||||
'edge-cases': function(assert){
|
||||
var x, y
|
||||
|
||||
// object.match(..)
|
||||
assert(object.match(x = {a: 123, b: '333', c: []}, x) === true, 'match self')
|
||||
assert(object.match(x, {a: x.a, b: x.b, c: []}) == false, 'strict mismatch')
|
||||
assert(object.match(x, {a: 123, b: 333, c: x.c}, true) === true, 'non-strict match')
|
||||
|
||||
// object.matchPartial(..)
|
||||
assert(object.matchPartial(x, {a: x.a}, true) === true, 'non-strict partial match')
|
||||
assert(object.matchPartial(x, {a: x.a, b: x.b, c: x.c}) === true, 'strict partial match')
|
||||
|
||||
// object.parent(..)
|
||||
assert(object.parent({}) === {}.__proto__, 'basic proto')
|
||||
assert.error('.parent(..) of anonymous function', function(){
|
||||
object.parent(function(){}, {}) })
|
||||
},
|
||||
}
|
||||
|
||||
@ -860,7 +874,7 @@ object.Constructor('Assert', {
|
||||
console.assert(value, this.strPath.bold +': '+ msg.bold.yellow, ...args)
|
||||
|
||||
return value },
|
||||
assert: function(msg, test){
|
||||
istrue: function(msg, test){
|
||||
try {
|
||||
return this(test.call(this), msg)
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user