Debian Codegraph @

js/src/jit-test/tests/ctypes/incompatible-pointer.js

raw
1 load(libdir + 'asserts.js');
2
3 function test() {
4 assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).isNull.call(1); },
5 "PointerType.prototype.isNull called on incompatible object, got the number 1");
6 assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).isNull.call({}); },
7 "PointerType.prototype.isNull called on incompatible object, got the object ({})");
8 assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).increment.call(1); },
9 "PointerType.prototype.increment called on incompatible object, got the number 1");
10 assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).increment.call(ctypes.int32_t(0)); },
11 "PointerType.prototype.increment called on non-PointerType CData, got ctypes.int32_t(0)");
12 assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).decrement.call(1); },
13 "PointerType.prototype.decrement called on incompatible object, got the number 1");
14 assertTypeErrorMessage(() => { ctypes.int32_t.ptr(0).decrement.call(ctypes.int32_t(0)); },
15 "PointerType.prototype.decrement called on non-PointerType CData, got ctypes.int32_t(0)");
16 }
17
18 if (typeof ctypes === "object")
19 test();