Update with current status
[gnash.git] / testsuite / actionscript.all / Instance.as
blobcb446ce1c9bba9c118a450ef8de3cb669970c695
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
20 // Test case for Instance construction
21 // compile this test case with Ming makeswf, and then
22 // execute it like this gnash -1 -r 0 -v out.swf
25 rcsid="Boolean.as";
26 #include "check.as"
29 n = 3;
30 o = new n;
31 check_equals(o, undefined);
33 // o = new 3;
34 asm {
35 push "o"
36 push 0
37 push "3"
38 new
39 setvariable
41 check_equals(o, undefined);
43 o = new Math.cos(9);
44 check_equals(typeof(o), "object");
45 check_equals(typeof(o.__proto__), "undefined");
46 ASSetPropFlags(o, null, 6, 1);
47 #if OUTPUT_VERSION < 7
48 check_equals(typeof(o.constructor), "function");
49 #else
50 check_equals(typeof(o.constructor), "undefined");
51 #endif
52 #if OUTPUT_VERSION > 5
53 check_equals(typeof(o.__constructor__), "function");
54 #else
55 check_equals(typeof(o.__constructor__), "undefined");
56 #endif
57 check_equals(o.toString(), undefined);
58 check_equals(o.valueOf(), undefined);
59 check(!o instanceOf Object);
60 check(!o instanceOf Number);
61 check(!o instanceOf String);
63 o = new Math.cos();
64 check_equals(typeof(o), "object");
65 check_equals(typeof(o.__proto__), "undefined");
66 #if OUTPUT_VERSION < 7
67 check_equals(typeof(o.constructor), "function");
68 #else
69 check_equals(typeof(o.constructor), "undefined");
70 #endif
71 check_equals(o.toString(), undefined);
72 check_equals(o.valueOf(), undefined);
73 check(!o instanceOf Object);
74 check(!o instanceOf Number);
75 check(!o instanceOf String);
77 o = new Mouse.hide();
78 check_equals(typeof(o), "object");
79 check_equals(typeof(o.__proto__), "undefined");
80 #if OUTPUT_VERSION < 7
81 check_equals(typeof(o.constructor), "function");
82 #else
83 check_equals(typeof(o.constructor), "undefined");
84 #endif
85 check_equals(o.toString(), undefined);
86 check_equals(o.valueOf(), undefined);
87 check(!o instanceOf Object);
88 check(!o instanceOf Number);
89 check(!o instanceOf String);
91 o = new Stage.align();
92 check_equals(typeof(o), "undefined");
94 o = new Date.UTC();
95 check_equals(typeof(o), "object");
96 check_equals(o.toString(), undefined);
97 check_equals(o.valueOf(), undefined);
98 check(!o instanceOf Object);
100 // This should be undefined in SWF7 and below because BitmapData doesn't exist.
101 // It should be undefined in SWF8 because the object isn't constructed when the
102 // given values are incorrect.
103 o = new flash.display.BitmapData();
104 check_equals(typeof(o), "undefined");
105 check_equals(o, undefined);
107 // Check object.prototype
108 // It seems this can't be changed under any circumstances.
109 delete Object.prototype;
110 check_equals(typeof(Object.prototype), "object");
111 Object.prototype = 6;
112 check_equals(typeof(Object.prototype), "object");
113 check_equals(Object.prototype.toString(), "[object Object]");
114 ASSetPropFlags(Object, null, 0);
115 delete Object.prototype;
116 check_equals(typeof(Object.prototype), "object");
118 // String.prototype can be changed.
119 String.prototype = 8;
120 check_equals(typeof(String.prototype), "number");
121 check_equals(String.prototype, 8);
122 s = new String("hello");
123 #if OUTPUT_VERSION == 5
124 check_equals(s, undefined);
125 #else
126 check_equals(s, undefined);
127 #endif
128 check_equals(s.__proto__, 8);
129 check_equals(typeof(s), "object");
130 check(!s instanceOf String);
132 s = new Object("hello");
133 #if OUTPUT_VERSION == 5
134 check_equals(s, undefined);
135 #else
136 check_equals(s, undefined);
137 #endif
139 Cl = function() {};
140 Cl.prototype = 8;
141 c = new Cl();
142 check_equals(c.__proto__, 8);
144 check_totals(46);