test: cover lowercase object field syntax
This commit is contained in:
@@ -803,6 +803,20 @@ For backward compatibility, a script with no `CLASS` declarations keeps the olde
|
|||||||
|
|
||||||
Claro also has a narrow static diagnostic for direct object-field assignments. If a class declares a typed field and a script creates a simple object with `NEW Class name`, `claro typecheck` remembers the field type:
|
Claro also has a narrow static diagnostic for direct object-field assignments. If a class declares a typed field and a script creates a simple object with `NEW Class name`, `claro typecheck` remembers the field type:
|
||||||
|
|
||||||
|
Keywords are case-insensitive, including object-field declarations and checks. This equivalent beginner example is accepted too:
|
||||||
|
|
||||||
|
```claro
|
||||||
|
class Player
|
||||||
|
has score number
|
||||||
|
end
|
||||||
|
|
||||||
|
new Player player
|
||||||
|
set player.score number 10
|
||||||
|
check type player.score is number
|
||||||
|
```
|
||||||
|
|
||||||
|
The focused validation fixture `tests/typecheck_object_field_lowercase_good.claro` protects this lowercased spelling.
|
||||||
|
|
||||||
```claro
|
```claro
|
||||||
CLASS Player
|
CLASS Player
|
||||||
HAS score NUMBER
|
HAS score NUMBER
|
||||||
|
|||||||
@@ -67,6 +67,7 @@ Ready now:
|
|||||||
- A valid `TYPE OF score AS kind` statement has a focused positive typecheck fixture, so the complete form is protected from diagnostic-only regression coverage.
|
- A valid `TYPE OF score AS kind` statement has a focused positive typecheck fixture, so the complete form is protected from diagnostic-only regression coverage.
|
||||||
- `TYPE OF` remains case-insensitive like other Claro keywords, with focused positive coverage for lowercase `type of score as kind` syntax.
|
- `TYPE OF` remains case-insensitive like other Claro keywords, with focused positive coverage for lowercase `type of score as kind` syntax.
|
||||||
- `CHECK TYPE` remains case-insensitive like other Claro keywords, with focused positive coverage for lowercase `check type score is number` syntax.
|
- `CHECK TYPE` remains case-insensitive like other Claro keywords, with focused positive coverage for lowercase `check type score is number` syntax.
|
||||||
|
- Object declarations and field checks remain case-insensitive like other Claro keywords, with focused positive coverage for lowercase `class`, `has`, `end`, `new`, `set`, and `check type` in one typed object-field example.
|
||||||
- `TYPE OF` rejects extra words after its result name with a direct repair hint, so `TYPE OF score AS kind extra` explains that only one result name belongs there; typed `TEACH ... RETURNS TYPE` declarations likewise reject extra words after the return type with a direct repair hint
|
- `TYPE OF` rejects extra words after its result name with a direct repair hint, so `TYPE OF score AS kind extra` explains that only one result name belongs there; typed `TEACH ... RETURNS TYPE` declarations likewise reject extra words after the return type with a direct repair hint
|
||||||
- typed `TEACH ... RETURNS` declarations reject a missing return type with a direct repair hint, such as `Function greet needs a return type after RETURNS. Add a type such as NUMBER.` The same diagnostic names the complete class and method, including compatibility `TAKES` / `LEARNED` methods: `Method Player.score needs a return type after RETURNS. Add a type such as NUMBER.`
|
- typed `TEACH ... RETURNS` declarations reject a missing return type with a direct repair hint, such as `Function greet needs a return type after RETURNS. Add a type such as NUMBER.` The same diagnostic names the complete class and method, including compatibility `TAKES` / `LEARNED` methods: `Method Player.score needs a return type after RETURNS. Add a type such as NUMBER.`
|
||||||
- typed list/map checks through `claro typecheck`, including a nested `LIST OF MAP` insertion example
|
- typed list/map checks through `claro typecheck`, including a nested `LIST OF MAP` insertion example
|
||||||
|
|||||||
@@ -93,6 +93,7 @@ Keep declared return types honest: `claro typecheck` now reports friendly diagno
|
|||||||
8q.5.3. Keep complete `TYPE OF` examples protected: the valid `TYPE OF score AS kind` form now has a positive fixture in the focused typecheck validation matrix.
|
8q.5.3. Keep complete `TYPE OF` examples protected: the valid `TYPE OF score AS kind` form now has a positive fixture in the focused typecheck validation matrix.
|
||||||
8q.5.3a. Keep `TYPE OF` keyword handling consistent: lowercase `type of score as kind` now has positive fixture coverage alongside the uppercase form.
|
8q.5.3a. Keep `TYPE OF` keyword handling consistent: lowercase `type of score as kind` now has positive fixture coverage alongside the uppercase form.
|
||||||
8q.5.3b. Keep `CHECK TYPE` keyword handling consistent: lowercase `check type score is number` now has positive fixture coverage alongside the uppercase form.
|
8q.5.3b. Keep `CHECK TYPE` keyword handling consistent: lowercase `check type score is number` now has positive fixture coverage alongside the uppercase form.
|
||||||
|
8q.5.3c. Keep object-field examples consistent with keyword rules: lowercase `class`, `has`, `new`, `set`, and `check type` now have one focused positive typed-field fixture.
|
||||||
8q.5.4. Keep bare `TYPE OF` declarations understandable: report that the expression, `AS`, and result name are all required, with a complete repair example.
|
8q.5.4. Keep bare `TYPE OF` declarations understandable: report that the expression, `AS`, and result name are all required, with a complete repair example.
|
||||||
8q.6. Keep `TYPE OF` declarations unambiguous: extra words after the result name now get a direct repair hint instead of being silently included in the variable name.
|
8q.6. Keep `TYPE OF` declarations unambiguous: extra words after the result name now get a direct repair hint instead of being silently included in the variable name.
|
||||||
8q.7. Keep typed `TEACH` declarations unambiguous: extra words after a declared return type now get a direct repair hint instead of being treated as part of an unknown type.
|
8q.7. Keep typed `TEACH` declarations unambiguous: extra words after a declared return type now get a direct repair hint instead of being treated as part of an unknown type.
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
class Player
|
||||||
|
has score number
|
||||||
|
end
|
||||||
|
|
||||||
|
new Player player
|
||||||
|
set player.score number 10
|
||||||
|
check type player.score is number
|
||||||
@@ -518,6 +518,7 @@ EXPECTED_OK = [
|
|||||||
"tests/typecheck_type_of_good.claro",
|
"tests/typecheck_type_of_good.claro",
|
||||||
"tests/typecheck_lowercase_type_of_good.claro",
|
"tests/typecheck_lowercase_type_of_good.claro",
|
||||||
"tests/typecheck_lowercase_check_type_good.claro",
|
"tests/typecheck_lowercase_check_type_good.claro",
|
||||||
|
"tests/typecheck_object_field_lowercase_good.claro",
|
||||||
"tests/typecheck_function_good.claro",
|
"tests/typecheck_function_good.claro",
|
||||||
"tests/typecheck_function_return_good.claro",
|
"tests/typecheck_function_return_good.claro",
|
||||||
"tests/typecheck_function_compat_return_good.claro",
|
"tests/typecheck_function_compat_return_good.claro",
|
||||||
|
|||||||
Reference in New Issue
Block a user