Index: test/mjsunit/es6/object-tostring.js |
diff --git a/test/mjsunit/es6/object-tostring.js b/test/mjsunit/es6/object-tostring.js |
new file mode 100644 |
index 0000000000000000000000000000000000000000..e609b571c896189bd6be4028e11d662869401819 |
--- /dev/null |
+++ b/test/mjsunit/es6/object-tostring.js |
@@ -0,0 +1,35 @@ |
+// Copyright 2014 the V8 project authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+// Flags: --harmony-tostring |
+ |
+// TODO: Move duplicated tests into mjsunit/class-of-builtins.js |
Dmitry Lomov (no reviews)
2014/10/18 15:16:48
Nit: I volunteer to own this TODO, so add me to th
|
+var funs = { |
+ Object: [ Object ], |
+/* Function: [ Function ], |
Dmitry Lomov (no reviews)
2014/10/18 15:16:48
Why all these tests are commented out?
|
+ Array: [ Array ], |
+ String: [ String ], |
+ Boolean: [ Boolean ], |
+ Number: [ Number ], |
+ Date: [ Date ], |
+ RegExp: [ RegExp ], |
+ Error: [ Error, TypeError, RangeError, SyntaxError, ReferenceError, EvalError, URIError ]*/ |
+} |
+for (f in funs) { |
+ for (i in funs[f]) { |
+ assertEquals("[object " + f + "]", |
+ Object.prototype.toString.call(new funs[f][i]), |
+ funs[f][i]); |
+ assertEquals("[object Function]", |
+ Object.prototype.toString.call(funs[f][i]), |
+ funs[f][i]); |
+ } |
+ |
+ // Ensure class !== tag |
+ var fake = f === "Object" ? [] : {}; |
+ fake[Symbol.toStringTag] = f; |
+ // if tag is "Object", it is not prepended with "~" |
+ assertEquals(f === "Object" ? "[object " + f + "]" : "[object ~" + f + "]", |
Dmitry Lomov (no reviews)
2014/10/18 15:16:48
Add tests for all cases from 19.1.3.6.
|
+ Object.prototype.toString.call(fake)); |
+} |