diff --git a/test/parallel/test-buffer-writedouble.js b/test/parallel/test-buffer-writedouble.js index 0dc26dbd3b23f1..8a17d536909dce 100644 --- a/test/parallel/test-buffer-writedouble.js +++ b/test/parallel/test-buffer-writedouble.js @@ -67,10 +67,19 @@ assert.strictEqual(buffer.readDoubleLE(8), -Infinity); buffer.writeDoubleBE(NaN, 0); buffer.writeDoubleLE(NaN, 8); -assert.ok(buffer.equals(new Uint8Array([ - 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x7F -]))); +// JS only knows a single NaN but there exist two platform specific +// implementations. Therefore, allow both quiet and signalling NaNs. +if (buffer[1] === 0xF7) { + assert.ok(buffer.equals(new Uint8Array([ + 0x7F, 0xF7, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, + 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xF7, 0x7F + ]))); +} else { + assert.ok(buffer.equals(new Uint8Array([ + 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xF8, 0x7F + ]))); +} assert.ok(Number.isNaN(buffer.readDoubleBE(0))); assert.ok(Number.isNaN(buffer.readDoubleLE(8))); diff --git a/test/parallel/test-buffer-writefloat.js b/test/parallel/test-buffer-writefloat.js index 77dd4793e5e749..4c2c7539eaafcb 100644 --- a/test/parallel/test-buffer-writefloat.js +++ b/test/parallel/test-buffer-writefloat.js @@ -50,8 +50,18 @@ assert.strictEqual(buffer.readFloatLE(4), -Infinity); buffer.writeFloatBE(NaN, 0); buffer.writeFloatLE(NaN, 4); -assert.ok(buffer.equals( - new Uint8Array([ 0x7F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x7F ]))); + +// JS only knows a single NaN but there exist two platform specific +// implementations. Therefore, allow both quiet and signalling NaNs. +if (buffer[1] === 0xBF) { + assert.ok( + buffer.equals(new Uint8Array( + [ 0x7F, 0xBF, 0xFF, 0xFF, 0xFF, 0xFF, 0xBF, 0x7F ]))); +} else { + assert.ok( + buffer.equals(new Uint8Array( + [ 0x7F, 0xC0, 0x00, 0x00, 0x00, 0x00, 0xC0, 0x7F ]))); +} assert.ok(Number.isNaN(buffer.readFloatBE(0))); assert.ok(Number.isNaN(buffer.readFloatLE(4)));