Skip to content

test(conformance): pin monkey patching and integer-overflow divergences #60

Description

@siyul-park

Why

docs/roadmap.md puts monkey patching out of scope by default and docs/spec/02-types.md documents int as signed 64-bit, but neither is pinned by a test — so the behavior can drift silently in either direction. conformance/testdata/conformance/divergent/ exists precisely for this and currently holds only two cases (int_overflow, dict_iteration_order).

Cases to add

Monkey patching. minipy lowers classes to fixed-field structs and dispatches methods statically, so rebinding a method is a compile-time refusal, not a wrong answer:

class A:
    def f(self) -> int:
        return 1
def g(self) -> int:
    return 2
A.f = g
a = A()
print(a.f())
output
CPython 3.13 2
minipy SyntaxError: class value "A" is not supported

Instance-attribute assignment (a.x = 5) already matches CPython and needs no divergent case — worth a normal case so the boundary between the two is visible.

Integer overflow beyond the existing + case. Add ** and * boundary cases once #52 makes ** well-defined, plus sys.maxsize and arithmetic at ±2^63-1 as ordinary (non-divergent) ints/ cases.

Requirements

Each divergent case needs the pair the harness enforces biconditionally (conformance/suite.go):

# minipy-divergence: <one-line reason>
# minipy-divergence-doc: docs/compatibility.md#<anchor>

a .minipy golden, and a -doc: target that actually resolves. docs/compatibility.md needs real anchors for both — the doc pointer is checked for existence, so a dangling one fails TestConformance.

Goldens are generated, never hand-written:

python3.13 conformance/testdata/conformance/divergent/<name>.py > <name>.expected

Verification

go test ./conformance
go test ./conformance -run TestGoldensMatchCPython

Part of #49.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions