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 assertThrows(function() { | 67 var proto = Object.getPrototypeOf(value); |
68 Object.getPrototypeOf(value); | |
69 }, TypeError); | |
70 | |
71 assertEquals(Object.setPrototypeOf(value, {}), value); | 68 assertEquals(Object.setPrototypeOf(value, {}), value); |
72 | 69 assertSame(proto, Object.getPrototypeOf(value)); |
73 assertThrows(function() { | |
74 Object.getPrototypeOf(value); | |
75 }, TypeError); | |
76 } | 70 } |
77 } | 71 } |
78 TestSetPrototypeOfCoercibleValues(); | 72 TestSetPrototypeOfCoercibleValues(); |
79 | 73 |
80 | 74 |
81 function TestSetPrototypeOfNonCoercibleValues() { | 75 function TestSetPrototypeOfNonCoercibleValues() { |
82 for (var i = 0; i < nonCoercibleValues.length; i++) { | 76 for (var i = 0; i < nonCoercibleValues.length; i++) { |
83 var value = nonCoercibleValues[i]; | 77 var value = nonCoercibleValues[i]; |
84 assertThrows(function() { | 78 assertThrows(function() { |
85 Object.setPrototypeOf(value, {}); | 79 Object.setPrototypeOf(value, {}); |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
159 assertEquals(object.y, 'old y'); | 153 assertEquals(object.y, 'old y'); |
160 | 154 |
161 var newProto = { | 155 var newProto = { |
162 x: 'new x' | 156 x: 'new x' |
163 }; | 157 }; |
164 Object.setPrototypeOf(object, newProto); | 158 Object.setPrototypeOf(object, newProto); |
165 assertEquals(object.x, 'new x'); | 159 assertEquals(object.x, 'new x'); |
166 assertFalse('y' in object); | 160 assertFalse('y' in object); |
167 } | 161 } |
168 TestLookup(); | 162 TestLookup(); |
OLD | NEW |