|
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 * Only Function objects implement [[HasInstance]] and can be proper ShiftExpression for the "instanceof" operator consequently |
|
6 * |
|
7 * @path ch11/11.8/11.8.6/S11.8.6_A6_T4.js |
|
8 * @description Checking if RelationalExpression is object |
|
9 */ |
|
10 |
|
11 MyFunct = function(){}; |
|
12 __my__funct = new MyFunct; |
|
13 |
|
14 |
|
15 //CHECK#1 |
|
16 if (!(__my__funct instanceof MyFunct)){ |
|
17 $ERROR('#1 Only Function objects implement [[HasInstance]] and consequently can be proper ShiftExpression for The instanceof operator'); |
|
18 } |
|
19 |
|
20 //CHECK#2 |
|
21 if (__my__funct instanceof Function){ |
|
22 $ERROR('#2 Only Function objects implement [[HasInstance]] and consequently can be proper ShiftExpression for The instanceof operator'); |
|
23 } |
|
24 |
|
25 //CHECK#3 |
|
26 if (!(__my__funct instanceof Object)){ |
|
27 $ERROR('#3 Only Function objects implement [[HasInstance]] and consequently can be proper ShiftExpression for The instanceof operator'); |
|
28 } |
|
29 |
|
30 //CHECK#4 |
|
31 try{ |
|
32 __my__funct instanceof __my__funct; |
|
33 $ERROR('#4 Only Function objects implement [[HasInstance]] and consequently can be proper ShiftExpression for The instanceof operator'); |
|
34 } |
|
35 catch(e){ |
|
36 if (e instanceof TypeError !== true) { |
|
37 $ERROR('#4 Only Function objects implement [[HasInstance]] and consequently can be proper ShiftExpression for The instanceof operator'); |
|
38 } |
|
39 } |
|
40 |