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

source-academy / js-slang / 24843532782

23 Apr 2026 03:22PM UTC coverage: 78.522% (+0.1%) from 78.391%
24843532782

Pull #1893

github

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

3125 of 4193 branches covered (74.53%)

Branch coverage included in aggregate %.

899 of 1089 new or added lines in 96 files covered. (82.55%)

21 existing lines in 12 files now uncovered.

7031 of 8741 relevant lines covered (80.44%)

180261.64 hits per line

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

41.03
/src/stepper/nodes/Expression/ArrayExpression.ts
1
import type { ArrayExpression, Comment, Expression, 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 { InternalRuntimeError } from '../../../errors/base';
7

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

22
  static create(node: ArrayExpression) {
23
    return new StepperArrayExpression(
1✔
NEW
24
      node.elements.map(element => (element ? convert(element as Expression) : null)),
×
25
      node.leadingComments,
26
      node.trailingComments,
27
      node.loc,
28
      node.range,
29
    );
30
  }
31

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

36
  public override isOneStepPossible(redex: RedexInfo): boolean {
37
    return this.elements.some(element => element?.isOneStepPossible(redex));
37,216✔
38
  }
39

40
  public override contract(redex: RedexInfo): StepperExpression {
41
    redex.preRedex = [this];
×
NEW
42
    throw new InternalRuntimeError('Array expressions cannot be contracted', this);
×
43
  }
44

45
  public override oneStep(redex: RedexInfo): StepperExpression {
46
    if (this.isContractible()) {
×
NEW
47
      return this.contract(redex);
×
48
    }
49

50
    for (let i = 0; i < this.elements.length; i++) {
×
51
      const element = this.elements[i];
×
NEW
52
      if (element?.isOneStepPossible(redex)) {
×
53
        const newElements = [...this.elements];
×
NEW
54
        newElements[i] = element.oneStep(redex);
×
55
        return new StepperArrayExpression(
×
56
          newElements,
57
          this.leadingComments,
58
          this.trailingComments,
59
          this.loc,
60
          this.range,
61
        );
62
      }
63
    }
64

NEW
65
    throw new InternalRuntimeError('No one step possible for ArrayExpression', this);
×
66
  }
67

68
  public override substitute(
69
    id: StepperPattern,
70
    value: StepperExpression,
71
    redex: RedexInfo,
72
  ): StepperExpression {
73
    return new StepperArrayExpression(
1,210✔
74
      this.elements.map(element => (element ? element.substitute(id, value, redex) : null)),
2,420!
75
      this.leadingComments,
76
      this.trailingComments,
77
      this.loc,
78
      this.range,
79
    );
80
  }
81

82
  public override freeNames(): string[] {
83
    const names = this.elements
403✔
84
      .filter(element => element !== null)
806✔
85
      .flatMap(element => element.freeNames());
806✔
86
    return Array.from(new Set(names));
403✔
87
  }
88

89
  public override allNames(): string[] {
90
    const names = this.elements
104✔
91
      .filter(element => element !== null)
208✔
92
      .flatMap(element => element.allNames());
208✔
93
    return Array.from(new Set(names));
104✔
94
  }
95

96
  public override rename(before: string, after: string): StepperExpression {
97
    return new StepperArrayExpression(
×
98
      this.elements.map(element => (element ? element.rename(before, after) : null)),
×
99
      this.leadingComments,
100
      this.trailingComments,
101
      this.loc,
102
      this.range,
103
    );
104
  }
105
}
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