Skip to content

Commit 7b3aea5

Browse files
pirapiraclaude
andcommitted
Expand leanSpec E2E tests to subspecs/ layer (Tiers 8-12)
Add 5 new E2E test tiers running real leanSpec subspecs Python files: koalabear/field.py (Fp arithmetic), ssz/ pipeline (constants, utils, pack, merkleization, hash_tree_root via singledispatch), chain/config constants, and containers (Slot, Checkpoint, Config). Fix bytes __getitem__ to support slice tuples on subclass instances, and add memoryview/frozenset/complex as builtin names. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent 5f741f1 commit 7b3aea5

4 files changed

Lines changed: 427 additions & 1 deletion

File tree

LeanPython/Interpreter/Eval.lean

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1751,6 +1751,14 @@ partial def callValueDispatch (callee : Value) (args : List Value)
17511751
let i : Int := if idx < 0 then (b.size : Int) + idx else idx
17521752
if i < 0 || i >= b.size then throwTypeError "index out of range"
17531753
return .int (b[i.toNat]!.toNat : Int)
1754+
| [a, .tuple #[start, stop, step]] => do
1755+
let b ← extractBytes a
1756+
let (st, en, stp) ← computeSliceIndices b.size (some start) (some stop) (some step)
1757+
let indices := sliceIndices st en stp
1758+
let mut result := ByteArray.empty
1759+
for i in indices do
1760+
if i < b.size then result := result.push b[i]!
1761+
return .bytes result
17541762
| _ => throwTypeError "bytes.__getitem__ takes 2 arguments"
17551763
| "__contains__" => match args with
17561764
| [a, .int byte_] => do
@@ -2757,7 +2765,8 @@ partial def evalSubscriptValue (obj idx : Value) : InterpM Value := do
27572765
| .builtin name =>
27582766
-- Allow subscripting on builtin type names for type annotations (list[int], dict[str, int], etc.)
27592767
match name with
2760-
| "list" | "dict" | "set" | "tuple" | "frozenset" | "type" => return .none
2768+
| "list" | "dict" | "set" | "tuple" | "frozenset" | "type"
2769+
| "memoryview" | "complex" => return .none
27612770
| _ => throwTypeError s!"'{typeName obj}' object is not subscriptable"
27622771
| _ => throwTypeError s!"'{typeName obj}' object is not subscriptable"
27632772

LeanPython/Runtime/Types.lean

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -350,6 +350,7 @@ def builtinNames : List String :=
350350
"hex", "oct", "bin", "round", "pow", "divmod", "map", "filter",
351351
"iter", "next", "hasattr", "getattr", "setattr", "callable",
352352
"issubclass", "super", "object", "bytes", "bytearray",
353+
"memoryview", "frozenset", "complex",
353354
"staticmethod", "classmethod", "property",
354355
-- Dataclass
355356
"dataclass",

PLAN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -787,6 +787,7 @@ For non-deterministic tests, structural equivalence is checked.
787787
| 9e | leanSpec: fork choice | Done (Store with block/state management, BlockLookup ancestors generator, LMD GHOST fork choice algorithm, compute_block_weights, update_head) |
788788
| 9f | leanSpec: cryptographic subspecs | Done (KoalaBear Fp field arithmetic with modular inverse/division, Poseidon2 width-16/24 permutation with reference test vectors, compression and sponge modes, int_to_base_p, SHAKE128-based PRF, tweak encoding, hash chain traversal with composition verification, hypercube layer size via math.comb + map_to_vertex round-trip, Merkle tree construction and path verification; interpreter: math.comb, os.urandom, list slice assignment, __bytes__ dunder) |
789789
| 9g | Match/case (structural pattern matching) | Done (MatchPattern AST with matchValue/matchClass/matchWildcard/matchCapture/matchOr, soft-keyword parser with attempt-based backtracking, interpreter pattern matching with isinstance + attribute extraction, class/value/wildcard/capture/guard patterns, real leanSpec XMSS encode_tweak test with match/case) |
790+
| 9h | leanSpec: subspecs E2E (ssz+koalabear+containers) | Done (real leanSpec subspecs files: koalabear/field.py Fp arithmetic, ssz/constants+utils+pack+merkleization+hash.py full hash_tree_root via singledispatch with 13 type handlers, chain/config.py constants, containers/slot.py+checkpoint.py+config.py; interpreter: memoryview/frozenset/complex builtins, bytes.__getitem__ slice support for subclass instances) |
790791
| 10 | Async runtime (optional) | Not started |
791792

792793
---

0 commit comments

Comments
 (0)