128
127
check_equals(TypeChanger.__proto__, Function.prototype);
130
check(! TypeChanger.prototype instanceof TypeChanger);
131
132
o1 = new TypeChanger(false);
132
133
check_equals(o1.__proto__, TypeChanger.prototype);
133
#if OUTPUT_VERSION > 5
134
check_equals(o1.__constructor__, TypeChanger);
136
check_equals(o1.__constructor__, TypeChanger);
134
check_equals(o1.__constructor__, TypeChanger);
138
135
check(o1 instanceof TypeChanger);
139
136
check(o1 instanceof Object);
140
137
o2 = new TypeChanger(true);
206
203
DerivedClass.prototype.typeofSuper = function() { return typeof(super); };
207
204
check_equals(derived.typeofSuper(), 'object');
208
xcheck_equals(DerivedClass.prototype.typeofSuper(), 'object');
205
check_equals(DerivedClass.prototype.typeofSuper(), 'object');
210
207
DerivedClass.prototype.getSuper = function() { return super; };
211
208
s = derived.getSuper();
212
209
check_equals(typeof(s), 'object');
213
210
check_equals(s.sayHello, BaseClass.prototype.sayHello);
214
xcheck(!s.hasOwnProperty('sayHello')); // sayHello is not copied to 's'
211
check(!s.hasOwnProperty('sayHello')); // sayHello is not copied to 's'
215
212
check_equals(s.__proto__, Object.prototype); // nor it's found in __proto__
216
213
check_equals(typeof(s.prototype), 'undefined');
217
214
check_equals(typeof(s.constructor), 'function');
218
215
check_equals(s.constructor, BaseClass); // maybe sayHello is looked for here...
219
216
check_equals(typeof(s.__constructor__), 'undefined');
220
xcheck(s != BaseClass.prototype);
217
check(s != BaseClass.prototype);
222
219
DerivedClass.prototype.typeofThis = function() { return typeof(this); };
223
220
check_equals(derived.typeofThis(), 'object');
263
260
return super.whoami()+"."+"C";
265
262
#if OUTPUT_VERSION > 5
266
xcheck_equals(co.whoami(), "A.B.C"); // gnash fails returning .B.C (SWF6) or undefined.B.C (SWF>6)
263
check_equals(co.whoami(), "A.B.C");
268
265
check_equals(co.whoami(), ".C");
268
// Test gaps in inheritance chain
269
function F() { FctorCalls++; /*note("F ctor");*/ }
270
F.prototype.myName = function() { return "F"; };
271
A.prototype.__constructor__ = F; A.prototype.__proto__ = F.prototype;
272
A.prototype.myName = function() { /*note("A.prototype.myName called");*/ super(); return super.myName()+"A"; };
273
C.prototype.myName = function() { /*note("C.prototype.myName called");*/ super(); return super.myName()+"C"; };
278
#if OUTPUT_VERSION < 6
279
check_equals(n, "C"); // no super
280
check_equals(FctorCalls, 0); // no super
281
check_equals(BctorCalls, 0); // no super
282
check_equals(ActorCalls, 0); // no super
284
#if OUTPUT_VERSION == 6
285
check_equals(n, "FAAC"); // super in C references B proto and B ctor no matter where myName was found
286
check_equals(FctorCalls, 1);
287
check_equals(BctorCalls, 1);
288
check_equals(ActorCalls, 1);
290
#if OUTPUT_VERSION > 6
291
check_equals(n, "FAC"); // super in C references A proto and B ctor
292
check_equals(FctorCalls, 1);
293
check_equals(BctorCalls, 1);
294
check_equals(ActorCalls, 0); // B.prototype calling super() calls F prototype, not A's
298
delete A.prototype.myName;
303
#if OUTPUT_VERSION < 6
304
check_equals(n, "C"); // no super
305
check_equals(FctorCalls, 0); // no super
306
check_equals(BctorCalls, 0); // no super
307
check_equals(ActorCalls, 0); // no super
309
check_equals(co.myName(), "FC"); // super in C references F proto and B ctor
310
check_equals(FctorCalls, 0);
311
check_equals(BctorCalls, 2);
312
check_equals(ActorCalls, 0);
315
// Now test 'super' at the top of the inheritance chain
316
F.prototype.myName = function() { /*note("F.prototype.myName called");*/ super(); return super.myName()+"F"; };
320
//note("Calling co (instanceof C) myName method");
322
//note("Done calling co (instanceof C) myName method");
323
#if OUTPUT_VERSION < 6
324
check_equals(n, "C"); // no super
325
check_equals(FctorCalls, 0); // no super
326
check_equals(BctorCalls, 0); // no super
327
check_equals(ActorCalls, 0); // no super
329
#if OUTPUT_VERSION == 6
330
check_equals(n, "FFFC"); // super in C references F proto
331
check_equals(FctorCalls, 1);
332
check_equals(BctorCalls, 1);
333
check_equals(ActorCalls, 1);
335
#if OUTPUT_VERSION > 6
336
check_equals(n, "undefinedFFC");
337
check_equals(FctorCalls, 1);
338
check_equals(BctorCalls, 1);
339
check_equals(ActorCalls, 0);
271
342
//------------------------------------------------
273
344
//------------------------------------------------
452
523
check(! t5 instanceOf Test4);
453
524
check(t4 instanceOf Test4);
454
525
check(! t4 instanceOf Test5);
527
//------------------------------------------------
528
// Test implements op
529
//------------------------------------------------
531
#ifdef MING_SUPPORTS_ASM_IMPLEMENTS
535
A.prototype = {}; // need a prototype to set as interface of B.prototype
537
B.prototype = {}; // need a prototype to register interfaces on
542
push 1 // 1 interface to register
545
implements // will register A.prototype as an interface of B.prototype
549
check (! ob instanceof A );
550
ob.__proto__ = B.prototype;
551
check ( ob instanceof A );
553
// Set A.prototype as a prototype of another object
554
// and see if now ob results an instance of that other
557
check (! ob instanceof C );
558
C.prototype = A.prototype;
559
check ( ob instanceof C );
561
#endif // MING_SUPPORTS_ASM_IMPLEMENTS
563
//------------------------------------------------
565
//------------------------------------------------
567
#if OUTPUT_VERSION < 6
569
# ifdef MING_SUPPORTS_ASM_IMPLEMENTS
577
# ifdef MING_SUPPORTS_ASM_IMPLEMENTS
585
dangerousStuff = function()
590
check(!a instanceof b); // really just tests if we survive :)
594
note("Now your flash player will try to answer the egg/chicken question. Kill it if it hangs your machine");
595
setTimeout(dangerousStuff, 0);