mirror of
https://github.com/tc39/test262.git
synced 2025-07-25 23:14:47 +02:00
Extend Number tests to assert abrupt completions
This commit is contained in:
parent
9223f56344
commit
4dd7e5aa4b
26
test/built-ins/Number/return-abrupt-tonumber-value-symbol.js
Normal file
26
test/built-ins/Number/return-abrupt-tonumber-value-symbol.js
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
// Copyright (C) 2013 the V8 project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
es6id: 20.1.1.1
|
||||||
|
esid: sec-number-constructor-number-value
|
||||||
|
description: >
|
||||||
|
Return abrupt from ToNumber(value)
|
||||||
|
info: |
|
||||||
|
Number ( value )
|
||||||
|
|
||||||
|
1. If no arguments were passed to this function invocation, let n be +0.
|
||||||
|
2. Else, let n be ? ToNumber(value).
|
||||||
|
[...]
|
||||||
|
features: [Symbol]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var s = Symbol("66");
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
Number(s);
|
||||||
|
}, "NewTarget is undefined");
|
||||||
|
|
||||||
|
assert.throws(TypeError, function() {
|
||||||
|
new Number(s);
|
||||||
|
}, "NewTarget is defined");
|
43
test/built-ins/Number/return-abrupt-tonumber-value.js
Normal file
43
test/built-ins/Number/return-abrupt-tonumber-value.js
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
// Copyright (C) 2016 The V8 Project authors. All rights reserved.
|
||||||
|
// This code is governed by the BSD license found in the LICENSE file.
|
||||||
|
|
||||||
|
/*---
|
||||||
|
es6id: 20.1.1.1
|
||||||
|
esid: sec-number-constructor-number-value
|
||||||
|
description: >
|
||||||
|
Return abrupt from ToNumber(value)
|
||||||
|
info: |
|
||||||
|
Number ( value )
|
||||||
|
|
||||||
|
1. If no arguments were passed to this function invocation, let n be +0.
|
||||||
|
2. Else, let n be ? ToNumber(value).
|
||||||
|
[...]
|
||||||
|
---*/
|
||||||
|
|
||||||
|
var obj1 = {
|
||||||
|
valueOf: function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var obj2 = {
|
||||||
|
toString: function() {
|
||||||
|
throw new Test262Error();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Number(obj1);
|
||||||
|
}, "NewTarget is undefined, {}.valueOf");
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
Number(obj2);
|
||||||
|
}, "NewTarget is undefined, {}.toString");
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
new Number(obj1);
|
||||||
|
}, "NewTarget is defined, {}.valueOf");
|
||||||
|
|
||||||
|
assert.throws(Test262Error, function() {
|
||||||
|
new Number(obj2);
|
||||||
|
}, "NewTarget is defined, {}.toString");
|
@ -1,28 +0,0 @@
|
|||||||
// Copyright (C) 2013 the V8 project authors. All rights reserved.
|
|
||||||
// This code is governed by the BSD license found in the LICENSE file.
|
|
||||||
/*---
|
|
||||||
es6id: 7.1.3
|
|
||||||
description: >
|
|
||||||
Number coercion operations on Symbols
|
|
||||||
---*/
|
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
Number(Symbol('66'));
|
|
||||||
});
|
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
Symbol('66') + 0;
|
|
||||||
});
|
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
+Symbol('66');
|
|
||||||
});
|
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
Symbol('66') >> 0;
|
|
||||||
});
|
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
Symbol('66') >>> 0;
|
|
||||||
});
|
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
Symbol('66') | 0;
|
|
||||||
});
|
|
||||||
assert.throws(TypeError, function() {
|
|
||||||
new Uint16Array([Symbol('66')]);
|
|
||||||
});
|
|
Loading…
x
Reference in New Issue
Block a user