From 5e7d9047b621a56afba4d9ce1da38648bd545d85 Mon Sep 17 00:00:00 2001 From: Steven Date: Sun, 9 Nov 2025 15:52:32 -0500 Subject: [PATCH] [import-bytes] add initial tests for import bytes proposal --- features.txt | 4 + .../import-bytes/bytes-from-empty-FIXTURE.bin | 0 .../import/import-bytes/bytes-from-empty.js | 27 +++++ .../import-bytes/bytes-from-png-FIXTURE.png | Bin 0 -> 67 bytes .../import/import-bytes/bytes-from-png.js | 98 ++++++++++++++++++ .../import-bytes/bytes-from-txt-FIXTURE.txt | 1 + .../import/import-bytes/bytes-from-txt.js | 44 ++++++++ 7 files changed, 174 insertions(+) create mode 100644 test/language/import/import-bytes/bytes-from-empty-FIXTURE.bin create mode 100644 test/language/import/import-bytes/bytes-from-empty.js create mode 100644 test/language/import/import-bytes/bytes-from-png-FIXTURE.png create mode 100644 test/language/import/import-bytes/bytes-from-png.js create mode 100644 test/language/import/import-bytes/bytes-from-txt-FIXTURE.txt create mode 100644 test/language/import/import-bytes/bytes-from-txt.js diff --git a/features.txt b/features.txt index f48d5412c32..d24e6e33290 100644 --- a/features.txt +++ b/features.txt @@ -84,6 +84,10 @@ upsert # https://github.com/tc39/proposal-immutable-arraybuffer immutable-arraybuffer +# Import Bytes +# https://github.com/tc39/proposal-import-bytes +import-bytes + # Non-extensible Applies to Private # https://github.com/tc39/proposal-nonextensible-applies-to-private nonextensible-applies-to-private diff --git a/test/language/import/import-bytes/bytes-from-empty-FIXTURE.bin b/test/language/import/import-bytes/bytes-from-empty-FIXTURE.bin new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/language/import/import-bytes/bytes-from-empty.js b/test/language/import/import-bytes/bytes-from-empty.js new file mode 100644 index 00000000000..61c61438991 --- /dev/null +++ b/test/language/import/import-bytes/bytes-from-empty.js @@ -0,0 +1,27 @@ +// Copyright (C) 2021 the V8 project authors. All rights reserved. +// This code is governed by the BSD license found in the LICENSE file. +/*--- +esid: sec-create-bytes-module +description: Creates bytes module from txt file +flags: [module] +features: [import-attributes, immutable-arraybuffer, import-bytes] +includes: [compareArray.js] +---*/ + +import value from './bytes-from-empty-FIXTURE.bin' with { type: 'bytes' }; + +assert(value instanceof Uint8Array); +assert(value.buffer instanceof ArrayBuffer); + +assert.sameValue(value.length, 0); +assert.sameValue(value.buffer.byteLength, 0); + +assert.compareArray(Array.from(value), []); + +assert.throws(TypeError, function() { + value.buffer.resize(0); +}); + +assert.throws(TypeError, function() { + value.buffer.transfer(); +}); diff --git a/test/language/import/import-bytes/bytes-from-png-FIXTURE.png b/test/language/import/import-bytes/bytes-from-png-FIXTURE.png new file mode 100644 index 0000000000000000000000000000000000000000..252d9502d8573d033e633f5e377d81bebf8afd36 GIT binary patch literal 67 zcmeAS@N?(olHy`uVBq!ia0vp^j35jm7|ip2ssJf2PZ!6K3dZCFAe)JSvAC2`0?1