Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: test/mjsunit/object-freeze.js

Issue 7053035: Fix a number of tests that incorrectly used assertUnreachable. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Address comments. Created 9 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « test/mjsunit/object-define-property.js ('k') | test/mjsunit/object-literal.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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 14 matching lines...) Expand all
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 // Tests the Object.freeze and Object.isFrozen methods - ES 15.2.3.9 and 28 // Tests the Object.freeze and Object.isFrozen methods - ES 15.2.3.9 and
29 // ES 15.2.3.12 29 // ES 15.2.3.12
30 30
31 31
32 // Test that we throw an error if an object is not passed as argument. 32 // Test that we throw an error if an object is not passed as argument.
33 var non_objects = new Array(undefined, null, 1, -1, 0, 42.43); 33 var non_objects = new Array(undefined, null, 1, -1, 0, 42.43);
34 for (var key in non_objects) { 34 for (var key in non_objects) {
35 var exception = false;
35 try { 36 try {
36 Object.freeze(non_objects[key]); 37 Object.freeze(non_objects[key]);
37 assertUnreachable();
38 } catch(e) { 38 } catch(e) {
39 exception = true;
39 assertTrue(/Object.freeze called on non-object/.test(e)); 40 assertTrue(/Object.freeze called on non-object/.test(e));
40 } 41 }
42 assertTrue(exception);
41 } 43 }
42 44
43 for (var key in non_objects) { 45 for (var key in non_objects) {
46 exception = false;
44 try { 47 try {
45 Object.isFrozen(non_objects[key]); 48 Object.isFrozen(non_objects[key]);
46 assertUnreachable();
47 } catch(e) { 49 } catch(e) {
50 exception = true;
48 assertTrue(/Object.isFrozen called on non-object/.test(e)); 51 assertTrue(/Object.isFrozen called on non-object/.test(e));
49 } 52 }
53 assertTrue(exception);
50 } 54 }
51 55
52 // Test normal data properties. 56 // Test normal data properties.
53 var obj = { x: 42, z: 'foobar' }; 57 var obj = { x: 42, z: 'foobar' };
54 var desc = Object.getOwnPropertyDescriptor(obj, 'x'); 58 var desc = Object.getOwnPropertyDescriptor(obj, 'x');
55 assertTrue(desc.writable); 59 assertTrue(desc.writable);
56 assertTrue(desc.configurable); 60 assertTrue(desc.configurable);
57 assertEquals(42, desc.value); 61 assertEquals(42, desc.value);
58 62
59 desc = Object.getOwnPropertyDescriptor(obj, 'z'); 63 desc = Object.getOwnPropertyDescriptor(obj, 'z');
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 var obj5 = {}; 184 var obj5 = {};
181 Object.defineProperty(obj5, 'x', {configurable: true, writable: false}); 185 Object.defineProperty(obj5, 'x', {configurable: true, writable: false});
182 Object.defineProperty(obj5, 'y', {configurable: false, writable: false}); 186 Object.defineProperty(obj5, 'y', {configurable: false, writable: false});
183 Object.preventExtensions(obj5); 187 Object.preventExtensions(obj5);
184 188
185 assertFalse(Object.isFrozen(obj5)); 189 assertFalse(Object.isFrozen(obj5));
186 190
187 // Make sure that Object.freeze returns the frozen object. 191 // Make sure that Object.freeze returns the frozen object.
188 var obj6 = {} 192 var obj6 = {}
189 assertTrue(obj6 === Object.freeze(obj6)) 193 assertTrue(obj6 === Object.freeze(obj6))
OLDNEW
« no previous file with comments | « test/mjsunit/object-define-property.js ('k') | test/mjsunit/object-literal.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698