]>
git.saurik.com Git - apple/javascriptcore.git/blob - tests/mozilla/ecma_2/instanceof/instanceof-003.js
2 File Name: instanceof-003.js
4 Description: http://bugzilla.mozilla.org/show_bug.cgi?id=7635
9 js> Foo.prototype = theproto
11 js> theproto instanceof Foo
14 I think this should be 'false'
17 Author: christine@netscape.com
18 Date: 12 november 1997
21 The test case described above is correct, however the second test case in this file is not,
22 'o instanceof o' should thow an exception. According to ECMA-262:
24 8.6.2 Internal Properties and Methods:
25 "... only Function objects implement [[HasInstance]]"
26 11.8.6 The instanceof operator:
27 "6.If Result(4) does not have a [[HasInstance]] method, throw a TypeError exception."
29 {} does not implement [[HasInstance]] (since it is not a function), so passing it as the
30 constructor to be tested to instanceof should result in a TypeError being thrown.
33 var SECTION
= "instanceof-003";
34 var VERSION
= "ECMA_2";
35 var TITLE
= "instanceof operator";
36 var BUGNUMBER
="http://bugzilla.mozilla.org/show_bug.cgi?id=7635";
42 Foo
.prototype = theproto
;
45 "function Foo() = {}; theproto = {}; Foo.prototype = theproto; " +
46 "theproto instanceof Foo",
48 theproto
instanceof Foo
);
52 "o = {}; o instanceof o",
54 (function(){ try { var o
= {}; o
instanceof o
; return "no exception"; } catch (e
) { return "EXCEPTION"; } } )() );