test: cover lowercase TYPE OF syntax
This commit is contained in:
@@ -65,6 +65,7 @@ Ready now:
|
||||
- `TYPE OF` prioritizes the missing expression diagnostic even when extra words follow the incomplete form, so `TYPE OF AS kind extra` still points the learner to the missing expression first.
|
||||
- `TYPE OF` reports a direct repair hint when the learner forgets the result name after `AS`, for example `TYPE OF score AS` reports `TYPE OF needs a result name after AS. Try: TYPE OF score AS kind.`
|
||||
- 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` 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 list/map checks through `claro typecheck`, including a nested `LIST OF MAP` insertion example
|
||||
|
||||
@@ -83,6 +83,7 @@ Keep declared return types honest: `claro typecheck` now reports friendly diagno
|
||||
8q.5.1a. Keep incomplete `TYPE OF` diagnostics focused: when the expression is missing, report that repair before secondary trailing-token errors.
|
||||
8q.5.2. Keep `TYPE OF` declarations named: a missing result name after `AS` now gets a direct repair hint with a complete `TYPE OF score AS kind` example.
|
||||
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.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.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.
|
||||
|
||||
@@ -101,6 +101,12 @@ class ValidateTypecheckDiagnosticsTests(unittest.TestCase):
|
||||
MODULE.EXPECTED,
|
||||
)
|
||||
|
||||
def test_includes_lowercase_type_of_success_fixture(self):
|
||||
self.assertIn(
|
||||
"tests/typecheck_lowercase_type_of_good.claro",
|
||||
MODULE.EXPECTED_OK,
|
||||
)
|
||||
|
||||
def test_includes_lowercase_compatibility_return_success_fixture(self):
|
||||
self.assertIn(
|
||||
"tests/typecheck_function_lowercase_return_good.claro",
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
set score number 10
|
||||
type of score as kind
|
||||
@@ -483,6 +483,7 @@ EXPECTED = {
|
||||
|
||||
EXPECTED_OK = [
|
||||
"tests/typecheck_type_of_good.claro",
|
||||
"tests/typecheck_lowercase_type_of_good.claro",
|
||||
"tests/typecheck_function_good.claro",
|
||||
"tests/typecheck_function_return_good.claro",
|
||||
"tests/typecheck_function_compat_return_good.claro",
|
||||
|
||||
Reference in New Issue
Block a user