From 435dcc9f6ec07f4d63bea6492acdd150e68b46c5 Mon Sep 17 00:00:00 2001 From: Kevin Gibbons Date: Tue, 12 Mar 2024 11:34:59 -0700 Subject: [PATCH] tests for Math.f16round --- features.txt | 4 +++ test/built-ins/Math/f16round/length.js | 17 +++++++++++++ test/built-ins/Math/f16round/name.js | 17 +++++++++++++ .../Math/f16round/not-a-constructor.js | 17 +++++++++++++ test/built-ins/Math/f16round/prop-desc.js | 14 +++++++++++ .../Math/f16round/value-convertion.js | 25 +++++++++++++++++++ 6 files changed, 94 insertions(+) create mode 100644 test/built-ins/Math/f16round/length.js create mode 100644 test/built-ins/Math/f16round/name.js create mode 100644 test/built-ins/Math/f16round/not-a-constructor.js create mode 100644 test/built-ins/Math/f16round/prop-desc.js create mode 100644 test/built-ins/Math/f16round/value-convertion.js diff --git a/features.txt b/features.txt index 9b55d6a523..53d7f99485 100644 --- a/features.txt +++ b/features.txt @@ -113,6 +113,10 @@ set-methods # https://github.com/tc39/proposal-explicit-resource-management explicit-resource-management +# Float16Array + Math.f16round +# https://github.com/tc39/proposal-float16array +Float16Array + ## Standard language features # # Language features that have been included in a published version of the diff --git a/test/built-ins/Math/f16round/length.js b/test/built-ins/Math/f16round/length.js new file mode 100644 index 0000000000..f3ca88c4ba --- /dev/null +++ b/test/built-ins/Math/f16round/length.js @@ -0,0 +1,17 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-math.f16round +description: > + Math.f16round.length is 1 +features: [Float16Array] +includes: [propertyHelper.js] +---*/ + +verifyProperty(Math.f16round, 'length', { + value: 1, + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/built-ins/Math/f16round/name.js b/test/built-ins/Math/f16round/name.js new file mode 100644 index 0000000000..606210f12a --- /dev/null +++ b/test/built-ins/Math/f16round/name.js @@ -0,0 +1,17 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-math.f16round +description: > + Math.f16round.name is "f16round" +features: [Float16Array] +includes: [propertyHelper.js] +---*/ + +verifyProperty(Math.f16round, 'name', { + value: 'f16round', + enumerable: false, + writable: false, + configurable: true +}); diff --git a/test/built-ins/Math/f16round/not-a-constructor.js b/test/built-ins/Math/f16round/not-a-constructor.js new file mode 100644 index 0000000000..4d9cb369cc --- /dev/null +++ b/test/built-ins/Math/f16round/not-a-constructor.js @@ -0,0 +1,17 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-ecmascript-standard-built-in-objects +description: > + Math.f16round does not implement [[Construct]], is not new-able +features: [Float16Array] +includes: [isConstructor.js] +features: [Reflect.construct] +---*/ + +assert(!isConstructor(Math.f16round), "Math.f16round is not a constructor"); + +assert.throws(TypeError, function () { + new Math.fround(); +}); diff --git a/test/built-ins/Math/f16round/prop-desc.js b/test/built-ins/Math/f16round/prop-desc.js new file mode 100644 index 0000000000..10f94d06bd --- /dev/null +++ b/test/built-ins/Math/f16round/prop-desc.js @@ -0,0 +1,14 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-math.f16round +description: > + "f16round" property of Math +features: [Float16Array] +includes: [propertyHelper.js] +---*/ + +verifyNotEnumerable(Math, "f16round"); +verifyWritable(Math, "f16round"); +verifyConfigurable(Math, "f16round"); diff --git a/test/built-ins/Math/f16round/value-convertion.js b/test/built-ins/Math/f16round/value-convertion.js new file mode 100644 index 0000000000..c13b77a05f --- /dev/null +++ b/test/built-ins/Math/f16round/value-convertion.js @@ -0,0 +1,25 @@ +// Copyright (C) 2024 Kevin Gibbons. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. + +/*--- +esid: sec-math.f16round +description: > + Convert to binary16 format and than to binary64 format +features: [Float16Array] +includes: [byteConversionValues.js] +---*/ + +var values = byteConversionValues.values; +var expectedValues = byteConversionValues.expected.Float16; + +values.forEach(function(value, i) { + var expected = expectedValues[i]; + + var result = Math.f16round(value); + + assert.sameValue( + result, + expected, + "value: " + value + ); +});