• 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

70.0
/src/stepper/nodes/Expression/Identifier.ts
1
import type { Comment, Identifier, SourceLocation } from 'estree';
2
import type { StepperExpression, StepperPattern } from '..';
3
import { isBuiltinFunction } from '../../builtins';
4
import { StepperBaseNode } from '../../interface';
5
import { UnassignedVariableError } from '../../../errors/errors';
6
import type { RedexInfo } from '../..';
7
import { InternalRuntimeError } from '../../../errors/base';
8

9
export class StepperIdentifier extends StepperBaseNode<Identifier> implements Identifier {
10
  constructor(
11
    public readonly name: string,
5,932✔
12
    leadingComments?: Comment[],
13
    trailingComments?: Comment[],
14
    loc?: SourceLocation | null,
15
    range?: [number, number],
16
  ) {
17
    super('Identifier', leadingComments, trailingComments, loc, range);
5,932✔
18
  }
19

20
  static create(node: Identifier) {
21
    return new StepperIdentifier(
4,820✔
22
      node.name,
23
      node.leadingComments,
24
      node.trailingComments,
25
      node.loc,
26
      node.range,
27
    );
28
  }
29

30
  public override isContractible(): boolean {
31
    // catch undeclared variables
NEW
32
    if (this.name !== 'undefined' && !isBuiltinFunction(this.name)) {
×
NEW
33
      throw new UnassignedVariableError(this.name, this);
×
34
    }
UNCOV
35
    return false;
×
36
  }
37

38
  public override isOneStepPossible(): boolean {
39
    if (this.name !== 'undefined' && !isBuiltinFunction(this.name)) {
3,808✔
40
      throw new UnassignedVariableError(this.name, this);
1✔
41
    }
42
    return false;
3,807✔
43
  }
44

45
  public override contract(): StepperIdentifier {
NEW
46
    throw new InternalRuntimeError('Cannot contract Identifier', this);
×
47
  }
48

49
  public override oneStep(): StepperIdentifier {
NEW
50
    throw new InternalRuntimeError('Cannot oneStep Identifier', this);
×
51
  }
52

53
  public override substitute(
54
    id: StepperPattern,
55
    value: StepperExpression,
56
    redex: RedexInfo,
57
  ): StepperExpression {
58
    if (id.name === this.name) {
10,691✔
59
      redex.postRedex.push(value);
2,954✔
60
      return value;
2,954✔
61
    } else {
62
      return this;
7,737✔
63
    }
64
  }
65

66
  public override freeNames(): string[] {
67
    return [this.name];
3,464✔
68
  }
69

70
  public override allNames(): string[] {
71
    return [this.name];
12,530✔
72
  }
73

74
  public override rename(before: string, after: string) {
75
    return before === this.name
164✔
76
      ? new StepperIdentifier(
77
          after,
78
          this.leadingComments,
79
          this.trailingComments,
80
          this.loc,
81
          this.range,
82
        )
83
      : this;
84
  }
85
}
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