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

source-academy / py-slang / 23715716818

29 Mar 2026 06:13PM UTC coverage: 59.421% (+18.2%) from 41.233%
23715716818

Pull #81

github

web-flow
Merge 576c7e6fc into 7b1e59a17
Pull Request #81: Python chapter 2 (+ 3?) support

779 of 1553 branches covered (50.16%)

Branch coverage included in aggregate %.

442 of 651 new or added lines in 32 files covered. (67.9%)

17 existing lines in 4 files now uncovered.

2400 of 3797 relevant lines covered (63.21%)

3195.38 hits per line

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

48.28
/src/stdlib/list.ts
1
import { Context } from "../cse-machine/context";
2
import { ControlItem } from "../cse-machine/control";
3
import { BigIntValue, BoolValue, BuiltinValue, Value } from "../cse-machine/stash";
4
import { Validate } from "../stdlib";
1✔
5
import listPrelude from "./list.prelude";
1✔
6
import { Group, GroupName } from "./utils";
1✔
7

8
const listBuiltins = new Map<string, BuiltinValue>();
1✔
9

10
class ListBuiltins {
11
  @Validate(1, 1, "list_length", true)
12
  static list_length(
1✔
13
    args: Value[],
14
    _source: string,
15
    _command: ControlItem,
16
    _context: Context,
17
  ): BigIntValue {
NEW
18
    const list = args[0];
×
NEW
19
    if (list.type !== "list") {
×
NEW
20
      throw new Error("list_length expects a list as the first argument");
×
21
    }
NEW
22
    return { type: "bigint", value: BigInt(list.value.length) };
×
23
  }
24

25
  @Validate(1, 1, "is_list", true)
26
  static is_list(
1✔
27
    args: Value[],
28
    _source: string,
29
    _command: ControlItem,
30
    _context: Context,
31
  ): BoolValue {
NEW
32
    const list = args[0];
×
NEW
33
    return { type: "bool", value: list.type === "list" };
×
34
  }
35

36
  // A helper function to generate a list of a given length
37
  @Validate(1, 1, "_gen_list", true)
38
  static _gen_list(
1✔
39
    args: Value[],
40
    _source: string,
41
    _command: ControlItem,
42
    _context: Context,
43
  ): Value {
NEW
44
    const length = args[0];
×
NEW
45
    if (length.type !== "bigint") {
×
NEW
46
      throw new Error("_gen_list expects a bigint as the first argument");
×
47
    }
NEW
48
    const list: Value[] = [];
×
NEW
49
    for (let i = BigInt(0); i < length.value; i++) {
×
NEW
50
      list.push({ type: "none" });
×
51
    }
NEW
52
    return { type: "list", value: list };
×
53
  }
54
}
55
for (const builtin of Object.getOwnPropertyNames(ListBuiltins)) {
1✔
56
  if (
6✔
57
    typeof ListBuiltins[builtin as keyof typeof ListBuiltins] === "function" &&
9✔
58
    !builtin.startsWith("_")
59
  ) {
60
    listBuiltins.set(builtin, {
2✔
61
      type: "builtin",
62
      func: ListBuiltins[builtin as keyof typeof ListBuiltins] as BuiltinValue["func"],
63
      name: builtin,
64
    });
65
  }
66
}
67
export default {
1✔
68
  name: GroupName.LIST,
69
  prelude: listPrelude,
70
  builtins: listBuiltins,
71
} as Group;
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