OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
57 null | 57 null |
58 ]; | 58 ]; |
59 | 59 |
60 | 60 |
61 var valuesWithoutNull = coercibleValues.concat(undefined); | 61 var valuesWithoutNull = coercibleValues.concat(undefined); |
62 | 62 |
63 | 63 |
64 function TestSetPrototypeOfCoercibleValues() { | 64 function TestSetPrototypeOfCoercibleValues() { |
65 for (var i = 0; i < coercibleValues.length; i++) { | 65 for (var i = 0; i < coercibleValues.length; i++) { |
66 var value = coercibleValues[i]; | 66 var value = coercibleValues[i]; |
67 var proto = Object.getPrototypeOf(value); | 67 assertThrows(function() { |
| 68 Object.getPrototypeOf(value); |
| 69 }, TypeError); |
| 70 |
68 assertEquals(Object.setPrototypeOf(value, {}), value); | 71 assertEquals(Object.setPrototypeOf(value, {}), value); |
69 assertSame(proto, Object.getPrototypeOf(value)); | 72 |
| 73 assertThrows(function() { |
| 74 Object.getPrototypeOf(value); |
| 75 }, TypeError); |
70 } | 76 } |
71 } | 77 } |
72 TestSetPrototypeOfCoercibleValues(); | 78 TestSetPrototypeOfCoercibleValues(); |
73 | 79 |
74 | 80 |
75 function TestSetPrototypeOfNonCoercibleValues() { | 81 function TestSetPrototypeOfNonCoercibleValues() { |
76 for (var i = 0; i < nonCoercibleValues.length; i++) { | 82 for (var i = 0; i < nonCoercibleValues.length; i++) { |
77 var value = nonCoercibleValues[i]; | 83 var value = nonCoercibleValues[i]; |
78 assertThrows(function() { | 84 assertThrows(function() { |
79 Object.setPrototypeOf(value, {}); | 85 Object.setPrototypeOf(value, {}); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 assertEquals(object.y, 'old y'); | 159 assertEquals(object.y, 'old y'); |
154 | 160 |
155 var newProto = { | 161 var newProto = { |
156 x: 'new x' | 162 x: 'new x' |
157 }; | 163 }; |
158 Object.setPrototypeOf(object, newProto); | 164 Object.setPrototypeOf(object, newProto); |
159 assertEquals(object.x, 'new x'); | 165 assertEquals(object.x, 'new x'); |
160 assertFalse('y' in object); | 166 assertFalse('y' in object); |
161 } | 167 } |
162 TestLookup(); | 168 TestLookup(); |
OLD | NEW |