summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Object/prototype/toString/symbol-tag-override-instances.js
blob: 5e4d31e4ce51f91a7f019c097274b9982e721bc6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// Copyright (C) 2015 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: |
    16. Let tag be Get (O, @@toStringTag).
    17. ReturnIfAbrupt(tag).
    18. If Type(tag) is not String, let tag be builtinTag.
    19. Return the String that is the result of concatenating "[object ", tag,
        and "]".
features: [Symbol.toStringTag]
---*/

var custom;

custom = [];
custom[Symbol.toStringTag] = 'test262';
assert.sameValue(Object.prototype.toString.call(custom), '[object test262]');

custom = new String();
custom[Symbol.toStringTag] = 'test262';
assert.sameValue(Object.prototype.toString.call(custom), '[object test262]');

custom = (function() {
  return arguments;
}());
custom[Symbol.toStringTag] = 'test262';
assert.sameValue(Object.prototype.toString.call(custom), '[object test262]');

custom = function() {};
custom[Symbol.toStringTag] = 'test262';
assert.sameValue(Object.prototype.toString.call(custom), '[object test262]');

custom = new Error();
custom[Symbol.toStringTag] = 'test262';
assert.sameValue(Object.prototype.toString.call(custom), '[object test262]');

custom = new Boolean();
custom[Symbol.toStringTag] = 'test262';
assert.sameValue(Object.prototype.toString.call(custom), '[object test262]');

custom = new Number();
custom[Symbol.toStringTag] = 'test262';
assert.sameValue(Object.prototype.toString.call(custom), '[object test262]');

custom = new Date();
custom[Symbol.toStringTag] = 'test262';
assert.sameValue(Object.prototype.toString.call(custom), '[object test262]');

custom = /./;
custom[Symbol.toStringTag] = 'test262';
assert.sameValue(Object.prototype.toString.call(custom), '[object test262]');

reportCompare(0, 0);