node/deps/v8/test/mjsunit/asm/regress-1027595.js
Matheus Marchini 2883c855e0
deps: update V8 to 8.1.307.20
PR-URL: https://github.com/nodejs/node/pull/32116
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Jiawen Geng <technicalcute@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2020-03-18 16:23:22 -07:00

45 lines
1.3 KiB
JavaScript

// Copyright 2019 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
(function TestF32StoreConvertsF64ToF32() {
function Module(stdlib, foreign, heap) {
'use asm';
var f32 = new stdlib.Float32Array(heap);
function f(a) {
a = +a;
f32[0] = f32[1] = a;
}
return f;
}
var buffer = new ArrayBuffer(0x10000);
var f = Module(this, {}, buffer);
assertDoesNotThrow(() => f(23.42));
var view = new Float32Array(buffer);
assertEquals(Math.fround(23.42), view[0]);
assertEquals(Math.fround(23.42), view[1]);
assertTrue(%IsAsmWasmCode(Module));
})();
(function TestF64StoreConvertsF32ToF64() {
function Module(stdlib, foreign, heap) {
'use asm';
var fround = stdlib.Math.fround;
var f64 = new stdlib.Float64Array(heap);
function f(a) {
a = fround(a);
f64[0] = f64[1] = a;
}
return f;
}
var buffer = new ArrayBuffer(0x10000);
var f = Module(this, {}, buffer);
assertDoesNotThrow(() => f(23.42));
var view = new Float64Array(buffer);
assertEquals(Math.fround(23.42), view[0]);
assertEquals(Math.fround(23.42), view[1]);
assertTrue(%IsAsmWasmCode(Module));
})();