Skip to content

Commit

Permalink
Merge pull request #132 from fink-lang/cov-ignore-match
Browse files Browse the repository at this point in the history
feat(match): add `istanbul ignore else` to generated code
  • Loading branch information
kollhof authored Sep 15, 2021
2 parents 1219423 + 557318f commit 474b040
Show file tree
Hide file tree
Showing 7 changed files with 1,644 additions and 1,422 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
- name: setup nodejs
uses: actions/setup-node@v1
with:
node-version: 16.5
node-version: 16.x

- name: install dependencies
env:
Expand Down
2,627 changes: 1,298 additions & 1,329 deletions package-lock.json

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions src/lang/async/init.test.fnk.snap
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export const task3 = async foo => {
export const a_gen = unfold(async (curr = 0) => {
const ˆvalue_1 = shrub;
/* istanbul ignore else */
ifvalue_1 === spam) {
return await ni(curr);
}
Expand Down
8 changes: 5 additions & 3 deletions src/lang/comments/init.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ transform_comments = fn comments:
map fn comment: transform_comment comment


get_comments = fn {comments={}}:
get_comments = fn {comments={}}, {leadingComments=[]}:
{leading=[], trailing=[]} = comments

rec:
leadingComments: [...transform_comments leading]
leadingComments: list:
...transform_comments leading
...leadingComments
trailingComments: [...transform_comments trailing]


wrap_with_comment_loc = fn js_node, larix_node:
comments = get_comments larix_node
comments = get_comments larix_node, js_node
{loc} = larix_node

match js_node:
Expand Down
28 changes: 21 additions & 7 deletions src/lang/conditionals/match.fnk
Original file line number Diff line number Diff line change
Expand Up @@ -111,9 +111,13 @@ match_record = fn value, record, emit_result, ctx, cond:
prop_match
[js, next_ctx]

js = ifStatement
not_nullish value
result
js = rec:
...ifStatement
not_nullish value
result
leadingComments: list: rec:
type: 'CommentBlock'
value: ' istanbul ignore else '

[js, end_ctx]

Expand Down Expand Up @@ -199,17 +203,27 @@ match_array = fn value, arr, emit_result, ctx, cond:
js = blockStatement [array_decl, matched]
[js, next_ctx]

js = ifStatement
is_iterable value
result
js = rec:
...ifStatement
is_iterable value
result
leadingComments: list: rec:
type: 'CommentBlock'
value: ' istanbul ignore else '

[js, end_ctx]



match_simple = fn value, expr, emit_result, ctx:
[cond, result_ctx] = comp value, expr, {...ctx, wrap: 'loc'}
[result, next_ctx] = emit_result result_ctx
js = ifStatement cond, result
js = rec:
...ifStatement cond, result
leadingComments: list: rec:
type: 'CommentBlock'
value: ' istanbul ignore else '

[js, next_ctx]


Expand Down
Loading

0 comments on commit 474b040

Please sign in to comment.