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

Function DoTheTests

deps/v8/test/mjsunit/wasm/asm-wasm-expr.js:101–140  ·  view source on GitHub ↗
(expr, assign, stmt)

Source from the content-addressed store, hash-verified

99var test = 0;
100
101function DoTheTests(expr, assign, stmt) {
102 // ==== Expression assignment tests ========================================
103 for (let e of assign_in_expr) {
104 if (skip(++test)) continue;
105 var orig = e;
106 e = e.replace(/=/g, assign);
107 e = e.replace(/E/g, expr);
108 e = e.replace(/S/g, stmt);
109 var str = main.toString().replace("FUNC_BODY", "return (" + e + ") | 0;");
110 var asm_source = MODULE_TEMPLATE.toString().replace("FUNC_DECL", str);
111 doTest(asm_source, "(" + test + ") " + e);
112 }
113
114 // ==== Statement assignment tests =========================================
115 for (let e of assign_in_stmt) {
116 if (skip(++test)) continue;
117 var orig = e;
118 e = e.replace(/=/g, assign);
119 e = e.replace(/E/g, expr);
120 e = e.replace(/S/g, stmt);
121 var str = main.toString().replace("FUNC_BODY", e + "; return 0;");
122 var asm_source = MODULE_TEMPLATE.toString().replace("FUNC_DECL", str);
123 doTest(asm_source, "(" + test + ") " + e);
124 }
125
126 function doTest(asm_source, orig) {
127 var nonasm_source = asm_source.replace(new RegExp("use asm"), "");
128 print("Testing JS: " + orig);
129 var js_module = eval("(" + nonasm_source + ")")(stdlib, {}, buffer);
130 expect(js_module);
131
132 print("Testing ASMJS: " + orig);
133 var asmfunc = eval("(" + asm_source + ")");
134 var asm_module = asmfunc(stdlib, {}, buffer);
135 assertTrue(%IsAsmWasmCode(asmfunc));
136 expect(asm_module);
137 }
138
139 function expect(module) { module.main(0, 0, 0); print(" ok"); return true; }
140}
141
142DoTheTests("(i32 | 0)", "i32 = 0", "void_func()");
143DoTheTests("G", "G = 0", "void_func()");

Callers 1

asm-wasm-expr.jsFile · 0.85

Calls 3

skipFunction · 0.70
doTestFunction · 0.70
toStringMethod · 0.45

Tested by

no test coverage detected