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

Side by Side Diff: test/mjsunit/object-get-own-property-names.js

Issue 12342003: Use InternalArray in Object.getOwnPropertyNames() implementation (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Dealt with review comments Created 7 years, 9 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 | « src/v8natives.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 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 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 assertEquals("foo", propertyNames[0]); 70 assertEquals("foo", propertyNames[0]);
71 71
72 // Check that getter properties are returned. 72 // Check that getter properties are returned.
73 var obj = {}; 73 var obj = {};
74 obj.__defineGetter__("getter", function() {}); 74 obj.__defineGetter__("getter", function() {});
75 propertyNames = Object.getOwnPropertyNames(obj); 75 propertyNames = Object.getOwnPropertyNames(obj);
76 propertyNames.sort(); 76 propertyNames.sort();
77 assertEquals(1, propertyNames.length); 77 assertEquals(1, propertyNames.length);
78 assertEquals("getter", propertyNames[0]); 78 assertEquals("getter", propertyNames[0]);
79 79
80 // Check that implementation does not access Array.prototype.
81 var savedConcat = Array.prototype.concat;
82 Array.prototype.concat = function() { return []; }
83 propertyNames = Object.getOwnPropertyNames({0: 'foo', bar: 'baz'});
84 assertEquals(2, propertyNames.length);
85 assertEquals('0', propertyNames[0]);
86 assertEquals('bar', propertyNames[1]);
87 assertSame(Array.prototype, propertyNames.__proto__);
88 Array.prototype.concat = savedConcat;
89
80 try { 90 try {
81 Object.getOwnPropertyNames(4); 91 Object.getOwnPropertyNames(4);
82 assertTrue(false); 92 assertTrue(false);
83 } catch (e) { 93 } catch (e) {
84 assertTrue(/on non-object/.test(e)); 94 assertTrue(/on non-object/.test(e));
85 } 95 }
86 96
87 try { 97 try {
88 Object.getOwnPropertyNames("foo"); 98 Object.getOwnPropertyNames("foo");
89 assertTrue(false); 99 assertTrue(false);
90 } catch (e) { 100 } catch (e) {
91 assertTrue(/on non-object/.test(e)); 101 assertTrue(/on non-object/.test(e));
92 } 102 }
93 103
94 try { 104 try {
95 Object.getOwnPropertyNames(undefined); 105 Object.getOwnPropertyNames(undefined);
96 assertTrue(false); 106 assertTrue(false);
97 } catch (e) { 107 } catch (e) {
98 assertTrue(/on non-object/.test(e)); 108 assertTrue(/on non-object/.test(e));
99 } 109 }
100 110
101 try { 111 try {
102 Object.getOwnPropertyNames(null); 112 Object.getOwnPropertyNames(null);
103 assertTrue(false); 113 assertTrue(false);
104 } catch (e) { 114 } catch (e) {
105 assertTrue(/on non-object/.test(e)); 115 assertTrue(/on non-object/.test(e));
106 } 116 }
OLDNEW
« no previous file with comments | « src/v8natives.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698