Skip to content

Commit 92bc11f

Browse files
committed
A test of of Value::IsWasmMemoryObject().
1 parent ae683da commit 92bc11f

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

graal-nodejs/test/graal/unit/value.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,12 @@ EXPORT_TO_JS(IsName) {
269269
args.GetReturnValue().Set(args[0]->IsName());
270270
}
271271

272+
// Value::IsWasmMemoryObject
273+
274+
EXPORT_TO_JS(IsWasmMemoryObject) {
275+
args.GetReturnValue().Set(args[0]->IsWasmMemoryObject());
276+
}
277+
272278
//more tests for Value::IsExternal in external.cc
273279

274280
// Value::IsNativeError

graal-nodejs/test/graal/unit/value.js

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -545,6 +545,27 @@ describe('Value - Is*()', function () {
545545
assert.strictEqual(module.Value_IsName(42), false);
546546
});
547547
});
548+
describe('IsWasmMemoryObject', function () {
549+
it('should return false for undefined', function () {
550+
assert.strictEqual(module.Value_IsWasmMemoryObject(undefined), false);
551+
});
552+
it('should return false for an ordinary object', function () {
553+
assert.strictEqual(module.Value_IsWasmMemoryObject({}), false);
554+
});
555+
if (typeof WebAssembly !== 'undefined') {
556+
it('should return false for WebAssembly object', function () {
557+
assert.strictEqual(module.Value_IsWasmMemoryObject(WebAssembly), false);
558+
});
559+
it('should return true for WebAssembly.Memory object', function () {
560+
let memory = new WebAssembly.Memory({ initial: 1 });
561+
assert.strictEqual(module.Value_IsWasmMemoryObject(memory), true);
562+
});
563+
it('should return false for WebAssembly.Global object', function () {
564+
let wasmGlobal = new WebAssembly.Global({ value: 'i32' });
565+
assert.strictEqual(module.Value_IsWasmMemoryObject(wasmGlobal), false);
566+
});
567+
}
568+
});
548569
});
549570

550571
describe('Value - *Value()', function () {

0 commit comments

Comments
 (0)