mirror of
				https://github.com/tc39/test262.git
				synced 2025-10-31 19:53:50 +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)
		
			
				
	
	
		
			68 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
			
		
		
	
	
			68 lines
		
	
	
		
			2.0 KiB
		
	
	
	
		
			JavaScript
		
	
	
	
	
	
| "use strict";
 | |
| 
 | |
| var shadowChickenFunctionsOnStack = $vm.shadowChickenFunctionsOnStack;
 | |
| 
 | |
| function describeFunction(f)
 | |
| {
 | |
|     var name;
 | |
|     try {
 | |
|         name = f.name;
 | |
|     } catch (e) {}
 | |
|     if (!name)
 | |
|         name = "<" + describe(f) + ">";
 | |
|     return name;
 | |
| }
 | |
| 
 | |
| function describeArray(array) {
 | |
|     var result = "[";
 | |
|     for (var i = 0; i < array.length; ++i) {
 | |
|         if (i)
 | |
|             result += ", ";
 | |
|         result += describeFunction(array[i]);
 | |
|     }
 | |
|     return result + "]";
 | |
| }
 | |
| 
 | |
| function compareStacks(stack, array) {
 | |
|     if (stack.length != array.length)
 | |
|         throw new Error("Bad stack length: " + describeArray(stack) + " (expected " + describeArray(array) + ")");
 | |
|     for (var i = 0; i < stack.length; ++i) {
 | |
|         if (stack[i] != array[i])
 | |
|             throw new Error("Bad stack at i = " + i + ": " + describeArray(stack) + " (expected " + describeArray(array) + ")");
 | |
|     }
 | |
| }
 | |
| 
 | |
| function expectStack(array) {
 | |
|     var stack = shadowChickenFunctionsOnStack();
 | |
|     if (verbose)
 | |
|         print("stack = " + describeArray(stack));
 | |
|     var myTop = stack.pop();
 | |
|     if (myTop != stackTop)
 | |
|         throw new Error("Bad stack top: " + myTop);
 | |
|     var myBottom = stack.shift();
 | |
|     if (myBottom != shadowChickenFunctionsOnStack)
 | |
|         throw new Error("Bad stack bottom: " + myBottom);
 | |
|     myBottom = stack.shift();
 | |
|     if (myBottom != expectStack)
 | |
|         throw new Error("Bad stack next-to-bottom: " + myBottom);
 | |
|     compareStacks(stack, array);
 | |
| }
 | |
| 
 | |
| var initialShadow;
 | |
| var stackTop;
 | |
| 
 | |
| function initialize()
 | |
| {
 | |
|     initialShadow = shadowChickenFunctionsOnStack();
 | |
|     if (initialShadow.length != 3)
 | |
|         throw new Error("bad initial shadow length: " + initialShadow.length);
 | |
|     if (initialShadow[0] != shadowChickenFunctionsOnStack)
 | |
|         throw new Error("bad top of stack: " + describeFunction(initialShadow[0]));
 | |
|     if (initialShadow[1] != initialize)
 | |
|         throw new Error("bad middle of stack: " + describeFunction(initialShadow[1]));
 | |
|     stackTop = initialShadow[2];
 | |
|     
 | |
|     expectStack([initialize]);
 | |
| }
 | |
| 
 |