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

Unified Diff: test/mjsunit/object-literal.js

Issue 493173003: Fix issue with numeric property names (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/preparser.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/object-literal.js
diff --git a/test/mjsunit/object-literal.js b/test/mjsunit/object-literal.js
index 3d0b33bd99195584829d67db2af31ed123ce6d31..53188d15b8aebeb39ad30470f3f08da5565bc7ab 100644
--- a/test/mjsunit/object-literal.js
+++ b/test/mjsunit/object-literal.js
@@ -190,3 +190,73 @@ function testKeywordProperty(keyword) {
for (var i = 0; i < keywords.length; i++) {
testKeywordProperty(keywords[i]);
}
+
+
+(function TestNumericNames() {
+ var o = {
+ 1: 1,
+ 2.: 2,
+ 3.0: 3,
+ 4e0: 4,
+ 5E0: 5,
+ 6e-0: 6,
+ 7E-0: 7,
+ 0x8: 8,
+ 0X9: 9,
+ }
+ assertEquals(['1', '2', '3', '4', '5', '6', '7', '8', '9'], Object.keys(o));
+
+ o = {
+ 1.2: 1.2,
+ 1.30: 1.3
+ };
+ assertEquals(['1.2', '1.3'], Object.keys(o));
+})();
+
+
+function TestNumericNamesGetter(expectedKeys, object) {
+ assertEquals(expectedKeys, Object.keys(object));
+ expectedKeys.forEach(function(key) {
+ var descr = Object.getOwnPropertyDescriptor(object, key);
+ assertEquals(key, descr.get.name);
+ });
+}
+TestNumericNamesGetter(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
+ get 1() {},
+ get 2.() {},
+ get 3.0() {},
+ get 4e0() {},
+ get 5E0() {},
+ get 6e-0() {},
+ get 7E-0() {},
+ get 0x8() {},
+ get 0X9() {},
+});
+TestNumericNamesGetter(['1.2', '1.3'], {
+ get 1.2() {},
+ get 1.30() {}
+});
+
+
+function TestNumericNamesSetter(expectedKeys, object) {
+ assertEquals(expectedKeys, Object.keys(object));
+ expectedKeys.forEach(function(key) {
+ var descr = Object.getOwnPropertyDescriptor(object, key);
+ assertEquals(key, descr.set.name);
+ });
+}
+TestNumericNamesSetter(['1', '2', '3', '4', '5', '6', '7', '8', '9'], {
+ set 1(_) {},
+ set 2.(_) {},
+ set 3.0(_) {},
+ set 4e0(_) {},
+ set 5E0(_) {},
+ set 6e-0(_) {},
+ set 7E-0(_) {},
+ set 0x8(_) {},
+ set 0X9(_) {},
+});
+TestNumericNamesSetter(['1.2', '1.3'], {
+ set 1.2(_) {; },
+ set 1.30(_) {; }
+});
« no previous file with comments | « src/preparser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698