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

Side by Side Diff: test/mjsunit/has-own-property.js

Issue 7356013: Implement Object.prototype.hasOwnProperty in generated code. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 5 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
« src/ia32/code-stubs-ia32.cc ('K') | « 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 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 18 matching lines...) Expand all
29 assertTrue({x:12}.hasOwnProperty('x')); 29 assertTrue({x:12}.hasOwnProperty('x'));
30 assertFalse({x:12}.hasOwnProperty('y')); 30 assertFalse({x:12}.hasOwnProperty('y'));
31 31
32 // Check for strings. 32 // Check for strings.
33 assertTrue(''.hasOwnProperty('length')); 33 assertTrue(''.hasOwnProperty('length'));
34 assertTrue(Object.prototype.hasOwnProperty.call('', 'length')); 34 assertTrue(Object.prototype.hasOwnProperty.call('', 'length'));
35 35
36 // Check for numbers. 36 // Check for numbers.
37 assertFalse((123).hasOwnProperty('length')); 37 assertFalse((123).hasOwnProperty('length'));
38 assertFalse(Object.prototype.hasOwnProperty.call(123, 'length')); 38 assertFalse(Object.prototype.hasOwnProperty.call(123, 'length'));
39
40 var o = {foo:0, bar:1};
41 assertTrue(o.hasOwnProperty("foo"));
42 assertTrue(o.hasOwnProperty("fo" + "o"));
43 assertTrue(o.hasOwnProperty("bar"));
44 assertTrue(o.hasOwnProperty("b" + "ar"));
45 assertFalse(o.hasOwnProperty("baz"));
46 assertFalse(o.hasOwnProperty("ba" + "z"));
47 assertFalse(o.hasOwnProperty("b" + "az"));
48
49 var longString = "a";
50 for (var i = 0; i < 65535; i++) {
51 longString += String.fromCharCode(i);
52 }
53 for (var i = 0; i < 65535; i++) {
54 longString.charCodeAt(i);
55 }
56 var strings = [];
57 var symbols = [];
58 var o = {};
59 for (var i = 0; i < 100; i++) {
60 strings[i] = "foo" + i;
61 symbols[i] = eval("'" + strings[i] + "'");
62 o[symbols[i]] = 0;
63 }
64 for (var i = 0; i < 100; i++) {
65 assertTrue(o.hasOwnProperty(strings[i]));
66 assertTrue(o.hasOwnProperty(symbols[i]));
67 assertFalse(o.hasOwnProperty(symbols[i] + "x"));
68 assertFalse(o.hasOwnProperty(strings[i] + "x"));
69 assertFalse(o.hasOwnProperty(i));
70 assertFalse(o.hasOwnProperty(longString));
71 }
72 o = {};
73 for (var i = 0; i < 100; i++) {
74 strings[i] = "foo" + i;
75 o[strings[i]] = 0;
76 }
77 for (var i = 0; i < 100; i++) {
78 assertTrue(o.hasOwnProperty(strings[i]));
79 assertTrue(o.hasOwnProperty(symbols[i]));
80 assertFalse(o.hasOwnProperty(symbols[i] + "x"));
81 assertFalse(o.hasOwnProperty(strings[i] + "x"));
82 assertFalse(o.hasOwnProperty(i));
83 assertFalse(o.hasOwnProperty(longString));
84 }
OLDNEW
« src/ia32/code-stubs-ia32.cc ('K') | « src/v8natives.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698