[webkit-changes] cvs commit: WebCore/layout-tests/fast/js named-function-expression-expected.txt named-function-expression.html

Geoffrey ggaren at opensource.apple.com
Wed Aug 31 11:37:02 PDT 2005


ggaren      05/08/31 11:37:02

  Modified:    .        ChangeLog
  Added:       layout-tests/fast/js named-function-expression-expected.txt
                        named-function-expression.html
  Log:
          -rolled in layout test for http://bugzilla.opendarwin.org/show_bug.cgi?id=4698
          kjs does not allow named functions in function expressions
  
          Test cases added:
  
          * layout-tests/fast/js/named-function-expression-expected.txt: Added.
          * layout-tests/fast/js/named-function-expression.html: Added.
  
  Revision  Changes    Path
  1.56      +10 -0     WebCore/ChangeLog
  
  Index: ChangeLog
  ===================================================================
  RCS file: /cvs/root/WebCore/ChangeLog,v
  retrieving revision 1.55
  retrieving revision 1.56
  diff -u -r1.55 -r1.56
  --- ChangeLog	31 Aug 2005 15:36:11 -0000	1.55
  +++ ChangeLog	31 Aug 2005 18:37:01 -0000	1.56
  @@ -1,3 +1,13 @@
  +2005-08-31  Geoffrey Garen  <ggaren at apple.com>
  +
  +        -rolled in layout test for http://bugzilla.opendarwin.org/show_bug.cgi?id=4698
  +        kjs does not allow named functions in function expressions
  +        
  +        Test cases added:
  +
  +        * layout-tests/fast/js/named-function-expression-expected.txt: Added.
  +        * layout-tests/fast/js/named-function-expression.html: Added.
  +
   2005-08-31  Darin Adler  <darin at apple.com>
   
           Reviewed by Maciej.
  
  
  
  1.1                  WebCore/layout-tests/fast/js/named-function-expression-expected.txt
  
  Index: named-function-expression-expected.txt
  ===================================================================
  Bug 4698 - kjs does not allow named functions in function expressions
  You should see 7 lines with OK in them below this line.
  OK
  OK
  OK
  OK
  OK
  OK
  OK
  
  
  
  
  1.1                  WebCore/layout-tests/fast/js/named-function-expression.html
  
  Index: named-function-expression.html
  ===================================================================
  <html>
  <body>
  Bug 4698 - kjs does not allow named functions in function expressions<br>
  You should see 7 lines with OK in them below this line.<br>
  <script type="text/javascript">
  if (window.layoutTestController) {
  	layoutTestController.dumpAsText();
  }
  
  function Test(lambda, expect) {
  	try {
  		var v = lambda();
  		if(v == expect)
  			document.write("OK<br>");
  		else
  			document.write("NOT OK: " + v + " != " + expect + "<br>");
  	}
  	catch(e) { document.write("ERROR: " + e + "<br>"); }
  }
  
  Test(function(){
  	// anonymous function expression
  	var x = (function(a,b){ return a + b; });
  	return x(1,2);
  }, 3);
  
  Test(function(){
  	// named function expression
  	var x = (function Named(a,b){ return a + b; });
  	return x(2,3);
  }, 5);
  
  Test(function(){
  	// eval'd code should be able to access scoped variables
  	var z = 6;
  	var x = eval("(function(a,b){ return a + b + z; })");
  	return x(3,4);
  }, 13);
  
  Test(function(){
  	// eval'd code + self-check
  	var z = 10;
  	var x = eval("(function Named(a,b){ return (!!Named) ? (a + b + z) : -999; })");
  	return x(4,5);
  }, 19);
  
  Test(function(){
  	// named function expressions are not saved in the current context
  	(function Foo(){ return 1; });
  	try { Foo(); throw "FuncExpr was stored"; } catch(e) { if(typeof(e)=="string") throw e; }
  	return 1;
  }, 1);
  
  Test(function(){
  	// recursion is possible, though
  	var ctr = 3;
  	var x = (function Named(a,b){ if(--ctr) return 2 * Named(a,b); else return a + b; });
  	return x(5,6);
  }, 44);
  
  Test(function(){
  	// regression test where kjs regarded an anonymous function declaration (which is illegal)
  	// as a FunctionExpr
  	try {
  		eval("function(){ return 2; };");
  		return 0;
  	} catch(e) { return 1; /* should bomb */ }
  }, 1);
  </script>
  </body>
  </html>
  
  



More information about the webkit-changes mailing list