LibJS: Add TypedArray.BYTES_PER_ELEMENT

This commit is contained in:
Linus Groh 2020-12-02 09:58:48 +00:00 committed by Andreas Kling
parent bb6bc70c5b
commit ddaab598a7
Notes: sideshowbarker 2024-07-19 01:06:11 +09:00
3 changed files with 10 additions and 0 deletions

View file

@ -32,6 +32,7 @@
namespace JS {
#define ENUMERATE_STANDARD_PROPERTY_NAMES(P) \
P(BYTES_PER_ELEMENT) \
P(BigInt) \
P(Boolean) \
P(E) \

View file

@ -65,6 +65,7 @@ namespace JS {
NativeFunction::initialize(global_object); \
define_property(vm.names.prototype, global_object.snake_name##_prototype(), 0); \
define_property(vm.names.length, Value(1), Attribute::Configurable); \
define_property(vm.names.BYTES_PER_ELEMENT, Value((i32)sizeof(Type)), 0); \
} \
Value ConstructorName::call() \
{ \

View file

@ -0,0 +1,8 @@
test("basic functionality", () => {
expect(Uint8Array.BYTES_PER_ELEMENT).toBe(1);
expect(Uint16Array.BYTES_PER_ELEMENT).toBe(2);
expect(Uint32Array.BYTES_PER_ELEMENT).toBe(4);
expect(Int8Array.BYTES_PER_ELEMENT).toBe(1);
expect(Int16Array.BYTES_PER_ELEMENT).toBe(2);
expect(Int32Array.BYTES_PER_ELEMENT).toBe(4);
});