Add automated tests on function-type FSCommand parameter passing.
[gnash.git] / testsuite / actionscript.all / argstest.as
blob7d67a9fb08e892f3f01c7d239e08e6a59ed5e500
1 //
2 // Copyright (C) 2005, 2006, 2007, 2009, 2010 Free Software
3 // Foundation, Inc
4 //
5 // This program is free software; you can redistribute it and/or modify
6 // it under the terms of the GNU General Public License as published by
7 // the Free Software Foundation; either version 3 of the License, or
8 // (at your option) any later version.
9 //
10 // This program is distributed in the hope that it will be useful,
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 // GNU General Public License for more details.
15 // You should have received a copy of the GNU General Public License
16 // along with this program; if not, write to the Free Software
17 // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
21 rcsid="array.as";
22 #include "check.as"
24 callAndRecurse = function(prop, name) {
26 // Don't recurse infinitely.
27 if (prop == "__proto__") return;
28 if (prop == "constructor") return;
30 // i is the object, name is its name.
31 name = name + "." + prop;
32 var i = eval(name);
34 trace("testing " + name + "(" + typeof(i) + ")");
36 if (typeof(i) == "function") {
38 // First call with various arguments.
39 i();
40 i(1);
41 i(1, 2);
42 i(1, 2, 3);
43 i(1, 2, 3, 4);
45 trace("Trying to construct " + name);
46 o = new i();
48 if (o) {
49 trace("Object was constructed");
50 ASSetPropFlags(o, null, 0, 1);
51 ASSetPropFlags(o.__proto__, null, 0, 1);
52 for (p in o) {
53 trace("Testing " + p + "()");
54 o[p]();
55 o[p](1);
56 o[p](1, 2);
57 o[p](1, 2, 3);
58 o[p](1, 2, 3, 4);
60 o[p].call();
61 o[p].call(null);
62 o[p].call(null, 1);
63 o[p].call(null, 1, 2);
64 o[p].call(null, 1, 2, 3);
65 o[p].call(null, 1, 2, 3, 4);
67 // Recurse for own properties only.
68 if (o.hasOwnProperty(p)) {
69 callAndRecurse(p, name);
74 else if (typeof(i) == "object") {
75 ASSetPropFlags(i, null, 0, 1);
76 for (p in i) {
77 callAndRecurse(p, name);
83 start = "_global";
84 obj = eval(start);
86 ASSetPropFlags(obj, null, 0, 1);
87 for (prop in obj) {
88 callAndRecurse(prop, start);
91 pass("Nothing crashed gnash");