summaryrefslogtreecommitdiff
path: root/cli/tests/coverage
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tests/coverage')
-rw-r--r--cli/tests/coverage/branch.ts15
-rw-r--r--cli/tests/coverage/branch_test.ts5
-rw-r--r--cli/tests/coverage/complex.ts68
-rw-r--r--cli/tests/coverage/complex_test.ts5
-rw-r--r--cli/tests/coverage/expected_branch.lcov27
-rw-r--r--cli/tests/coverage/expected_branch.out12
-rw-r--r--cli/tests/coverage/expected_complex.lcov52
-rw-r--r--cli/tests/coverage/expected_complex.out17
8 files changed, 201 insertions, 0 deletions
diff --git a/cli/tests/coverage/branch.ts b/cli/tests/coverage/branch.ts
new file mode 100644
index 000000000..352167109
--- /dev/null
+++ b/cli/tests/coverage/branch.ts
@@ -0,0 +1,15 @@
+export function branch(condition: boolean): boolean {
+ if (condition) {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+export function unused(condition: boolean): boolean {
+ if (condition) {
+ return false;
+ } else {
+ return true;
+ }
+}
diff --git a/cli/tests/coverage/branch_test.ts b/cli/tests/coverage/branch_test.ts
new file mode 100644
index 000000000..2a44c8071
--- /dev/null
+++ b/cli/tests/coverage/branch_test.ts
@@ -0,0 +1,5 @@
+import { branch } from "./branch.ts";
+
+Deno.test("branch", function () {
+ branch(true);
+});
diff --git a/cli/tests/coverage/complex.ts b/cli/tests/coverage/complex.ts
new file mode 100644
index 000000000..a54c3437b
--- /dev/null
+++ b/cli/tests/coverage/complex.ts
@@ -0,0 +1,68 @@
+// This entire interface should be completely ignored by the coverage tool.
+export interface Complex {
+ // These comments should be ignored.
+ foo: string;
+
+ // But this is a stub, so this isn't really documentation.
+ bar: string;
+
+ // Really all these are doing is padding the line count.
+ baz: string;
+}
+
+// Lets add some wide characters to ensure that the absolute byte offsets are
+// being matched properly.
+//
+// 패딩에 대한 더 많은 문자.
+function dependency(
+ foo: string,
+ bar: string,
+ baz: string,
+): Complex {
+ return {
+ foo,
+ bar,
+ baz,
+ };
+}
+
+// Again just more wide characters for padding.
+//
+// 良い対策のためにいくつかのユニコード文字を投げる。
+export function complex(
+ foo: string,
+ bar: string,
+ baz: string,
+): Complex {
+ return dependency(
+ foo,
+ bar,
+ baz,
+ );
+}
+
+// And yet again for good measure.
+// 更多用於填充的字元。
+export function unused(
+ foo: string,
+ bar: string,
+ baz: string,
+): Complex {
+ return complex(
+ foo,
+ bar,
+ baz,
+ );
+}
+
+// Using a non-ascii name again to ensure that the byte offsets match up
+// correctly.
+export const π = Math.PI;
+
+// And same applies for this one, this one is unused and will show up in
+// lacking coverage.
+export function ƒ(): number {
+ return (
+ 0
+ );
+}
diff --git a/cli/tests/coverage/complex_test.ts b/cli/tests/coverage/complex_test.ts
new file mode 100644
index 000000000..fda948bc3
--- /dev/null
+++ b/cli/tests/coverage/complex_test.ts
@@ -0,0 +1,5 @@
+import { complex } from "./complex.ts";
+
+Deno.test("complex", function () {
+ complex("foo", "bar", "baz");
+});
diff --git a/cli/tests/coverage/expected_branch.lcov b/cli/tests/coverage/expected_branch.lcov
new file mode 100644
index 000000000..07e29cca5
--- /dev/null
+++ b/cli/tests/coverage/expected_branch.lcov
@@ -0,0 +1,27 @@
+SF:[WILDCARD]branch.ts
+FN:2,branch
+FN:10,unused
+FNDA:1,branch
+FNDA:0,unused
+FNF:2
+FNH:1
+BRDA:4,1,0,0
+BRF:1
+BRH:0
+DA:1,1
+DA:2,2
+DA:3,2
+DA:4,0
+DA:5,0
+DA:6,0
+DA:7,1
+DA:9,0
+DA:10,0
+DA:11,0
+DA:12,0
+DA:13,0
+DA:14,0
+DA:15,0
+LH:4
+LF:14
+end_of_record
diff --git a/cli/tests/coverage/expected_branch.out b/cli/tests/coverage/expected_branch.out
new file mode 100644
index 000000000..630ea93b2
--- /dev/null
+++ b/cli/tests/coverage/expected_branch.out
@@ -0,0 +1,12 @@
+cover [WILDCARD]/coverage/branch.ts ... 28.571% (4/14)
+ 4 | } else {
+ 5 | return false;
+ 6 | }
+-----|-----
+ 9 | export function unused(condition: boolean): boolean {
+ 10 | if (condition) {
+ 11 | return false;
+ 12 | } else {
+ 13 | return true;
+ 14 | }
+ 15 | }
diff --git a/cli/tests/coverage/expected_complex.lcov b/cli/tests/coverage/expected_complex.lcov
new file mode 100644
index 000000000..0182b3de7
--- /dev/null
+++ b/cli/tests/coverage/expected_complex.lcov
@@ -0,0 +1,52 @@
+SF:[WILDCARD]complex.ts
+FN:22,dependency
+FN:37,complex
+FN:51,unused
+FN:65,ƒ
+FNDA:1,dependency
+FNDA:1,complex
+FNDA:0,unused
+FNDA:0,ƒ
+FNF:4
+FNH:2
+BRF:0
+BRH:0
+DA:17,2
+DA:18,2
+DA:19,2
+DA:20,2
+DA:22,2
+DA:23,2
+DA:24,2
+DA:25,2
+DA:26,2
+DA:27,1
+DA:32,1
+DA:33,1
+DA:34,1
+DA:35,1
+DA:37,2
+DA:38,2
+DA:39,2
+DA:40,2
+DA:41,2
+DA:42,1
+DA:46,0
+DA:47,0
+DA:48,0
+DA:49,0
+DA:51,0
+DA:52,0
+DA:53,0
+DA:54,0
+DA:55,0
+DA:56,0
+DA:60,1
+DA:64,0
+DA:65,0
+DA:66,0
+DA:67,0
+DA:68,1
+LH:22
+LF:36
+end_of_record
diff --git a/cli/tests/coverage/expected_complex.out b/cli/tests/coverage/expected_complex.out
new file mode 100644
index 000000000..1dee78a87
--- /dev/null
+++ b/cli/tests/coverage/expected_complex.out
@@ -0,0 +1,17 @@
+cover [WILDCARD]/coverage/complex.ts ... 61.111% (22/36)
+ 46 | export function unused(
+ 47 | foo: string,
+ 48 | bar: string,
+ 49 | baz: string,
+-----|-----
+ 51 | return complex(
+ 52 | foo,
+ 53 | bar,
+ 54 | baz,
+ 55 | );
+ 56 | }
+-----|-----
+ 64 | export function ƒ(): number {
+ 65 | return (
+ 66 | 0
+ 67 | );