js/src/tests/test262/ch13/13.2/S13.2.2_A1_T2.js

branch
TOR_BUG_3246
changeset 6
8bccb770b82d
equal deleted inserted replaced
-1:000000000000 0:565c54228209
1 // Copyright 2009 the Sputnik authors. All rights reserved.
2 // This code is governed by the BSD license found in the LICENSE file.
3
4 /**
5 * Since a function is an object, it might be set to [[Prototype]] property of a new created object through [[Construct]] property
6 *
7 * @path ch13/13.2/S13.2.2_A1_T2.js
8 * @description Declaring a function with "var __PROTO = function()"
9 */
10
11 var __MONSTER="monster";
12 var __PREDATOR="predator";
13
14 var __PROTO = function(){};
15
16 try{
17 __PROTO.type=__MONSTER;
18 }
19 catch(e){
20 $FAIL('#0: __PROTO.type=__MONSTER does not lead to throwing exception')
21 }
22
23 var __FACTORY = function(){this.name=__PREDATOR};
24
25 __FACTORY.prototype=__PROTO;
26
27 var __monster = new __FACTORY();
28
29 //////////////////////////////////////////////////////////////////////////////
30 //CHECK#1
31 if (!(__PROTO.isPrototypeOf(__monster))) {
32 $ERROR('#1: __PROTO.isPrototypeOf(__monster) must be true');
33 }
34 //
35 //////////////////////////////////////////////////////////////////////////////
36
37 //////////////////////////////////////////////////////////////////////////////
38 //CHECK#2
39 if (__monster.type !==__MONSTER) {
40 $ERROR('#2: __monster.type ===__MONSTER. Actual: __monster.type ==='+__monster.type);
41 }
42 //
43 //////////////////////////////////////////////////////////////////////////////
44

mercurial