-
Notifications
You must be signed in to change notification settings - Fork 464
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* typeCoercion.js supports ToIndex * typeCoercion.js supports ToBigInt * updated BigInt.asIntN type coercion tests to use typeCoercion.js
- Loading branch information
Josh Wolfe
committed
Sep 13, 2017
1 parent
765f273
commit dafde72
Showing
10 changed files
with
385 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
// Copyright (C) 2017 Josh Wolfe. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: pending | ||
description: BigInt.asUintN arithmetic test cases | ||
info: > | ||
BigInt.asUintN ( bits, bigint ) | ||
3. Return a BigInt representing bigint modulo 2**bits. | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert.sameValue(BigInt.asUintN(0, -2n), 0n); | ||
assert.sameValue(BigInt.asUintN(0, -1n), 0n); | ||
assert.sameValue(BigInt.asUintN(0, 0n), 0n); | ||
assert.sameValue(BigInt.asUintN(0, 1n), 0n); | ||
assert.sameValue(BigInt.asUintN(0, 2n), 0n); | ||
|
||
assert.sameValue(BigInt.asUintN(1, -3n), 1n); | ||
assert.sameValue(BigInt.asUintN(1, -2n), 0n); | ||
assert.sameValue(BigInt.asUintN(1, -1n), 1n); | ||
assert.sameValue(BigInt.asUintN(1, 0n), 0n); | ||
assert.sameValue(BigInt.asUintN(1, 1n), 1n); | ||
assert.sameValue(BigInt.asUintN(1, 2n), 0n); | ||
assert.sameValue(BigInt.asUintN(1, 3n), 1n); | ||
assert.sameValue(BigInt.asUintN(1, -123456789012345678901n), 1n); | ||
assert.sameValue(BigInt.asUintN(1, -123456789012345678900n), 0n); | ||
assert.sameValue(BigInt.asUintN(1, 123456789012345678900n), 0n); | ||
assert.sameValue(BigInt.asUintN(1, 123456789012345678901n), 1n); | ||
|
||
assert.sameValue(BigInt.asUintN(2, -3n), 1n); | ||
assert.sameValue(BigInt.asUintN(2, -2n), 2n); | ||
assert.sameValue(BigInt.asUintN(2, -1n), 3n); | ||
assert.sameValue(BigInt.asUintN(2, 0n), 0n); | ||
assert.sameValue(BigInt.asUintN(2, 1n), 1n); | ||
assert.sameValue(BigInt.asUintN(2, 2n), 2n); | ||
assert.sameValue(BigInt.asUintN(2, 3n), 3n); | ||
assert.sameValue(BigInt.asUintN(2, -123456789012345678901n), 3n); | ||
assert.sameValue(BigInt.asUintN(2, -123456789012345678900n), 0n); | ||
assert.sameValue(BigInt.asUintN(2, 123456789012345678900n), 0n); | ||
assert.sameValue(BigInt.asUintN(2, 123456789012345678901n), 1n); | ||
|
||
assert.sameValue(BigInt.asUintN(8, 0xabn), 0xabn); | ||
assert.sameValue(BigInt.asUintN(8, 0xabcdn), 0xcdn); | ||
assert.sameValue(BigInt.asUintN(8, 0xabcdef01n), 0x01n); | ||
assert.sameValue(BigInt.asUintN(8, 0xabcdef0123456789abcdef0123n), 0x23n); | ||
assert.sameValue(BigInt.asUintN(8, 0xabcdef0123456789abcdef0183n), 0x83n); | ||
|
||
assert.sameValue(BigInt.asUintN(64, 0xabcdef0123456789abcdefn), 0x0123456789abcdefn); | ||
assert.sameValue(BigInt.asUintN(65, 0xabcdef0123456789abcdefn), 0x10123456789abcdefn); | ||
|
||
assert.sameValue(BigInt.asUintN(200, | ||
0xbffffffffffffffffffffffffffffffffffffffffffffffffffn), | ||
0x0ffffffffffffffffffffffffffffffffffffffffffffffffffn | ||
); | ||
assert.sameValue(BigInt.asUintN(201, | ||
0xbffffffffffffffffffffffffffffffffffffffffffffffffffn), | ||
0x1ffffffffffffffffffffffffffffffffffffffffffffffffffn | ||
); | ||
|
||
assert.sameValue(BigInt.asUintN(200, | ||
0xb89e081df68b65fedb32cffea660e55df9605650a603ad5fc54n), | ||
0x089e081df68b65fedb32cffea660e55df9605650a603ad5fc54n | ||
); | ||
assert.sameValue(BigInt.asUintN(201, | ||
0xb89e081df68b65fedb32cffea660e55df9605650a603ad5fc54n), | ||
0x189e081df68b65fedb32cffea660e55df9605650a603ad5fc54n | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// Copyright (C) 2017 Josh Wolfe. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: pending | ||
description: BigInt.asUintN property descriptor | ||
info: > | ||
BigInt.asUintN ( bits, bigint ) | ||
17 ECMAScript Standard Built-in Objects | ||
includes: [propertyHelper.js] | ||
features: [BigInt] | ||
---*/ | ||
|
||
assert.sameValue(typeof BigInt.asUintN, 'function'); | ||
|
||
verifyProperty(BigInt, "asUintN", { | ||
enumerable: false, | ||
writable: true, | ||
configurable: true | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// Copyright (C) 2017 Josh Wolfe. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: pending | ||
description: BigInt.asUintN type coercion for bigint parameter | ||
info: > | ||
BigInt.asUintN ( bits, bigint ) | ||
2. Let bigint ? ToBigInt(bigint). | ||
features: [BigInt, Symbol, Symbol.toPrimitive] | ||
includes: [typeCoercion.js] | ||
---*/ | ||
|
||
testCoercibleToBigIntZero(function(zero) { | ||
assert.sameValue(BigInt.asUintN(2, zero), 0n); | ||
}); | ||
|
||
testCoercibleToBigIntOne(function(one) { | ||
assert.sameValue(BigInt.asUintN(2, one), 1n); | ||
}); | ||
|
||
testCoercibleToBigIntFromBigInt(10n, function(ten) { | ||
assert.sameValue(BigInt.asUintN(3, ten), 2n); | ||
}); | ||
|
||
testCoercibleToBigIntFromBigInt(12345678901234567890003n, function(value) { | ||
assert.sameValue(BigInt.asUintN(4, value), 3n); | ||
}); | ||
|
||
testNotCoercibleToBigInt(function(error, value) { | ||
assert.throws(error, function() { BigInt.asUintN(0, value); }); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Copyright (C) 2017 Josh Wolfe. All rights reserved. | ||
// This code is governed by the BSD license found in the LICENSE file. | ||
/*--- | ||
esid: pending | ||
description: BigInt.asUintN type coercion for bits parameter | ||
info: > | ||
BigInt.asUintN ( bits, bigint ) | ||
1. Let bits be ? ToIndex(bits). | ||
features: [BigInt, Symbol, Symbol.toPrimitive] | ||
includes: [typeCoercion.js] | ||
---*/ | ||
|
||
testCoercibleToIndexZero(function(zero) { | ||
assert.sameValue(BigInt.asUintN(zero, 1n), 0n); | ||
}); | ||
|
||
testCoercibleToIndexOne(function(one) { | ||
assert.sameValue(BigInt.asUintN(one, 1n), 0n); | ||
}); | ||
|
||
testCoercibleToIndexFromIndex(3, function(three) { | ||
assert.sameValue(BigInt.asUintN(three, 10n), 2n); | ||
}); | ||
|
||
testNotCoercibleToIndex(function(error, value) { | ||
assert.throws(error, function() { BigInt.asUintN(value, 0n); }); | ||
}); |
Oops, something went wrong.