mirror of
				https://github.com/flynx/object.js.git
				synced 2025-10-30 19:10:11 +00:00 
			
		
		
		
	more minor tweaks and notes...
Signed-off-by: Alex A. Naanou <alex.nanou@gmail.com>
This commit is contained in:
		
							parent
							
								
									dfe69bbb1f
								
							
						
					
					
						commit
						f4b3df077e
					
				
							
								
								
									
										15
									
								
								test.js
									
									
									
									
									
								
							
							
						
						
									
										15
									
								
								test.js
									
									
									
									
									
								
							| @ -30,19 +30,22 @@ module.VERBOSE = process ? | |||||||
| //---------------------------------------------------------------------
 | //---------------------------------------------------------------------
 | ||||||
| // helpers...
 | // helpers...
 | ||||||
| 
 | 
 | ||||||
|  | // a constructor is a thing that starts with a capital and has a .prototype
 | ||||||
| var constructors = function(obj){ | var constructors = function(obj){ | ||||||
| 	return Object.entries(obj) | 	return Object.entries(obj) | ||||||
| 		.filter(function([k, o]){ | 		.filter(function([k, o]){ | ||||||
| 			return k[0] == k[0].toUpperCase() && o.prototype }) } | 			return k[0] == k[0].toUpperCase()  | ||||||
| 
 | 				&& o.prototype }) } | ||||||
| 
 | 
 | ||||||
|  | // an instance is a thing that starts with a lowercase and has a .constructor
 | ||||||
| var instances = function(obj){ | var instances = function(obj){ | ||||||
| 	return Object.entries(obj) | 	return Object.entries(obj) | ||||||
| 		.filter(function([k, o]){ | 		.filter(function([k, o]){ | ||||||
| 			return k[0] == k[0].toLowerCase() && o.constructor }) } | 			return k[0] == k[0].toLowerCase()  | ||||||
|  | 				&& o.constructor }) } | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| var assert = function(pre, stats){ | var makeAssert = function(pre, stats){ | ||||||
| 	return function(e, msg, ...args){ | 	return function(e, msg, ...args){ | ||||||
| 		stats | 		stats | ||||||
| 			&& (stats.assertions += 1) | 			&& (stats.assertions += 1) | ||||||
| @ -244,7 +247,7 @@ var runner = function(){ | |||||||
| 								return } | 								return } | ||||||
| 							// run the test...
 | 							// run the test...
 | ||||||
| 							stats.tests += 1 | 							stats.tests += 1 | ||||||
| 							var _assert = assert(`test:${t}.${s}.${m}`, stats) | 							var _assert = makeAssert(`test:${t}.${s}.${m}`, stats) | ||||||
| 							tests[t](_assert,  | 							tests[t](_assert,  | ||||||
| 								modifiers[m](_assert,  | 								modifiers[m](_assert,  | ||||||
| 									setups[s](_assert))) }) }) })  | 									setups[s](_assert))) }) }) })  | ||||||
| @ -252,7 +255,7 @@ var runner = function(){ | |||||||
| 	Object.keys(cases) | 	Object.keys(cases) | ||||||
| 		.forEach(function(c){ | 		.forEach(function(c){ | ||||||
| 			stats.tests += 1 | 			stats.tests += 1 | ||||||
| 			cases[c]( assert(`case:${c}:`, stats) ) })  | 			cases[c]( makeAssert(`case:${c}:`, stats) ) })  | ||||||
| 
 | 
 | ||||||
| 	// stats...
 | 	// stats...
 | ||||||
| 	console.log('Tests:', stats.tests,  | 	console.log('Tests:', stats.tests,  | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user