~ubuntu-branches/ubuntu/saucy/gnash/saucy-proposed

« back to all changes in this revision

Viewing changes to testsuite/actionscript.all/Inheritance.as

  • Committer: Bazaar Package Importer
  • Author(s): Alexander Sack
  • Date: 2008-10-13 14:29:49 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20081013142949-f6qdvnu4mn05ltdc
Tags: 0.8.4~~bzr9980-0ubuntu1
* new upstream release 0.8.4 (LP: #240325)
* ship new lib usr/lib/gnash/libmozsdk.so.* in mozilla-plugin-gnash
  - update debian/mozilla-plugin-gnash.install
* ship new lib usr/lib/gnash/libgnashnet.so.* in gnash-common
  - update debian/gnash-common.install
* add basic debian/build_head script to build latest CVS head packages.
  - add debian/build_head
* new sound architecture requires build depend on libsdl1.2-dev
  - update debian/control
* head build script now has been completely migrated to bzr (upstream +
  ubuntu)
  - update debian/build_head
* disable kde gui until klash/qt4 has been fixed; keep kde packages as empty
  packages for now.
  - update debian/rules
  - debian/klash.install
  - debian/klash.links
  - debian/klash.manpages
  - debian/konqueror-plugin-gnash.install
* drop libkonq5-dev build dependency accordingly
  - update debian/control
* don't install headers manually anymore. gnash doesnt provide a -dev
  package after all
  - update debian/rules
* update libs installed in gnash-common; libgnashserver-*.so is not available
  anymore (removed); in turn we add the new libgnashcore-*.so
  - update debian/gnash-common.install
* use -Os for optimization and properly pass CXXFLAGS=$(CFLAGS) to configure
  - update debian/rules
* touch firefox .autoreg in postinst of mozilla plugin
  - update debian/mozilla-plugin-gnash.postinst
* link gnash in ubufox plugins directory for the plugin alternative switcher
  - add debian/mozilla-plugin-gnash.links
* suggest ubufox accordingly
  - update debian/control
* add new required build-depends on libgif-dev
  - update debian/control
* add Xb-Npp-Description and Xb-Npp-File as new plugin database meta data
  - update debian/control

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
// 
2
 
//   Copyright (C) 2005, 2006, 2007 Free Software Foundation, Inc.
 
2
//   Copyright (C) 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
3
3
//
4
4
// This program is free software; you can redistribute it and/or modify
5
5
// it under the terms of the GNU General Public License as published by
21
21
// compile this test case with Ming makeswf, and then
22
22
// execute it like this gnash -1 -r 0 -v out.swf
23
23
 
24
 
rcsid="$Id: Inheritance.as,v 1.43 2007/09/29 16:22:57 strk Exp $";
25
 
 
 
24
rcsid="$Id: Inheritance.as,v 1.64 2008/06/19 10:51:44 strk Exp $";
26
25
#include "check.as"
27
26
 
28
27
check_equals(typeof(Object.prototype.constructor), 'function');
128
127
check_equals(TypeChanger.__proto__, Function.prototype);
129
128
#endif
130
129
 
 
130
check(! TypeChanger.prototype instanceof TypeChanger);
 
131
 
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);
135
 
#else
136
 
check_equals(o1.__constructor__, TypeChanger);
137
 
#endif
 
134
check_equals(o1.__constructor__, TypeChanger);
138
135
check(o1 instanceof TypeChanger);
139
136
check(o1 instanceof Object);
140
137
o2 = new TypeChanger(true);
205
202
 
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');
209
206
 
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);
221
218
 
222
219
DerivedClass.prototype.typeofThis = function() { return typeof(this); };
223
220
check_equals(derived.typeofThis(), 'object');
231
228
check_equals(super, undefined);
232
229
 
233
230
 
234
 
function A() {}
 
231
function A() { ActorCalls++; }
235
232
A.prototype.whoami = function() {
236
233
        return "A";
237
234
};
238
 
function B() {}
 
235
function B() { BctorCalls++; }
239
236
B.prototype = new A;
240
237
bo = new B;
241
238
check_equals(bo.whoami(), "A");
251
248
C.prototype = new B;
252
249
co = new C;
253
250
#if OUTPUT_VERSION > 6
254
 
 xcheck_equals(co.whoami(), "A.B"); // gnash fails returning undefined.B.B
 
251
 check_equals(co.whoami(), "A.B"); 
255
252
#else
256
253
# if OUTPUT_VERSION == 6
257
 
   xcheck_equals(co.whoami(), "A.B.B"); // gnash fails returning .B.B
 
254
   check_equals(co.whoami(), "A.B.B"); 
258
255
# else
259
256
   check_equals(co.whoami(), ".B");
260
257
# endif
263
260
        return super.whoami()+"."+"C";
264
261
};
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"); 
267
264
#else
268
265
  check_equals(co.whoami(), ".C");
269
266
#endif
270
267
 
 
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"; };
 
274
FctorCalls=0;
 
275
BctorCalls=0;
 
276
ActorCalls=0;
 
277
n = co.myName();
 
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
 
283
#endif
 
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); 
 
289
#endif
 
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
 
295
#endif
 
296
 
 
297
// double gap now
 
298
delete A.prototype.myName;
 
299
FctorCalls=0;
 
300
BctorCalls=0;
 
301
ActorCalls=0;
 
302
n = co.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
 
308
#else
 
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); 
 
313
#endif
 
314
 
 
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"; };
 
317
FctorCalls=0;
 
318
BctorCalls=0;
 
319
ActorCalls=0;
 
320
//note("Calling co (instanceof C) myName method");
 
321
n = co.myName();
 
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
 
328
#endif
 
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); 
 
334
#endif
 
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); 
 
340
#endif
 
341
 
271
342
//------------------------------------------------
272
343
//
273
344
//------------------------------------------------
452
523
check(! t5 instanceOf Test4);
453
524
check(t4 instanceOf Test4);
454
525
check(! t4 instanceOf Test5);
455
 
totals();
 
526
 
 
527
//------------------------------------------------
 
528
// Test implements op
 
529
//------------------------------------------------
 
530
 
 
531
#ifdef MING_SUPPORTS_ASM_IMPLEMENTS
 
532
 
 
533
 
 
534
A = {};
 
535
A.prototype = {}; // need a prototype to set as interface of B.prototype
 
536
B = {};
 
537
B.prototype = {}; // need a prototype to register interfaces on
 
538
 
 
539
asm {
 
540
        push "A"
 
541
        getvariable
 
542
        push 1 // 1 interface to register
 
543
        push "B"
 
544
        getvariable
 
545
        implements // will register A.prototype as an interface of B.prototype 
 
546
};
 
547
 
 
548
ob = {};
 
549
check (! ob instanceof A ); 
 
550
ob.__proto__ = B.prototype;
 
551
check (  ob instanceof A ); 
 
552
 
 
553
// Set A.prototype as a prototype of another object
 
554
// and see if now ob results an instance of that other
 
555
// object.. (it is)
 
556
C = {};
 
557
check (! ob instanceof C ); 
 
558
C.prototype = A.prototype;
 
559
check (  ob instanceof C ); 
 
560
 
 
561
#endif // MING_SUPPORTS_ASM_IMPLEMENTS
 
562
 
 
563
//------------------------------------------------
 
564
// END OF TEST
 
565
//------------------------------------------------
 
566
 
 
567
#if OUTPUT_VERSION < 6
 
568
 
 
569
# ifdef MING_SUPPORTS_ASM_IMPLEMENTS
 
570
    check_totals(106); 
 
571
# else
 
572
    check_totals(102); 
 
573
# endif
 
574
 
 
575
#else // SWF6,7,8
 
576
 
 
577
# ifdef MING_SUPPORTS_ASM_IMPLEMENTS
 
578
    check_totals(163);
 
579
# else
 
580
    check_totals(159); 
 
581
# endif
 
582
 
 
583
#endif
 
584
 
 
585
dangerousStuff = function()
 
586
{
 
587
        a = {}; b = {};
 
588
        a.__proto__ = b;
 
589
        b.__proto__ = a;
 
590
        check(!a instanceof b); // really just tests if we survive :)
 
591
};
 
592
 
 
593
note("");
 
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);
 
596
 
 
597