Debian Codegraph @

js/src/jit-test/tests/basic/tagTempl.js

raw
1 /*
2 * Tests tagged template string functionality.
3 */
4
5 function check(actual, expected) {
6 assertEq(actual.length, expected.length);
7 for (var i = 0; i < expected.length; i++)
8 assertEq(actual[i], expected[i]);
9 }
10
11 function func(a) { return a; }
12
13 function csoLoop() {
14 var cso = [];
15 for (var index = 0; index < 2000; index++) {
16 cso[index] = func`hey${4}there`;
17 if (index > 0)
18 assertEq(cso[index - 1], cso[index]);
19 }
20 }
21
22 // Tests baseline and ion functionality.
23 csoLoop();
24
25 // Tests off thread compilation
26 if (helperThreadCount() !== 0) {
27 offThreadCompileToStencil("(x=>x)`abc`");
28 var stencil = finishOffThreadStencil();
29 a = evalStencil(stencil);
30 check(a, ["abc"]);
31 check(a.raw, ["abc"]);
32 assertEq(a === a.raw, false);
33 assertEq(Object.isFrozen(a), true);
34 assertEq(Object.isFrozen(a.raw), true);
35 }