Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
176 additions
and
0 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
1 change: 1 addition & 0 deletions
1
packages/core-js-pure/override/modules/esnext.data-view.get-float16.js
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 @@ | ||
// empty |
1 change: 1 addition & 0 deletions
1
packages/core-js-pure/override/modules/esnext.data-view.set-float16.js
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 @@ | ||
// empty |
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 |
---|---|---|
@@ -1,6 +1,8 @@ | ||
'use strict'; | ||
var parent = require('../../actual/data-view'); | ||
require('../../modules/esnext.data-view.get-float16'); | ||
require('../../modules/esnext.data-view.get-uint8-clamped'); | ||
require('../../modules/esnext.data-view.set-float16'); | ||
require('../../modules/esnext.data-view.set-uint8-clamped'); | ||
|
||
module.exports = parent; |
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,5 @@ | ||
'use strict'; | ||
require('../../modules/esnext.math.f16round'); | ||
var path = require('../../internals/path'); | ||
|
||
module.exports = path.Math.f16round; |
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,16 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var unpackIEEE754 = require('../internals/ieee754').unpack; | ||
|
||
// eslint-disable-next-line es/no-typed-arrays -- safe | ||
var getUint16 = uncurryThis(DataView.prototype.getUint16); | ||
|
||
// `DataView.prototype.getFloat16` method | ||
// https://github.com/tc39/proposal-float16array | ||
$({ target: 'DataView', proto: true, forced: true }, { | ||
getFloat16: function getFloat16(byteOffset /* , littleEndian */) { | ||
var uint16 = getUint16(this, byteOffset, arguments.length > 1 ? arguments[1] : false); | ||
return unpackIEEE754([uint16 & 0xFF, uint16 >> 8 & 0xFF], 10); | ||
} | ||
}); |
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 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var uncurryThis = require('../internals/function-uncurry-this'); | ||
var classof = require('../internals/classof'); | ||
var toIndex = require('../internals/to-index'); | ||
var packIEEE754 = require('../internals/ieee754').pack; | ||
|
||
var $TypeError = TypeError; | ||
// eslint-disable-next-line es/no-typed-arrays -- safe | ||
var setUint16 = uncurryThis(DataView.prototype.setUint16); | ||
|
||
// `DataView.prototype.setFloat16` method | ||
// https://github.com/tc39/proposal-float16array | ||
$({ target: 'DataView', proto: true, forced: true }, { | ||
setFloat16: function setFloat16(byteOffset, value /* , littleEndian */) { | ||
if (classof(this) !== 'DataView') throw $TypeError('Incorrect receiver'); | ||
var offset = toIndex(byteOffset); | ||
var bytes = packIEEE754(+value, 10, 2); | ||
return setUint16(this, offset, bytes[1] << 8 | bytes[0], arguments.length > 2 ? arguments[2] : false); | ||
} | ||
}); |
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,16 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var IEEE754 = require('../internals/ieee754'); | ||
|
||
var packIEEE754 = IEEE754.pack; | ||
var unpackIEEE754 = IEEE754.unpack; | ||
var $isFinite = isFinite; | ||
|
||
// `Math.f16round` method | ||
// https://github.com/tc39/proposal-float16array | ||
$({ target: 'Math', stat: true }, { | ||
f16round: function f16round(x) { | ||
var n = +x; | ||
return $isFinite(n) && n !== 0 ? unpackIEEE754(packIEEE754(n, 10, 2), 10) : n; | ||
} | ||
}); |
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,5 @@ | ||
'use strict'; | ||
// https://github.com/tc39/proposal-float16array | ||
require('../modules/esnext.data-view.get-float16'); | ||
require('../modules/esnext.data-view.set-float16'); | ||
require('../modules/esnext.math.f16round'); |
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,44 @@ | ||
// some asserts based on https://github.com/petamoriken/float16/blob/master/test/f16round.js | ||
import { createConversionChecker } from '../helpers/helpers'; | ||
|
||
const { MAX_VALUE, MIN_VALUE } = Number; | ||
|
||
QUnit.test('Math.f16round', assert => { | ||
const { f16round } = Math; | ||
assert.isFunction(f16round); | ||
assert.name(f16round, 'f16round'); | ||
assert.arity(f16round, 1); | ||
assert.looksNative(f16round); | ||
assert.nonEnumerable(Math, 'f16round'); | ||
assert.same(f16round(), NaN); | ||
assert.same(f16round(undefined), NaN); | ||
assert.same(f16round(NaN), NaN); | ||
assert.same(f16round(null), 0); | ||
assert.same(f16round(0), 0); | ||
assert.same(f16round(-0), -0); | ||
assert.same(f16round(MIN_VALUE), 0); | ||
assert.same(f16round(-MIN_VALUE), -0); | ||
assert.same(f16round(Infinity), Infinity); | ||
assert.same(f16round(-Infinity), -Infinity); | ||
assert.same(f16round(MAX_VALUE), Infinity); | ||
assert.same(f16round(-MAX_VALUE), -Infinity); | ||
|
||
const maxFloat16 = 65504; | ||
const minFloat16 = 2 ** -24; | ||
|
||
assert.same(f16round(maxFloat16), maxFloat16); | ||
assert.same(f16round(-maxFloat16), -maxFloat16); | ||
assert.same(f16round(minFloat16), minFloat16); | ||
assert.same(f16round(-minFloat16), -minFloat16); | ||
assert.same(f16round(minFloat16 / 2), 0); | ||
assert.same(f16round(-minFloat16 / 2), -0); | ||
assert.same(f16round(minFloat16 / 2 + 2 ** -25), minFloat16); | ||
assert.same(f16round(-minFloat16 / 2 - 2 ** -25), -minFloat16); | ||
|
||
assert.same(f16round(1.337), 1.3369140625); | ||
|
||
const checker = createConversionChecker(1.1); | ||
assert.same(f16round(checker), 1.099609375, 'object wrapper'); | ||
assert.same(checker.$valueOf, 1, 'valueOf calls'); | ||
assert.same(checker.$toString, 0, 'toString calls'); | ||
}); |
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,43 @@ | ||
// some asserts based on https://github.com/petamoriken/float16/blob/master/test/f16round.js | ||
import { createConversionChecker } from '../helpers/helpers'; | ||
|
||
import f16round from 'core-js-pure/full/math/f16round'; | ||
|
||
const { MAX_VALUE, MIN_VALUE } = Number; | ||
|
||
QUnit.test('Math.f16round', assert => { | ||
assert.isFunction(f16round); | ||
assert.name(f16round, 'f16round'); | ||
assert.arity(f16round, 1); | ||
assert.same(f16round(), NaN); | ||
assert.same(f16round(undefined), NaN); | ||
assert.same(f16round(NaN), NaN); | ||
assert.same(f16round(null), 0); | ||
assert.same(f16round(0), 0); | ||
assert.same(f16round(-0), -0); | ||
assert.same(f16round(MIN_VALUE), 0); | ||
assert.same(f16round(-MIN_VALUE), -0); | ||
assert.same(f16round(Infinity), Infinity); | ||
assert.same(f16round(-Infinity), -Infinity); | ||
assert.same(f16round(MAX_VALUE), Infinity); | ||
assert.same(f16round(-MAX_VALUE), -Infinity); | ||
|
||
const maxFloat16 = 65504; | ||
const minFloat16 = 2 ** -24; | ||
|
||
assert.same(f16round(maxFloat16), maxFloat16); | ||
assert.same(f16round(-maxFloat16), -maxFloat16); | ||
assert.same(f16round(minFloat16), minFloat16); | ||
assert.same(f16round(-minFloat16), -minFloat16); | ||
assert.same(f16round(minFloat16 / 2), 0); | ||
assert.same(f16round(-minFloat16 / 2), -0); | ||
assert.same(f16round(minFloat16 / 2 + 2 ** -25), minFloat16); | ||
assert.same(f16round(-minFloat16 / 2 - 2 ** -25), -minFloat16); | ||
|
||
assert.same(f16round(1.337), 1.3369140625); | ||
|
||
const checker = createConversionChecker(1.1); | ||
assert.same(f16round(checker), 1.099609375, 'object wrapper'); | ||
assert.same(checker.$valueOf, 1, 'valueOf calls'); | ||
assert.same(checker.$toString, 0, 'toString calls'); | ||
}); |