1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 05:27:43 +00:00

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
3 changed files with 10 additions and 0 deletions

View file

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

View file

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