Repository navigation
test: characterize structs and methods - #104
Open
shayyz-code wants to merge 3 commits into
Open
shayyz-code wants to merge 3 commits into
shayyz-code wants to merge 3 commits into
Conversation
Pin down v0.1.11 behaviour of struct declarations, construction, field access, impl blocks, self, Self and inheritance in the conformance corpus. Cases for known defects (#50, #57, #63, #64, #65, #69) carry an .ignore file with the intended output. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Field assignment on a mut binding should update the field (#106), so the case is now a known failure with the intended output instead of a blessed parse error. The self-mutation case notes the same dependency. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds 21 conformance cases under
tests/conformance/structs/that record how v0.1.11 handles structs and methods, so the upcoming refactor changes them on purpose. The cases cover declarations with typed fields,pub, construction withName::{...}, field access, construction errors,impl { }andimpl Target { }methods,self,Selfreturn types, andinherits. No interpreter or harness changes.Current behaviour (blessed, 12 cases):
field_access,pub_modifier_not_enforced,field_type_mismatch,missing_field,undefined_struct,unknown_field_access,method_reads_self,method_with_argument,impl_target_block,method_returns_self_type,static_method_call_rejected,inherits_parent_method.Known failures (9 cases, hand-written intended output plus
.ignore):unknown_field_rejectedPoint::{x, y, z}is accepted silentlystruct_typed_fieldPointvalue for aPointfield is rejected (expected Map({...}) but got Map({}))vec_typed_fieldUnexpected token: TInt. The case returns the vector instead of indexing it, because indexing after a field access is a separate defect (#107)field_assignmentc.count = 2;on amutbinding fails withUnexpected token: Assignment, expected: SemiColon; there is no field assignment syntax yetmethod_returns_int_fieldself.xis typedString, so>> intfails with "Return type mismatch"method_result_bindingpoo n <: p.get_name();fails with "Undefined method 'get_name' for object of type Map(...)" (inference panic caught by the hook)method_mutates_selfself.count = 0;does not parse at all (Unexpected token: Assignment, see #106), so the case fails before the lost-mutation bug can showinherits_parent_without_implRuntime error: called Option::unwrap() on a None value(exit 1, because the panic hook turns the panic into an error)print_struct{"x": Int(1), "y": Int(2), "__prototypes__": Map({})}, in a different key order from run to run. With methods, it also dumps the method AST. It does not panic as #69 saysNot included: override resolution (#56). A child overriding a parent method returned the child's result in 20 of 60 runs and the parent's in the other 40. A case expecting the child to win would pass about one run in three, and the harness fails the run when an ignored case passes, so it would make CI flaky. #56 stays without a corpus case until the lookup is deterministic.
Recorded as they are now, decision still open:
pub_modifier_not_enforced:pubis parsed, but fields withoutpubcan still be read from outside the struct.missing_field: a missing field is rejected with the confusing messageMismatched key 'y' on struct compound - 'Point'.unknown_field_access: reading an unknown field saysValue for key z does not exist in the map, which talks about a map, not a struct.static_method_call_rejected:Point::origin()fails withExpected struct compound after namespace access. Methods can only be called on an instance, so a>> Selfconstructor can't be called without one.Defects found while writing these cases: #106 (struct field assignment does not parse), #107 (indexing after a field access), and #109 (
impl Other { }naming a struct that doesn't exist is accepted, and its methods attach to the enclosing struct; no case here).Also seen: type-mismatch messages for struct-typed fields print the expected
Map({...})in random key order, so.errorfiles must not include that part.Issue
Closes #87
Verification
BLESS=1 POO_CASE=structs/ cargo test --test conformance, then checked every blessed.stdoutand.errorby hand.cargo test --test conformance5 times, eachconformance: 17 passed, 9 known failures, 0 failed;POO_CASE=structs/20 more times, each13 passed, 8 known failures, 0 failed (21 matched).cargo test --test conformance3 times on the branch tip, eachconformance: 16 passed, 10 known failures, 0 failed(structs: 12 passed, 9 known failures, 21 matched). The middle commit alone gives17 passed, 9 known failures, 0 failed.poobinary. Every recorded output was the same on all 30 runs.just checkpasses on the branch tip.just checkDocumentation and Visual Impact
None. The only changes are test files under
tests/conformance/structs/.🤖 Generated with Claude Code