MCPcopy Create free account
hub / github.com/nodejs/node / TestForeignFunctionMultipleUse

Function TestForeignFunctionMultipleUse

deps/v8/test/mjsunit/wasm/asm-wasm-imports.js:67–102  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

65
66
67function TestForeignFunctionMultipleUse() {
68 function AsmModule(stdlib, foreign, buffer) {
69 "use asm";
70
71 var getVal = foreign.getVal;
72
73 function caller(int_val, double_val) {
74 int_val = int_val|0;
75 double_val = +double_val;
76 if ((getVal()|0) == (int_val|0)) {
77 if ((+getVal()) == (+double_val)) {
78 return 89;
79 }
80 }
81 return 0;
82 }
83
84 return {caller:caller};
85 }
86
87 function ffi() {
88 function getVal() {
89 return 83.25;
90 }
91
92 return {getVal:getVal};
93 }
94
95 var foreign = new ffi();
96
97 var module_decl = eval('(' + AsmModule.toString() + ')');
98 var module = module_decl(stdlib, foreign, null);
99 assertValidAsm(module_decl);
100
101 assertEquals(89, module.caller(83, 83.25));
102}
103
104print("TestForeignFunctionMultipleUse...");
105TestForeignFunctionMultipleUse();

Callers 1

Calls 4

assertValidAsmFunction · 0.70
evalFunction · 0.50
assertEqualsFunction · 0.50
toStringMethod · 0.45

Tested by

no test coverage detected