mirror of
				https://github.com/flynx/object.js.git
				synced 2025-10-30 02:50:10 +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
 | * 	https://github.com/flynx/object.js
 | ||||||
| * | * | ||||||
| * | * | ||||||
| **********************************************************************/ | ***********************************************/ /* c8 ignore next 2 */ | ||||||
| ((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define) | ((typeof define)[0]=='u'?function(f){module.exports=f(require)}:define) | ||||||
| (function(require){ var module={} // make module AMD/node compatible...
 | (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...
 | // 		framework so as to be able to use them on more setups...
 | ||||||
| var cases = | var cases = | ||||||
| module.cases = { | module.cases = { | ||||||
| 	'example': function(assert){ | 	'edge-cases': function(assert){ | ||||||
| 		assert(true, 'example.') | 		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) | 		console.assert(value, this.strPath.bold +': '+ msg.bold.yellow, ...args) | ||||||
| 
 | 
 | ||||||
| 		return value }, | 		return value }, | ||||||
| 	assert: function(msg, test){ | 	istrue: function(msg, test){ | ||||||
| 		try { | 		try { | ||||||
| 			return this(test.call(this), msg) | 			return this(test.call(this), msg) | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user