mirror of
				https://github.com/tc39/test262.git
				synced 2025-10-30 19:24:12 +01:00 
			
		
		
		
	* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
		
			
				
	
	
		
			41 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			41 lines
		
	
	
		
			1.1 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| function shouldBe(expected, actual, msg = "") {
 | |
|     if (msg)
 | |
|         msg = " for " + msg;
 | |
|     if (actual !== expected)
 | |
|         throw new Error("bad value" + msg + ": " + actual + ". Expected " + expected);
 | |
| }
 | |
| function shouldBeAsync(expected, promise, msg) {
 | |
|     let actual;
 | |
|     var hadError = false;
 | |
|     promise.then(function(value) { actual = value; },
 | |
|                  function(error) { hadError = true; actual = error; });
 | |
|     drainMicrotasks();
 | |
| 
 | |
|     if (hadError)
 | |
|         throw actual;
 | |
| 
 | |
|     shouldBe(expected, actual, msg);
 | |
| }
 | |
| 
 | |
| var AsyncFunctionPrototype = async function(){}.__proto__;
 | |
| 
 | |
| function sink (p, q) {
 | |
|     var g = async function (x) { return x; };
 | |
|     if (p) { if (q) OSRExit(); return g; }
 | |
|     return async function (x) { return x; };
 | |
| }
 | |
| noInline(sink);
 | |
| 
 | |
| for (var i = 0; i < 10000; ++i) {
 | |
|     var f = sink(true, false);
 | |
|     shouldBe(f.__proto__, AsyncFunctionPrototype);
 | |
|     shouldBeAsync(42, f(42));
 | |
| }
 | |
| 
 | |
| // At this point, the function should be compiled down to the FTL
 | |
| 
 | |
| // Check that the function is properly allocated on OSR exit
 | |
| var f = sink(true, true);
 | |
| shouldBe(f.__proto__, AsyncFunctionPrototype);
 | |
| shouldBeAsync(42, f(42));
 |