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

source-academy / js-slang / 23995741899

05 Apr 2026 06:14AM UTC coverage: 77.093% (+0.002%) from 77.091%
23995741899

push

github

web-flow
Upgrade to TypeScript 6 and Prettier improvements (#1936)

* Upgrade TypeScript to v6

* Fix import source

* Fix tsconfig

* Fix preexisting type errors

* Remove scm-slang

* Bump node types

* Fix tsconfig

* Fix node types specifier

* Enable trailing commas

* Enable semicolons

* Check and commit files with changed line numbers

* Update Yarn to 4.13.0

* Remove unneeded sicp package deps

3112 of 4282 branches covered (72.68%)

Branch coverage included in aggregate %.

3761 of 5218 new or added lines in 152 files covered. (72.08%)

26 existing lines in 9 files now uncovered.

7136 of 9011 relevant lines covered (79.19%)

175254.05 hits per line

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

42.55
/src/tracer/nodes/Expression/ArrayExpression.ts
1
import type { ArrayExpression, Comment, SourceLocation } from 'estree';
2
import type { StepperExpression, StepperPattern } from '..';
3
import { redex } from '../..';
4
import { convert } from '../../generator';
5
import type { StepperBaseNode } from '../../interface';
6

7
export class StepperArrayExpression implements ArrayExpression, StepperBaseNode {
8
  type: 'ArrayExpression';
9
  elements: (StepperExpression | null)[];
10
  leadingComments?: Comment[];
11
  trailingComments?: Comment[];
12
  loc?: SourceLocation | null;
13
  range?: [number, number];
14

15
  constructor(
16
    elements: (StepperExpression | null)[],
17
    leadingComments?: Comment[],
18
    trailingComments?: Comment[],
19
    loc?: SourceLocation | null,
20
    range?: [number, number],
21
  ) {
22
    this.type = 'ArrayExpression';
1,281✔
23
    this.elements = elements;
1,281✔
24
    this.leadingComments = leadingComments;
1,281✔
25
    this.trailingComments = trailingComments;
1,281✔
26
    this.loc = loc;
1,281✔
27
    this.range = range;
1,281✔
28
  }
29

30
  static create(node: ArrayExpression) {
31
    return new StepperArrayExpression(
×
32
      node.elements.map(element => (element ? (convert(element) as StepperExpression) : null)),
×
33
      node.leadingComments,
34
      node.trailingComments,
35
      node.loc,
36
      node.range,
37
    );
38
  }
39

40
  isContractible(): boolean {
NEW
41
    return false;
×
42
  }
43

44
  isOneStepPossible(): boolean {
45
    return this.elements.some(element => element && element.isOneStepPossible());
37,216✔
46
  }
47

48
  contract(): StepperExpression {
NEW
49
    redex.preRedex = [this];
×
NEW
50
    throw new Error('Array expressions cannot be contracted');
×
51
  }
52

53
  oneStep(): StepperExpression {
54
    if (this.isContractible()) {
×
NEW
55
      return this.contract();
×
56
    }
57

58
    for (let i = 0; i < this.elements.length; i++) {
×
NEW
59
      const element = this.elements[i];
×
60
      if (element && element.isOneStepPossible()) {
×
NEW
61
        const newElements = [...this.elements];
×
NEW
62
        newElements[i] = element.oneStep();
×
UNCOV
63
        return new StepperArrayExpression(
×
64
          newElements,
65
          this.leadingComments,
66
          this.trailingComments,
67
          this.loc,
68
          this.range,
69
        );
70
      }
71
    }
72

NEW
73
    throw new Error('No one step possible');
×
74
  }
75

76
  substitute(id: StepperPattern, value: StepperExpression): StepperExpression {
77
    return new StepperArrayExpression(
1,210✔
78
      this.elements.map(element => (element ? element.substitute(id, value) : null)),
2,420!
79
      this.leadingComments,
80
      this.trailingComments,
81
      this.loc,
82
      this.range,
83
    );
84
  }
85

86
  freeNames(): string[] {
87
    const names = this.elements
403✔
88
      .filter(element => element !== null)
806✔
89
      .map(element => element.freeNames())
806✔
90
      .flat();
91
    return Array.from(new Set(names));
403✔
92
  }
93

94
  allNames(): string[] {
95
    const names = this.elements
104✔
96
      .filter(element => element !== null)
208✔
97
      .map(element => element.allNames())
208✔
98
      .flat();
99
    return Array.from(new Set(names));
104✔
100
  }
101

102
  rename(before: string, after: string): StepperExpression {
103
    return new StepperArrayExpression(
×
104
      this.elements.map(element => (element ? element.rename(before, after) : null)),
×
105
      this.leadingComments,
106
      this.trailingComments,
107
      this.loc,
108
      this.range,
109
    );
110
  }
111
}
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