2016-05-30 22:55:45 +02:00
|
|
|
// 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.keyfor
|
|
|
|
description: Called with a non-symbol argument
|
2018-01-05 18:26:51 +01:00
|
|
|
info: |
|
2016-05-30 22:55:45 +02:00
|
|
|
1. If Type(sym) is not Symbol, throw a TypeError exception.
|
2017-09-07 21:06:13 +02:00
|
|
|
features: [Symbol]
|
2016-05-30 22:55:45 +02:00
|
|
|
---*/
|
|
|
|
|
|
|
|
assert.sameValue(typeof Symbol.keyFor, 'function');
|
|
|
|
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
Symbol.keyFor(null);
|
|
|
|
}, 'null');
|
|
|
|
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
Symbol.keyFor(undefined);
|
|
|
|
}, 'undefined');
|
|
|
|
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
Symbol.keyFor('1');
|
|
|
|
}, 'number');
|
|
|
|
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
Symbol.keyFor('');
|
|
|
|
}, 'string');
|
|
|
|
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
Symbol.keyFor({});
|
|
|
|
}, 'ordinary object');
|
|
|
|
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
Symbol.keyFor([]);
|
|
|
|
}, 'array exotic object');
|
|
|
|
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
Symbol.keyFor(arguments);
|
|
|
|
}, 'arguments exotic object');
|
|
|
|
|
|
|
|
var subject = Object(Symbol('s'));
|
|
|
|
|
|
|
|
assert.throws(TypeError, function() {
|
|
|
|
Symbol.keyFor(subject);
|
|
|
|
}, 'symbol object');
|