summaryrefslogtreecommitdiffstats
path: root/js/src/jit-test/tests/coverage
diff options
context:
space:
mode:
Diffstat (limited to 'js/src/jit-test/tests/coverage')
-rw-r--r--js/src/jit-test/tests/coverage/bug1203695.js15
-rw-r--r--js/src/jit-test/tests/coverage/bug1206247.js6
-rw-r--r--js/src/jit-test/tests/coverage/bug1214548.js12
-rw-r--r--js/src/jit-test/tests/coverage/bug1274048.js10
-rw-r--r--js/src/jit-test/tests/coverage/bug1304569-switch-case.js14
-rw-r--r--js/src/jit-test/tests/coverage/getLcovInfo_twice.js4
-rw-r--r--js/src/jit-test/tests/coverage/lcov-enabled-1.js5
-rw-r--r--js/src/jit-test/tests/coverage/lcov-enabled-2.js7
-rw-r--r--js/src/jit-test/tests/coverage/off-thread-01.js23
-rw-r--r--js/src/jit-test/tests/coverage/off-thread-02.js25
-rw-r--r--js/src/jit-test/tests/coverage/simple.js596
11 files changed, 717 insertions, 0 deletions
diff --git a/js/src/jit-test/tests/coverage/bug1203695.js b/js/src/jit-test/tests/coverage/bug1203695.js
new file mode 100644
index 0000000000..5a8a091d6a
--- /dev/null
+++ b/js/src/jit-test/tests/coverage/bug1203695.js
@@ -0,0 +1,15 @@
+// |jit-test| --code-coverage
+
+var lfcode = new Array();
+lfcode.push = loadFile;
+lfcode.push(")");
+lfcode.push(`
+assertThrowsInstanceOf(function () {}, TypeError);
+var g = newGlobal();
+`);
+getLcovInfo(g);
+function loadFile(lfVarx) {
+ try {
+ evaluate(lfVarx, { noScriptRval : true, compileAndGo : true });
+ } catch (lfVare) {}
+}
diff --git a/js/src/jit-test/tests/coverage/bug1206247.js b/js/src/jit-test/tests/coverage/bug1206247.js
new file mode 100644
index 0000000000..f6b954df76
--- /dev/null
+++ b/js/src/jit-test/tests/coverage/bug1206247.js
@@ -0,0 +1,6 @@
+// |jit-test| --code-coverage
+
+evaluate("", {
+ fileName: null
+});
+getLcovInfo();
diff --git a/js/src/jit-test/tests/coverage/bug1214548.js b/js/src/jit-test/tests/coverage/bug1214548.js
new file mode 100644
index 0000000000..b54cd80169
--- /dev/null
+++ b/js/src/jit-test/tests/coverage/bug1214548.js
@@ -0,0 +1,12 @@
+// |jit-test| --code-coverage
+
+if (!('oomTest' in this))
+ quit();
+
+oomTest(() => {
+ var g = newGlobal({sameZoneAs: this});
+ g.eval("\
+ function f(){}; \
+ getLcovInfo(); \
+ ");
+});
diff --git a/js/src/jit-test/tests/coverage/bug1274048.js b/js/src/jit-test/tests/coverage/bug1274048.js
new file mode 100644
index 0000000000..526a2c9142
--- /dev/null
+++ b/js/src/jit-test/tests/coverage/bug1274048.js
@@ -0,0 +1,10 @@
+// |jit-test| --code-coverage
+
+function h() {
+ return 1;
+}
+function g() {
+ switch (h()) {}
+}
+g();
+getLcovInfo();
diff --git a/js/src/jit-test/tests/coverage/bug1304569-switch-case.js b/js/src/jit-test/tests/coverage/bug1304569-switch-case.js
new file mode 100644
index 0000000000..d243c7fddc
--- /dev/null
+++ b/js/src/jit-test/tests/coverage/bug1304569-switch-case.js
@@ -0,0 +1,14 @@
+// |jit-test| --code-coverage
+
+s = newGlobal()
+evalcx("\
+ switch (0) {\
+ default: break;\
+ case 1:\
+ this.s += this.s;\
+ g(h(\"\", 2));\
+ break;\
+ break\
+ }\
+", s)
+evalcx("getLcovInfo()", s)
diff --git a/js/src/jit-test/tests/coverage/getLcovInfo_twice.js b/js/src/jit-test/tests/coverage/getLcovInfo_twice.js
new file mode 100644
index 0000000000..dd78513729
--- /dev/null
+++ b/js/src/jit-test/tests/coverage/getLcovInfo_twice.js
@@ -0,0 +1,4 @@
+// |jit-test| --code-coverage
+
+getLcovInfo();
+getLcovInfo();
diff --git a/js/src/jit-test/tests/coverage/lcov-enabled-1.js b/js/src/jit-test/tests/coverage/lcov-enabled-1.js
new file mode 100644
index 0000000000..0bbb53f2fe
--- /dev/null
+++ b/js/src/jit-test/tests/coverage/lcov-enabled-1.js
@@ -0,0 +1,5 @@
+// |jit-test| --code-coverage
+
+// Use the `--code-coverage` shell argument must enable JS code-coverage support
+// for the process.
+assertEq(isLcovEnabled(), true);
diff --git a/js/src/jit-test/tests/coverage/lcov-enabled-2.js b/js/src/jit-test/tests/coverage/lcov-enabled-2.js
new file mode 100644
index 0000000000..133d167e3d
--- /dev/null
+++ b/js/src/jit-test/tests/coverage/lcov-enabled-2.js
@@ -0,0 +1,7 @@
+
+// Setting the `JS_CODE_COVERAGE_OUTPUT_DIR` for will also enable coverage for
+// the process.
+
+if (os.getenv("JS_CODE_COVERAGE_OUTPUT_DIR")) {
+ assertEq(isLcovEnabled(), true);
+}
diff --git a/js/src/jit-test/tests/coverage/off-thread-01.js b/js/src/jit-test/tests/coverage/off-thread-01.js
new file mode 100644
index 0000000000..ab9172cf92
--- /dev/null
+++ b/js/src/jit-test/tests/coverage/off-thread-01.js
@@ -0,0 +1,23 @@
+// |jit-test| --code-coverage; --no-ion; skip-if: helperThreadCount() === 0
+
+assertEq(isLcovEnabled(), true);
+
+offThreadCompileToStencil(`
+ let hitCount = 0;
+ function offThreadFun() {
+ hitCount += 1;
+ }
+
+ offThreadFun();
+ offThreadFun();
+ offThreadFun();
+ offThreadFun();
+`);
+var stencil = finishOffThreadStencil();
+evalStencil(stencil);
+assertEq(hitCount, 4);
+
+let report = getLcovInfo();
+
+const expected = "FNDA:4,offThreadFun";
+assertEq(report.includes(expected), true);
diff --git a/js/src/jit-test/tests/coverage/off-thread-02.js b/js/src/jit-test/tests/coverage/off-thread-02.js
new file mode 100644
index 0000000000..18d43f9d0c
--- /dev/null
+++ b/js/src/jit-test/tests/coverage/off-thread-02.js
@@ -0,0 +1,25 @@
+// |jit-test| --code-coverage; --no-ion; skip-if: helperThreadCount() === 0
+
+assertEq(isLcovEnabled(), true);
+
+offThreadCompileModuleToStencil(`
+ globalThis.hitCount = 0;
+ function offThreadFun() {
+ globalThis.hitCount += 1;
+ }
+
+ offThreadFun();
+ offThreadFun();
+ offThreadFun();
+ offThreadFun();
+`);
+let stencil = finishOffThreadStencil();
+let mod = instantiateModuleStencil(stencil);
+moduleLink(mod);
+moduleEvaluate(mod);
+assertEq(hitCount, 4);
+
+const expected = "FNDA:4,offThreadFun";
+
+let report = getLcovInfo();
+assertEq(report.includes(expected), true);
diff --git a/js/src/jit-test/tests/coverage/simple.js b/js/src/jit-test/tests/coverage/simple.js
new file mode 100644
index 0000000000..cdb8197201
--- /dev/null
+++ b/js/src/jit-test/tests/coverage/simple.js
@@ -0,0 +1,596 @@
+// |jit-test| --code-coverage
+
+// Currently the Jit integration has a few issues, let's keep this test
+// case deterministic.
+//
+// - Baseline OSR increments the loop header twice.
+// - Ion is not updating any counter yet.
+//
+if (getJitCompilerOptions()["ion.warmup.trigger"] != 30)
+ setJitCompilerOption("ion.warmup.trigger", 30);
+if (getJitCompilerOptions()["baseline.warmup.trigger"] != 10)
+ setJitCompilerOption("baseline.warmup.trigger", 10);
+
+/*
+ * These test cases are annotated with the output produced by LCOV [1]. Comment
+ * starting with //<key> without any spaces are used as a reference for the code
+ * coverage output. Any "$" in these line comments are replaced by the current
+ * line number, and any "%" are replaced with the current function name (defined
+ * by the FN key).
+ *
+ * [1] http://ltp.sourceforge.net/coverage/lcov/geninfo.1.php
+ */
+function checkLcov(fun) {
+ var keys = [ "TN", "SF", "FN", "FNDA", "FNF", "FNH", "BRDA", "BRF", "BRH", "DA", "LF", "LH" ];
+ function startsWithKey(s) {
+ for (k of keys) {
+ if (s.startsWith(k))
+ return true;
+ }
+ return false;
+ };
+
+ // Extract the body of the function, as the code to be executed.
+ var source = fun.toString();
+ source = source.slice(source.indexOf('{') + 1, source.lastIndexOf('}'));
+
+ // Extract comment starting with the previous keys, as a reference of the
+ // output expected from getLcovInfo.
+ var lcovRef = [];
+ var currLine = 0;
+ var currFun = "<badfunction>";
+ for (var line of source.split('\n')) {
+ currLine++;
+ for (var comment of line.split("//").slice(1)) {
+ if (!startsWithKey(comment))
+ continue;
+ comment = comment.trim();
+ if (comment.startsWith("FN:"))
+ currFun = comment.split(',')[1];
+ comment = comment.replace('$', currLine);
+ comment = comment.replace('%', currFun);
+ lcovRef.push(comment);
+ }
+ }
+
+ // Evaluate the code, and generate the Lcov result from the execution.
+ // Enabling LCov disables lazy parsing, as we rely on the ZoneCellIter to
+ // emulate the behaviour of the finalizer.
+ var g = newGlobal();
+ g.eval(source);
+ var lcovResRaw = getLcovInfo(g);
+
+ // Check that all the lines are present the result.
+ var lcovRes = lcovResRaw.split('\n');
+ for (ref of lcovRef) {
+ if (lcovRes.indexOf(ref) == -1) {
+ print("Cannot find `" + ref + "` in the following Lcov result:\n", lcovResRaw);
+ print("In the following source:\n", source);
+ assertEq(true, false);
+ }
+ }
+}
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ ",".split(','); //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:1
+ //LH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ function f() { //FN:$,f
+ ",".split(','); //DA:$,0
+ }
+ ",".split(','); //DA:$,1
+ //FNF:2
+ //FNH:1
+ //LF:2
+ //LH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ function f() { //FN:$,f //FNDA:1,%
+ ",".split(','); //DA:$,1
+ }
+ f(); //DA:$,1
+ //FNF:2
+ //FNH:2
+ //LF:2
+ //LH:2
+});
+
+checkLcov(function () { ','.split(','); //FN:$,top-level //FNDA:1,% //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:1
+ //LH:1
+});
+
+checkLcov(function () { function f() { ','.split(','); } //FN:$,top-level //FNDA:1,% //FN:$,f //FNDA:1,f //DA:$,1
+ f(); //DA:$,1
+ //FNF:2
+ //FNH:2
+ //LF:2
+ //LH:2
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ if (l.length == 3) //DA:$,1 //BRDA:$,0,0,1 //BRDA:$,0,1,0
+ l.push(''); //DA:$,0
+ l.pop(); //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:4
+ //LH:3
+ //BRF:2
+ //BRH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ if (l.length == 2) //DA:$,1 //BRDA:$,0,0,0 //BRDA:$,0,1,1
+ l.push(''); //DA:$,1
+ l.pop(); //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:4
+ //LH:4
+ //BRF:2
+ //BRH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ if (l.length == 3) //DA:$,1 //BRDA:$,0,0,1 //BRDA:$,0,1,0
+ l.push(''); //DA:$,0
+ else
+ l.pop(); //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:4
+ //LH:3
+ //BRF:2
+ //BRH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ if (l.length == 2) //DA:$,1 //BRDA:$,0,0,0 //BRDA:$,0,1,1
+ l.push(''); //DA:$,1
+ else
+ l.pop(); //DA:$,0
+ //FNF:1
+ //FNH:1
+ //LF:4
+ //LH:3
+ //BRF:2
+ //BRH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ if (l.length == 2) //DA:$,1 //BRDA:$,0,0,0 //BRDA:$,0,1,1
+ l.push(''); //DA:$,1
+ else {
+ if (l.length == 1) //DA:$,0 //BRDA:$,1,0,- //BRDA:$,1,1,-
+ l.pop(); //DA:$,0
+ }
+ //FNF:1
+ //FNH:1
+ //LF:5
+ //LH:3
+ //BRF:4
+ //BRH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ function f(i) { //FN:$,f //FNDA:2,%
+ var x = 0; //DA:$,2
+ while (i--) { // Currently OSR wrongly count the loop header twice.
+ // So instead of DA:$,12 , we have DA:$,13 .
+ x += i; //DA:$,10
+ x = x / 2; //DA:$,10
+ }
+ return x; //DA:$,2
+ //BRF:2
+ //BRH:2
+ }
+
+ f(5); //DA:$,1
+ f(5); //DA:$,1
+ //FNF:2
+ //FNH:2
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ try { //DA:$,1
+ var l = ",".split(','); //DA:$,1
+ if (l.length == 2) { //DA:$,1 //BRDA:$,0,0,0 //BRDA:$,0,1,1
+ l.push(''); //DA:$,1
+ throw l; //DA:$,1
+ }
+ l.pop(); //DA:$,0
+ } catch (x) { //DA:$,1
+ x.pop(); //DA:$,1
+ }
+ //FNF:1
+ //FNH:1
+ //LF:8
+ //LH:7
+ //BRF:2
+ //BRH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ try { //DA:$,1
+ try { //DA:$,1
+ if (l.length == 2) { //DA:$,1 //BRDA:$,0,0,0 //BRDA:$,0,1,1
+ l.push(''); //DA:$,1
+ throw l; //DA:$,1
+ }
+ l.pop(); //DA:$,0
+ } finally { //DA:$,1
+ l.pop(); //DA:$,1
+ }
+ } catch (x) { //DA:$,1
+ }
+ //FNF:1
+ //FNH:1
+ //LF:10
+ //LH:9
+ //BRF:4
+ //BRH:2
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ function f() { //FN:$,f //FNDA:1,%
+ throw 1; //DA:$,1
+ f(); //DA:$,0
+ }
+ var l = ",".split(','); //DA:$,1
+ try { //DA:$,1
+ f(); //DA:$,1
+ f(); //DA:$,0
+ } catch (x) { //DA:$,1
+ }
+ //FNF:2
+ //FNH:2
+ //LF:7
+ //LH:5
+ //BRF:0
+ //BRH:0
+});
+
+// Test TableSwitch opcode
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ switch (l.length) { //DA:$,1 //BRDA:$,0,0,0 //BRDA:$,0,1,0 //BRDA:$,0,2,1 //BRDA:$,0,3,0 //BRDA:$,0,4,0
+ case 0:
+ l.push('0'); //DA:$,0
+ break;
+ case 1:
+ l.push('1'); //DA:$,0
+ break;
+ case 2:
+ l.push('2'); //DA:$,1
+ break;
+ case 3:
+ l.push('3'); //DA:$,0
+ break;
+ }
+ l.pop(); //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:7
+ //LH:4
+ //BRF:5
+ //BRH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ switch (l.length) { //DA:$,1 //BRDA:$,0,0,0 //BRDA:$,0,1,0 //BRDA:$,0,2,1 //BRDA:$,0,3,0 //BRDA:$,0,4,0
+ case 0:
+ l.push('0'); //DA:$,0
+ case 1:
+ l.push('1'); //DA:$,0
+ case 2:
+ l.push('2'); //DA:$,1
+ case 3:
+ l.push('3'); //DA:$,1
+ }
+ l.pop(); //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:7
+ //LH:5
+ //BRF:5
+ //BRH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ // Branches are ordered, and starting at 0
+ switch (l.length) { //DA:$,1 //BRDA:$,0,0,1 //BRDA:$,0,1,0 //BRDA:$,0,2,0 //BRDA:$,0,3,0 //BRDA:$,0,4,0
+ case 5:
+ l.push('5'); //DA:$,0
+ case 4:
+ l.push('4'); //DA:$,0
+ case 3:
+ l.push('3'); //DA:$,0
+ case 2:
+ l.push('2'); //DA:$,1
+ }
+ l.pop(); //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:7
+ //LH:4
+ //BRF:5
+ //BRH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ switch (l.length) { //DA:$,1 //BRDA:$,0,0,1 //BRDA:$,0,1,0 //BRDA:$,0,2,0
+ case 2:
+ l.push('2'); //DA:$,1
+ case 5:
+ l.push('5'); //DA:$,1
+ }
+ l.pop(); //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:5
+ //LH:5
+ //BRF:3
+ //BRH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ switch (l.length) { //DA:$,1 //BRDA:$,0,0,0 //BRDA:$,0,1,1 //BRDA:$,0,2,0
+ case 3:
+ l.push('1'); //DA:$,0
+ case 5:
+ l.push('5'); //DA:$,0
+ }
+ l.pop(); //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:5
+ //LH:3
+ //BRF:3
+ //BRH:1
+});
+
+// Unfortunately the differences between switch implementations leaks in the
+// code coverage reports.
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ function f(a) { //FN:$,f //FNDA:2,%
+ return a; //DA:$,2
+ }
+ var l = ",".split(','); //DA:$,1
+ switch (l.length) { //DA:$,1
+ case f(-42): //DA:$,1 //BRDA:$,0,0,0 //BRDA:$,0,1,1
+ l.push('1'); //DA:$,0
+ case f(51): //DA:$,1 //BRDA:$,1,0,0 //BRDA:$,1,1,1
+ l.push('5'); //DA:$,0
+ }
+ l.pop(); //DA:$,1
+ //FNF:2
+ //FNH:2
+ //LF:8
+ //LH:6
+ //BRF:4
+ //BRH:2
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ switch (l.length) { //DA:$,1 //BRDA:$,0,0,0 //BRDA:$,0,1,1 //BRDA:$,0,2,0 //BRDA:$,0,3,0
+ case 0:
+ case 1:
+ l.push('0'); //DA:$,0
+ l.push('1'); //DA:$,0
+ case 2:
+ l.push('2'); //DA:$,1
+ case 3:
+ l.push('3'); //DA:$,1
+ }
+ l.pop(); //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:7
+ //LH:5
+ //BRF:4
+ //BRH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ switch (l.length) { //DA:$,1 //BRDA:$,0,0,0 //BRDA:$,0,1,0 //BRDA:$,0,2,1 //BRDA:$,0,3,0
+ case 0:
+ l.push('0'); //DA:$,0
+ case 1:
+ l.push('1'); //DA:$,0
+ case 2:
+ case 3:
+ l.push('2'); //DA:$,1
+ l.push('3'); //DA:$,1
+ }
+ l.pop(); //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:7
+ //LH:5
+ //BRF:4
+ //BRH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ switch (l.length) { //DA:$,1 //BRDA:$,0,0,0 //BRDA:$,0,1,0 //BRDA:$,0,2,1 //BRDA:$,0,3,0
+ case 0:
+ l.push('0'); //DA:$,0
+ case 1:
+ default:
+ l.push('1'); //DA:$,0
+ case 2:
+ l.push('2'); //DA:$,1
+ case 3:
+ l.push('3'); //DA:$,1
+ }
+ l.pop(); //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:7
+ //LH:5
+ //BRF:4
+ //BRH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ switch (l.length) { //DA:$,1 //BRDA:$,0,0,0 //BRDA:$,0,1,0 //BRDA:$,0,2,1 //BRDA:$,0,3,0
+ case 0:
+ l.push('0'); //DA:$,0
+ case 1:
+ l.push('1'); //DA:$,0
+ default:
+ case 2:
+ l.push('2'); //DA:$,1
+ case 3:
+ l.push('3'); //DA:$,1
+ }
+ l.pop(); //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:7
+ //LH:5
+ //BRF:4
+ //BRH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ switch (l.length) { //DA:$,1 //BRDA:$,0,0,0 //BRDA:$,0,1,0 //BRDA:$,0,2,1 //BRDA:$,0,3,0 //BRDA:$,0,4,0
+ case 0:
+ l.push('0'); //DA:$,0
+ case 1:
+ l.push('1'); //DA:$,0
+ default:
+ l.push('default'); //DA:$,0
+ case 2:
+ l.push('2'); //DA:$,1
+ case 3:
+ l.push('3'); //DA:$,1
+ }
+ l.pop(); //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:8
+ //LH:5
+ //BRF:5
+ //BRH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ",".split(','); //DA:$,1
+ switch (l.length) { //DA:$,1 //BRDA:$,0,0,0 //BRDA:$,0,1,0 //BRDA:$,0,2,1 //BRDA:$,0,3,0
+ case 0:
+ l.push('0'); //DA:$,0
+ case 1:
+ l.push('1'); //DA:$,0
+ default:
+ l.push('2'); //DA:$,1
+ case 3:
+ l.push('3'); //DA:$,1
+ }
+ l.pop(); //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:7
+ //LH:5
+ //BRF:4
+ //BRH:1
+});
+
+checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ var l = ','.split(','); //DA:$,1
+ if (l.length === 45) { //DA:$,1 //BRDA:$,0,0,1 //BRDA:$,0,1,0
+ switch (l[0]) { //DA:$,0 //BRDA:$,1,0,- //BRDA:$,1,1,-
+ case ',':
+ l.push('0'); //DA:$,0
+ default:
+ l.push('1'); //DA:$,0
+ }
+ }
+ l.pop(); //DA:$,1
+ //FNF:1
+ //FNH:1
+ //LF:6
+ //LH:3
+ //BRF:4
+ //BRH:1
+});
+
+// These tests are not included in ../debug/Script-getOffsetsCoverage-01.js
+// because we're specifically testing a feature of Lcov output that
+// Debugger.Script doesn't have (the aggregation of hits that are on the
+// same line but in different functions).
+{
+ checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ function f() { return 0; } var l = f(); //DA:$,2
+ //FNF:2
+ //FNH:2
+ //LF:1
+ //LH:1
+ });
+
+ // A single line has two functions on it, and both hit.
+ checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ function f() { return 0; } function g() { return 1; } //DA:$,2
+ var v = f() + g(); //DA:$,1
+ //FNF:3
+ //FNH:3
+ //LF:2
+ //LH:2
+ });
+
+ // A line has both function code and toplevel code, and only one of them hits.
+ checkLcov(function () { //FN:$,top-level //FNDA:1,%
+ if (1 === 2) //DA:$,1
+ throw "0 hits here"; function f() { return "1 hit here"; } //DA:$,1
+ f(); //DA:$,1
+ //FNF:2
+ //FNH:2
+ //LF:3
+ //LH:3
+ });
+}
+
+// These tests are not included in ../debug/Script-getOffsetsCoverage-01.js
+// because they are testing behaviour of --code-coverage.
+{
+ // Test function names
+ checkLcov(function () {
+ //FN:1,top-level
+ //FNDA:1,top-level
+
+ var x = function() {}; //FN:$,x
+ let y = function() {}; //FN:$,y
+
+ let z = {
+ z_method() { }, //FN:$,z_method
+ get z_prop() { }, //FN:$,get z_prop
+ }
+ });
+}
+
+// If you add a test case here, do the same in
+// jit-test/tests/debug/Script-getOffsetsCoverage-01.js