Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Empty file.
27 changes: 27 additions & 0 deletions test/language/import/import-bytes/bytes-from-empty.js
Original file line number Diff line number Diff line change
@@ -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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there should be some kind of assertion that it's immutable (not sure what that'd look like tho)

same throughout


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();
});
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
98 changes: 98 additions & 0 deletions test/language/import/import-bytes/bytes-from-png.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
// 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 png file
flags: [module]
features: [import-attributes, immutable-arraybuffer, import-bytes]
includes: [compareArray.js]
---*/

import value from './bytes-from-png-FIXTURE.png' with { type: 'bytes' };

assert(value instanceof Uint8Array);
assert(value.buffer instanceof ArrayBuffer);

assert.sameValue(value.length, 67);
assert.sameValue(value.buffer.byteLength, 67);

assert.compareArray(
Array.from(value),
[
0x89,
0x50,
0x4e,
0x47,
0xd,
0xa,
0x1a,
0xa,
0x0,
0x0,
0x0,
0xd,
0x49,
0x48,
0x44,
0x52,
0x0,
0x0,
0x0,
0x1,
0x0,
0x0,
0x0,
0x1,
0x1,
0x0,
0x0,
0x0,
0x0,
0x37,
0x6e,
0xf9,
0x24,
0x0,
0x0,
0x0,
0xa,
0x49,
0x44,
0x41,
0x54,
0x78,
0x1,
0x63,
0x60,
0x0,
0x0,
0x0,
0x2,
0x0,
0x1,
0x73,
0x75,
0x1,
0x18,
0x0,
0x0,
0x0,
0x0,
0x49,
0x45,
0x4e,
0x44,
0xae,
0x42,
0x60,
0x82,
]
);

assert.throws(TypeError, function() {
value.buffer.resize(0);
});

assert.throws(TypeError, function() {
value.buffer.transfer();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Hello World!
44 changes: 44 additions & 0 deletions test/language/import/import-bytes/bytes-from-txt.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
// 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-txt-FIXTURE.txt' with { type: 'bytes' };

assert(value instanceof Uint8Array);
assert(value.buffer instanceof ArrayBuffer);

assert.sameValue(value.length, 13);
assert.sameValue(value.buffer.byteLength, 13);

assert.compareArray(
Array.from(value),
[
0x48, // H
0x65, // e
0x6c, // l
0x6c, // l
0x6f, // o
0x20, // (space)
0x57, // W
0x6f, // o
0x72, // r
0x6c, // l
0x64, // d
0x21, // !
0x0a, // (newline)
]
);

assert.throws(TypeError, function() {
value.buffer.resize(0);
});

assert.throws(TypeError, function() {
value.buffer.transfer();
});
Loading