[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Gnash-commit] gnash/testsuite/actionscript.all Function.as
From: |
Zou Lunkai |
Subject: |
[Gnash-commit] gnash/testsuite/actionscript.all Function.as |
Date: |
Thu, 27 Dec 2007 02:42:17 +0000 |
CVSROOT: /sources/gnash
Module name: gnash
Changes by: Zou Lunkai <zoulunkai> 07/12/27 02:42:17
Modified files:
testsuite/actionscript.all: Function.as
Log message:
add tests for arguments object, detected new failures.
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/gnash/testsuite/actionscript.all/Function.as?cvsroot=gnash&r1=1.62&r2=1.63
Patches:
Index: Function.as
===================================================================
RCS file: /sources/gnash/gnash/testsuite/actionscript.all/Function.as,v
retrieving revision 1.62
retrieving revision 1.63
diff -u -b -r1.62 -r1.63
--- Function.as 12 Dec 2007 07:30:12 -0000 1.62
+++ Function.as 27 Dec 2007 02:42:16 -0000 1.63
@@ -21,7 +21,7 @@
// compile this test case with Ming makeswf, and then
// execute it like this gnash -1 -r 0 -v out.swf
-rcsid="$Id: Function.as,v 1.62 2007/12/12 07:30:12 zoulunkai Exp $";
+rcsid="$Id: Function.as,v 1.63 2007/12/27 02:42:16 zoulunkai Exp $";
#include "check.as"
@@ -397,14 +397,64 @@
// Test the 'arguments' object
//----------------------------------------------------------
-// this is to be called argsChecker(1,2,3)
-function argsChecker(a, b, c, d, e, f, g)
+function f()
{
check_equals(typeof(arguments), 'object');
check(arguments instanceOf Array);
check(arguments instanceOf Object);
+ check_equals(arguments.length, 0);
+
check_equals(typeof(arguments.callee), 'function');
- check_equals(arguments.callee, argsChecker);
+ // callee: the function being called
+ check_equals(arguments.callee, _root.f);
+ // caller: the caller function
+ xcheck_equals(typeof(arguments.caller), 'null'); //? typeof return 'null',
seems new!
+ check_equals(arguments.caller, null);
+
+ var a = arguments;
+ var propRecorder = new Array();
+ for(var props in a)
+ {
+ propRecorder.push(props.toString());
+ }
+ // no enumerable properties in default mode.
+ xcheck_equals(propRecorder.length, 0); //? shouldn't fail here
+
+ ASSetPropFlags(a, null, 6, 1 );
+ for(var props in a)
+ {
+ propRecorder.push(props.toString());
+ }
+ propRecorder.sort();
+ check_equals(propRecorder.length, 5);
+ check_equals(propRecorder[0], '__proto__');
+ check_equals(propRecorder[1], 'callee');
+ xcheck_equals(propRecorder[2], 'caller');
+ xcheck_equals(propRecorder[3], 'constructor');
+ xcheck_equals(propRecorder[4], 'length');
+}
+f();
+
+// test argument.caller
+function child_func()
+{
+#if OUTPUT_VERSION == 5
+ check_equals(arguments.caller, parent_func);
+#else
+ //? passed on swf5, but failed on swf6,7,8
+ xcheck_equals(arguments.caller, parent_func);
+#endif
+}
+function parent_func()
+{
+ child_func();
+}
+parent_func();
+
+
+// this is to be called argsChecker(1,2,3)
+function argsChecker(a, b, c, d, e, f, g)
+{
check_equals(arguments.length, 3);
check_equals(arguments[0], 1);
check_equals(arguments[1], 2);
@@ -435,7 +485,7 @@
check_equals(argsCounter([a,b]), 1);
function factorial(n) {
- return n <= 1 ? n : n*factorial(n-1);
+ return n <= 1 ? n : n*arguments.callee(n-1);
}
check_equals(factorial(3), 6);
check_equals(factorial(4), 24);