diff options
author | Rick Waldron <waldron.rick@gmail.com> | 2017-01-20 14:55:36 -0500 |
---|---|---|
committer | Tom Care <tcare@microsoft.com> | 2017-01-20 11:55:36 -0800 |
commit | f280db452e6e5a2fc9ba9056ae57765362d46a7a (patch) | |
tree | 422d74e123a3d8ec58cb363b54ff6ed7af1c7ab2 | |
parent | ced9bfd7be4f87bb317b39f9f9b623c273a84c2a (diff) | |
download | qtdeclarative-testsuites-f280db452e6e5a2fc9ba9056ae57765362d46a7a.tar.gz |
Test Symbol.toStringTag overrides on primitive wrapper prototypes. Closes gh-809 (#837)
Signed-off-by: Rick Waldron <waldron.rick@gmail.com>
-rw-r--r-- | test/built-ins/Object/prototype/toString/symbol-tag-override-instances.js (renamed from test/built-ins/Object/prototype/toString/symbol-tag-override.js) | 0 | ||||
-rw-r--r-- | test/built-ins/Object/prototype/toString/symbol-tag-override-primitives.js | 42 |
2 files changed, 42 insertions, 0 deletions
diff --git a/test/built-ins/Object/prototype/toString/symbol-tag-override.js b/test/built-ins/Object/prototype/toString/symbol-tag-override-instances.js index 2a30e22ac..2a30e22ac 100644 --- a/test/built-ins/Object/prototype/toString/symbol-tag-override.js +++ b/test/built-ins/Object/prototype/toString/symbol-tag-override-instances.js diff --git a/test/built-ins/Object/prototype/toString/symbol-tag-override-primitives.js b/test/built-ins/Object/prototype/toString/symbol-tag-override-primitives.js new file mode 100644 index 000000000..503691bc8 --- /dev/null +++ b/test/built-ins/Object/prototype/toString/symbol-tag-override-primitives.js @@ -0,0 +1,42 @@ +// 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]'); |