test: add object field YESNO positive typecheck fixture

This commit is contained in:
Hermes Agent
2026-06-18 03:03:10 -06:00
parent 0b632e116d
commit 296d2e5b4e
6 changed files with 15 additions and 3 deletions
+5
View File
@@ -1,5 +1,10 @@
# Changelog
## v1.18.26-dev object field YESNO positive validation
- Added a focused positive `claro typecheck` fixture for direct object-field assignment with a YESNO field: `NEW Player player` followed by `SET player.ready YES` when the class declares `HAS ready YESNO`.
- Wired the YESNO object-field fixture into both the typecheck diagnostics validator and `claro validate`, complementing the existing NUMBER/TEXT positive fixtures and wrong-type field diagnostic fixture.
## v1.18.26-dev object field TEXT positive validation
- Added a focused positive `claro typecheck` fixture for direct object-field assignment with a TEXT field: `NEW Player player` followed by `SET player.name "Ada"` when the class declares `HAS name TEXT`.
+1 -1
View File
@@ -150,7 +150,7 @@ Output:
Type mismatch for field player.score: expected NUMBER, but this value looks like TEXT.
```
Both sides of this narrow field foundation are covered by validation: `tests/typecheck_object_field_good.claro` checks that `SET player.score 10` is accepted for a `HAS score NUMBER` field, `tests/typecheck_object_field_text_good.claro` checks that `SET player.name "Ada"` is accepted for a `HAS name TEXT` field, and `tests/typecheck_object_field_bad.claro` checks the friendly wrong-type diagnostic.
Both sides of this narrow field foundation are covered by validation: `tests/typecheck_object_field_good.claro` checks that `SET player.score 10` is accepted for a `HAS score NUMBER` field, `tests/typecheck_object_field_text_good.claro` checks that `SET player.name "Ada"` is accepted for a `HAS name TEXT` field, `tests/typecheck_object_field_yesno_good.claro` checks that `SET player.ready YES` is accepted for a `HAS ready YESNO` field, and `tests/typecheck_object_field_bad.claro` checks the friendly wrong-type diagnostic.
This slice is intentionally small: it covers direct `NEW Class object` plus `SET object.field value` cases in one file. Broader object flows, aliases, method return checks, and richer object signatures remain future work.
+1 -1
View File
@@ -53,7 +53,7 @@ Ready now:
- `TYPE OF` and `CHECK TYPE`
- typed list/map checks through `claro typecheck`
- a narrow function/method argument check: `CHECK TYPE parameter IS TYPE` inside a function or simple object method lets `claro typecheck` accept correct checked calls and catch mismatched `DO`, `CALL ... WITH`, and `DO object.method ...` arguments
- a narrow object-field assignment check for simple `NEW Class object` plus direct `SET object.field value` cases when the class declares `HAS field TYPE`; validation now covers correct NUMBER and TEXT direct assignments plus a wrong-type diagnostic
- a narrow object-field assignment check for simple `NEW Class object` plus direct `SET object.field value` cases when the class declares `HAS field TYPE`; validation now covers correct NUMBER, TEXT, and YESNO direct assignments plus a wrong-type diagnostic
Still needed:
- richer typed function signatures and return values
+1 -1
View File
@@ -31,7 +31,7 @@ See `CURRENT_STATUS.md` for the detailed feature matrix.
1. Keep beginner-facing docs current and separate from historical release notes.
2. Keep examples aligned with the modern simple syntax (`END`, `DO`, short `SET`, short `ASK`) while documenting older compatibility forms separately.
3. Expand validation around typecheck diagnostics and package/networking safety. Current object-method parameter validation covers one correct `DO object.method ...` call and one wrong-type diagnostic; object-field validation covers correct NUMBER and TEXT direct `SET object.field value` assignments plus one wrong-type direct assignment after `NEW Class object`.
3. Expand validation around typecheck diagnostics and package/networking safety. Current object-method parameter validation covers one correct `DO object.method ...` call and one wrong-type diagnostic; object-field validation covers correct NUMBER, TEXT, and YESNO direct `SET object.field value` assignments plus one wrong-type direct assignment after `NEW Class object`.
4. Add small examples for each foundation feature before adding bigger syntax.
## Complete-platform milestones
@@ -0,0 +1,6 @@
CLASS Player
HAS ready YESNO
END
NEW Player player
SET player.ready YES
+1
View File
@@ -37,6 +37,7 @@ EXPECTED_OK = [
"tests/typecheck_method_good.claro",
"tests/typecheck_object_field_good.claro",
"tests/typecheck_object_field_text_good.claro",
"tests/typecheck_object_field_yesno_good.claro",
"tests/37_object_field_types.claro",
]