• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

source-academy / js-slang / 24834367427

23 Apr 2026 12:09PM UTC coverage: 78.541% (+0.2%) from 78.391%
24834367427

Pull #1893

github

web-flow
Merge ab101147d into 715603479
Pull Request #1893: Error Handling and Stringify Changes

3126 of 4197 branches covered (74.48%)

Branch coverage included in aggregate %.

801 of 975 new or added lines in 76 files covered. (82.15%)

20 existing lines in 11 files now uncovered.

7056 of 8767 relevant lines covered (80.48%)

173930.4 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

66.67
/src/stepper/nodes/Statement/ReturnStatement.ts
1
import type { Comment, ReturnStatement, SourceLocation } from 'estree';
2
import type { StepperExpression, StepperPattern } from '..';
3
import { convert } from '../../generator';
4
import { StepperBaseNode } from '../../interface';
5
import type { RedexInfo } from '../..';
6
import assert from '../../../utils/assert';
7

8
export class StepperReturnStatement
9
  extends StepperBaseNode<ReturnStatement>
10
  implements ReturnStatement
11
{
12
  constructor(
13
    public readonly argument: StepperExpression | null,
1,179✔
14
    leadingComments?: Comment[] | undefined,
15
    trailingComments?: Comment[] | undefined,
16
    loc?: SourceLocation | null | undefined,
17
    range?: [number, number] | undefined,
18
  ) {
19
    super('ReturnStatement', leadingComments, trailingComments, loc, range);
1,179✔
20
  }
21

22
  static create(node: ReturnStatement) {
23
    return new StepperReturnStatement(
198✔
24
      node.argument ? convert(node.argument) : null,
198!
25
      node.leadingComments,
26
      node.trailingComments,
27
      node.loc,
28
      node.range,
29
    );
30
  }
31

32
  public override isContractible(): boolean {
33
    return true;
13✔
34
  }
35

36
  public override isOneStepPossible(): boolean {
37
    return true;
207✔
38
  }
39

40
  public override contract(redex: RedexInfo): StepperExpression {
41
    assert(!!this.argument, 'Cannot contract return statement without argument', this);
38✔
42

43
    redex.preRedex = [this];
38✔
44
    redex.postRedex = [this.argument];
38✔
45
    return this.argument;
38✔
46
  }
47

48
  contractEmpty(redex: RedexInfo) {
49
    redex.preRedex = [this];
×
50
    redex.postRedex = [];
×
51
  }
52

53
  public override oneStep(redex: RedexInfo): StepperExpression {
NEW
54
    assert(!!this.argument, 'Cannot step return statement without argument', this);
×
NEW
55
    return this.contract(redex);
×
56
  }
57

58
  public override substitute(
59
    id: StepperPattern,
60
    value: StepperExpression,
61
    redex: RedexInfo,
62
  ): StepperBaseNode {
63
    return new StepperReturnStatement(
949✔
64
      this.argument ? this.argument.substitute(id, value, redex) : null,
949!
65
      this.leadingComments,
66
      this.trailingComments,
67
      this.loc,
68
      this.range,
69
    );
70
  }
71

72
  public override freeNames(): string[] {
73
    return this.argument ? this.argument.freeNames() : [];
1,938!
74
  }
75

76
  public override allNames(): string[] {
77
    return this.argument ? this.argument.allNames() : [];
3,424!
78
  }
79

80
  public override rename(before: string, after: string): StepperReturnStatement {
81
    return new StepperReturnStatement(
32✔
82
      this.argument ? this.argument.rename(before, after) : null,
32!
83
      this.leadingComments,
84
      this.trailingComments,
85
      this.loc,
86
      this.range,
87
    );
88
  }
89
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc