Extend Number tests to assert abrupt completions

This commit is contained in:
Leonardo Balter 2016-06-21 13:38:20 -04:00 committed by Mike Pennisi
parent 9223f56344
commit 4dd7e5aa4b
3 changed files with 69 additions and 28 deletions

View 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");

View 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");

View File

@ -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')]);
});