mirror of
				https://github.com/tc39/test262.git
				synced 2025-10-31 11:44:31 +01:00 
			
		
		
		
	
		
			
				
	
	
		
			27 lines
		
	
	
		
			1000 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			27 lines
		
	
	
		
			1000 B
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| function shouldBe(actual, expected) {
 | |
|     if (actual !== expected)
 | |
|         throw new Error('bad value: ' + actual);
 | |
| }
 | |
| noInline(shouldBe);
 | |
| 
 | |
| var isUndefinedOrNull = $vm.createBuiltin(`(function (value) { return @isUndefinedOrNull(value); })`);
 | |
| noInline(isUndefinedOrNull);
 | |
| 
 | |
| var masquerader = makeMasquerader();
 | |
| for (var i = 0; i < 1e5; ++i) {
 | |
|     shouldBe(isUndefinedOrNull(null), true);
 | |
|     shouldBe(isUndefinedOrNull(undefined), true);
 | |
|     shouldBe(isUndefinedOrNull("Hello"), false);
 | |
|     shouldBe(isUndefinedOrNull(Symbol("Hello")), false);
 | |
|     shouldBe(isUndefinedOrNull(42), false);
 | |
|     shouldBe(isUndefinedOrNull(-42), false);
 | |
|     shouldBe(isUndefinedOrNull(0), false);
 | |
|     shouldBe(isUndefinedOrNull(-0), false);
 | |
|     shouldBe(isUndefinedOrNull(42.2), false);
 | |
|     shouldBe(isUndefinedOrNull(-42.2), false);
 | |
|     shouldBe(isUndefinedOrNull({}), false);
 | |
|     shouldBe(isUndefinedOrNull([]), false);
 | |
|     shouldBe(isUndefinedOrNull(true), false);
 | |
|     shouldBe(isUndefinedOrNull(masquerader), false);
 | |
| }
 |