summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Object/prototype/toString/symbol-tag-override-primitives.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/tests/test262/built-ins/Object/prototype/toString/symbol-tag-override-primitives.js')
-rw-r--r--js/src/tests/test262/built-ins/Object/prototype/toString/symbol-tag-override-primitives.js44
1 files changed, 44 insertions, 0 deletions
diff --git a/js/src/tests/test262/built-ins/Object/prototype/toString/symbol-tag-override-primitives.js b/js/src/tests/test262/built-ins/Object/prototype/toString/symbol-tag-override-primitives.js
new file mode 100644
index 0000000000..d7e77ec1ee
--- /dev/null
+++ b/js/src/tests/test262/built-ins/Object/prototype/toString/symbol-tag-override-primitives.js
@@ -0,0 +1,44 @@
+// Copyright (C) 2017 the V8 project authors. All rights reserved.
+// This code is governed by the BSD license found in the LICENSE file.
+
+/*---
+description: >
+ String values of `Symbol.toStringTag` property override built-in tags
+es6id: 19.1.3.6
+info: |
+ 1. If the this value is undefined, return "[object Undefined]".
+ 2. If the this value is null, return "[object Null]".
+
+ 14. Else, let builtinTag be "Object".
+ 15. Let tag be ? Get(O, @@toStringTag).
+ 16. If Type(tag) is not String, let tag be builtinTag.
+ 17. Return the String that is the result of concatenating "[object ", tag, and "]".
+
+ 4.3.2 primitive value
+
+ member of one of the types Undefined, Null, Boolean, Number, Symbol, or String as defined in clause 6
+
+features: [Symbol.toStringTag]
+---*/
+
+
+Boolean.prototype[Symbol.toStringTag] = 'test262';
+assert.sameValue(Object.prototype.toString.call(Boolean.prototype), '[object test262]');
+assert.sameValue(Object.prototype.toString.call(true), '[object test262]');
+
+Number.prototype[Symbol.toStringTag] = 'test262';
+assert.sameValue(Object.prototype.toString.call(Number.prototype), '[object test262]');
+assert.sameValue(Object.prototype.toString.call(0), '[object test262]');
+
+String.prototype[Symbol.toStringTag] = 'test262';
+assert.sameValue(Object.prototype.toString.call(String.prototype), '[object test262]');
+assert.sameValue(Object.prototype.toString.call(''), '[object test262]');
+
+
+Object.defineProperty(Symbol.prototype, Symbol.toStringTag, {
+ value: 'test262'
+});
+
+assert.sameValue(Object.prototype.toString.call(Symbol.prototype), '[object test262]');
+
+reportCompare(0, 0);