OLD | NEW |
1 // Copyright 2008 the V8 project authors. All rights reserved. | 1 // Copyright 2008 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 assertFalse(C instanceof F); | 53 assertFalse(C instanceof F); |
54 assertFalse(B instanceof F); | 54 assertFalse(B instanceof F); |
55 assertFalse(A instanceof F); | 55 assertFalse(A instanceof F); |
56 } | 56 } |
57 | 57 |
58 TestChains(); | 58 TestChains(); |
59 | 59 |
60 | 60 |
61 function TestExceptions() { | 61 function TestExceptions() { |
62 function F() { } | 62 function F() { } |
| 63 function G() { } |
| 64 G.prototype = undefined; |
63 var items = [ 1, new Number(42), | 65 var items = [ 1, new Number(42), |
64 true, | 66 true, |
65 'string', new String('hest'), | 67 'string', new String('hest'), |
66 {}, [], | 68 {}, [], |
67 F, new F(), | 69 F, new F(), |
| 70 G, new G(), |
68 Object, String ]; | 71 Object, String ]; |
69 | 72 |
70 var exceptions = 0; | 73 var exceptions = 0; |
71 var instanceofs = 0; | 74 var instanceofs = 0; |
72 | 75 |
73 for (var i = 0; i < items.length; i++) { | 76 for (var i = 0; i < items.length; i++) { |
74 for (var j = 0; j < items.length; j++) { | 77 for (var j = 0; j < items.length; j++) { |
75 try { | 78 try { |
76 if (items[i] instanceof items[j]) instanceofs++; | 79 if (items[i] instanceof items[j]) instanceofs++; |
77 } catch (e) { | 80 } catch (e) { |
78 assertTrue(e instanceof TypeError); | 81 assertTrue(e instanceof TypeError); |
79 exceptions++; | 82 exceptions++; |
80 } | 83 } |
81 } | 84 } |
82 } | 85 } |
83 assertEquals(10, instanceofs); | 86 assertEquals(12, instanceofs); |
84 assertEquals(88, exceptions); | 87 assertEquals(130, exceptions); |
85 } | 88 } |
86 | 89 |
87 TestExceptions(); | 90 TestExceptions(); |
OLD | NEW |