summaryrefslogtreecommitdiffstats
path: root/js/src/tests/test262/built-ins/Symbol/prototype/valueOf/this-val-non-obj.js
blob: fe5ee1516605c7ab8bd79cb507ecb7576c974b60 (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
// Copyright (C) 2016 the V8 project authors. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: sec-symbol.prototype.valueof
description: Called on a value that is neither a Symbol nor an Object
info: |
  1. Let s be the this value.
  2. If Type(s) is Symbol, return s.
  3. If Type(s) is not Object, throw a TypeError exception.
features: [Symbol]
---*/

var valueOf = Symbol.prototype.valueOf;

assert.throws(TypeError, function() {
  valueOf.call(null);
}, 'null');

assert.throws(TypeError, function() {
  valueOf.call(undefined);
}, 'undefined');

assert.throws(TypeError, function() {
  valueOf.call(0);
}, 'number');

assert.throws(TypeError, function() {
  valueOf.call('');
}, 'string');

reportCompare(0, 0);