diff options
| author | David Sherret <dsherret@users.noreply.github.com> | 2021-08-11 10:20:47 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-08-11 10:20:47 -0400 |
| commit | 15a763152f9d392cb80692262f8de5ef8ae15495 (patch) | |
| tree | fcd1a59777f95920bf3502519983d6cc0d882a9a /cli/tests/testdata/coverage | |
| parent | a0285e2eb88f6254f6494b0ecd1878db3a3b2a58 (diff) | |
chore: move test files to testdata directory (#11601)
Diffstat (limited to 'cli/tests/testdata/coverage')
| -rw-r--r-- | cli/tests/testdata/coverage/branch.ts | 15 | ||||
| -rw-r--r-- | cli/tests/testdata/coverage/branch_test.ts | 5 | ||||
| -rw-r--r-- | cli/tests/testdata/coverage/complex.ts | 71 | ||||
| -rw-r--r-- | cli/tests/testdata/coverage/complex_test.ts | 5 | ||||
| -rw-r--r-- | cli/tests/testdata/coverage/expected_branch.lcov | 27 | ||||
| -rw-r--r-- | cli/tests/testdata/coverage/expected_branch.out | 12 | ||||
| -rw-r--r-- | cli/tests/testdata/coverage/expected_complex.lcov | 53 | ||||
| -rw-r--r-- | cli/tests/testdata/coverage/expected_complex.out | 19 |
8 files changed, 207 insertions, 0 deletions
diff --git a/cli/tests/testdata/coverage/branch.ts b/cli/tests/testdata/coverage/branch.ts new file mode 100644 index 000000000..352167109 --- /dev/null +++ b/cli/tests/testdata/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/testdata/coverage/branch_test.ts b/cli/tests/testdata/coverage/branch_test.ts new file mode 100644 index 000000000..2a44c8071 --- /dev/null +++ b/cli/tests/testdata/coverage/branch_test.ts @@ -0,0 +1,5 @@ +import { branch } from "./branch.ts"; + +Deno.test("branch", function () { + branch(true); +}); diff --git a/cli/tests/testdata/coverage/complex.ts b/cli/tests/testdata/coverage/complex.ts new file mode 100644 index 000000000..47d4ffa79 --- /dev/null +++ b/cli/tests/testdata/coverage/complex.ts @@ -0,0 +1,71 @@ +// 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 + ); +} + +// This arrow function should also show up as uncovered. +console.log("%s", () => 1); diff --git a/cli/tests/testdata/coverage/complex_test.ts b/cli/tests/testdata/coverage/complex_test.ts new file mode 100644 index 000000000..fda948bc3 --- /dev/null +++ b/cli/tests/testdata/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/testdata/coverage/expected_branch.lcov b/cli/tests/testdata/coverage/expected_branch.lcov new file mode 100644 index 000000000..07e29cca5 --- /dev/null +++ b/cli/tests/testdata/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/testdata/coverage/expected_branch.out b/cli/tests/testdata/coverage/expected_branch.out new file mode 100644 index 000000000..630ea93b2 --- /dev/null +++ b/cli/tests/testdata/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/testdata/coverage/expected_complex.lcov b/cli/tests/testdata/coverage/expected_complex.lcov new file mode 100644 index 000000000..962ebee96 --- /dev/null +++ b/cli/tests/testdata/coverage/expected_complex.lcov @@ -0,0 +1,53 @@ +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 +DA:71,0 +LH:22 +LF:37 +end_of_record diff --git a/cli/tests/testdata/coverage/expected_complex.out b/cli/tests/testdata/coverage/expected_complex.out new file mode 100644 index 000000000..e9f9a453f --- /dev/null +++ b/cli/tests/testdata/coverage/expected_complex.out @@ -0,0 +1,19 @@ +cover [WILDCARD]/coverage/complex.ts ... 59.459% (22/37) + 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 | ); +-----|----- + 71 | console.log("%s", () => 1); |
