Skip to content

Commit 6d1aa6c

Browse files
committed
test: add SharedArrayBuffer to value_type_cast
1 parent f861d36 commit 6d1aa6c

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

test/value_type_cast.cc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ namespace {
2727
#define V(Type) \
2828
void TypeCast##Type(const CallbackInfo& info) { USE(info[0].As<Type>()); }
2929
TYPE_CAST_TYPES(V)
30+
31+
#ifdef NODE_API_EXPERIMENTAL_HAS_SHAREDARRAYBUFFER
32+
V(SharedArrayBuffer)
33+
#endif
34+
3035
#undef V
3136

3237
void TypeCastBuffer(const CallbackInfo& info) {
@@ -47,6 +52,11 @@ Object InitValueTypeCast(Env env, Object exports) {
4752

4853
#define V(Type) exports["typeCast" #Type] = Function::New(env, TypeCast##Type);
4954
TYPE_CAST_TYPES(V)
55+
56+
#ifdef NODE_API_EXPERIMENTAL_HAS_SHAREDARRAYBUFFER
57+
V(SharedArrayBuffer)
58+
#endif
59+
5060
#undef V
5161

5262
exports["typeCastBuffer"] = Function::New(env, TypeCastBuffer);

test/value_type_cast.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ function test (buildType) {
4242
},
4343
typeCastArrayBuffer: {
4444
positiveValues: [new ArrayBuffer(0)],
45-
negativeValues: [new Uint8Array(1), {}, [], null, undefined]
45+
negativeValues: [new Uint8Array(1), new SharedArrayBuffer(0), {}, [], null, undefined]
4646
},
4747
typeCastTypedArray: {
4848
positiveValues: [new Uint8Array(0)],
@@ -77,6 +77,13 @@ function test (buildType) {
7777
}
7878
};
7979

80+
if ('typeCastSharedArrayBuffer' in binding) {
81+
testTable.typeCastSharedArrayBuffer = {
82+
positiveValues: [new SharedArrayBuffer(0)],
83+
negativeValues: [new Uint8Array(1), new ArrayBuffer(0), {}, [], null, undefined]
84+
};
85+
}
86+
8087
if (process.argv[2] === 'child') {
8188
child(binding, testTable, process.argv[3], process.argv[4], parseInt(process.argv[5]));
8289
return;

0 commit comments

Comments
 (0)