test: cover compatibility method text concatenation
This commit is contained in:
@@ -409,6 +409,17 @@ SET player.name "Ada " + player.name
|
|||||||
|
|
||||||
This reverse-order concatenation is also covered by focused validation, so learners can build text from either side without losing the declared `TEXT` field type.
|
This reverse-order concatenation is also covered by focused validation, so learners can build text from either side without losing the declared `TEXT` field type.
|
||||||
|
|
||||||
|
Compatibility methods use the same TEXT concatenation rule. The older `TAKES` / `LEARNED` spelling accepts both operand orders when a method updates declared `TEXT` fields:
|
||||||
|
|
||||||
|
```claro
|
||||||
|
TEACH full_name TAKES suffix
|
||||||
|
SET first first + suffix
|
||||||
|
SET last "Dr. " + last
|
||||||
|
LEARNED
|
||||||
|
```
|
||||||
|
|
||||||
|
The focused validation matrix covers this compatibility example too, keeping modern and older method lessons aligned.
|
||||||
|
|
||||||
Two TEXT fields can be combined as well:
|
Two TEXT fields can be combined as well:
|
||||||
|
|
||||||
```claro
|
```claro
|
||||||
|
|||||||
@@ -64,6 +64,7 @@ Still needed:
|
|||||||
- Method return validation now has focused positive subtraction and division fixtures alongside the existing arithmetic return coverage, including compatibility `TAKES` / `LEARNED` subtraction and division cases, so checked NUMBER method parameters and numeric subtraction or division remain accepted by the release validator in both method spellings.
|
- Method return validation now has focused positive subtraction and division fixtures alongside the existing arithmetic return coverage, including compatibility `TAKES` / `LEARNED` subtraction and division cases, so checked NUMBER method parameters and numeric subtraction or division remain accepted by the release validator in both method spellings.
|
||||||
- Compatibility `TAKES` / `LEARNED` methods also have positive NUMBER, TEXT, and YESNO field-assignment coverage, and modern plus compatibility method-body `CHECK TYPE` metadata now have positive YESNO coverage beside the wrong-value diagnostics.
|
- Compatibility `TAKES` / `LEARNED` methods also have positive NUMBER, TEXT, and YESNO field-assignment coverage, and modern plus compatibility method-body `CHECK TYPE` metadata now have positive YESNO coverage beside the wrong-value diagnostics.
|
||||||
- Modern method-body TEXT concatenation has positive coverage in both operand orders, such as `SET first first + "!"` and `SET last "Dr. " + last`.
|
- Modern method-body TEXT concatenation has positive coverage in both operand orders, such as `SET first first + "!"` and `SET last "Dr. " + last`.
|
||||||
|
- Compatibility method-body TEXT concatenation has matching positive coverage in both operand orders, so `TAKES` / `LEARNED` methods keep the same beginner-safe field update behavior.
|
||||||
- richer typed function signatures and return values beyond the focused simple function/method `RETURNS TYPE` check
|
- richer typed function signatures and return values beyond the focused simple function/method `RETURNS TYPE` check
|
||||||
- type checking through branches and loops
|
- type checking through branches and loops
|
||||||
- richer object field type checking beyond simple direct assignments
|
- richer object field type checking beyond simple direct assignments
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ Keep declared return types honest: `claro typecheck` now reports friendly diagno
|
|||||||
7. Keep method-body field diagnostics learner-facing: typed methods now name the class method when a simple class field receives a known mismatch in `CHECK TYPE` or assignment, or a known TEXT operand in a NUMBER expression, with matching text and numeric coverage in modern and compatibility method syntax; direct assignments to undeclared method fields now report the missing field when the value type is known, and bare `CHECK TYPE missing IS TYPE` statements inside methods now use the expected type in the repair hint in both modern and compatibility method syntax; broader control-flow and object-flow analysis remains planned.
|
7. Keep method-body field diagnostics learner-facing: typed methods now name the class method when a simple class field receives a known mismatch in `CHECK TYPE` or assignment, or a known TEXT operand in a NUMBER expression, with matching text and numeric coverage in modern and compatibility method syntax; direct assignments to undeclared method fields now report the missing field when the value type is known, and bare `CHECK TYPE missing IS TYPE` statements inside methods now use the expected type in the repair hint in both modern and compatibility method syntax; broader control-flow and object-flow analysis remains planned.
|
||||||
8: Keep method-body coverage balanced across beginner field types and syntax generations: YESNO field assignment mismatches are now validated for both modern `DO` and compatibility `CALL ... WITH` method syntax, method-body `CHECK TYPE` metadata mismatches now have matching compatibility `TAKES` / `LEARNED` coverage alongside the modern form, compatibility YESNO field metadata has dedicated positive and negative fixtures, and compatibility method assignments to undeclared fields have the same focused missing-field diagnostic as modern methods, including a beginner-facing fallback when the assigned expression is not inferable yet.
|
8: Keep method-body coverage balanced across beginner field types and syntax generations: YESNO field assignment mismatches are now validated for both modern `DO` and compatibility `CALL ... WITH` method syntax, method-body `CHECK TYPE` metadata mismatches now have matching compatibility `TAKES` / `LEARNED` coverage alongside the modern form, compatibility YESNO field metadata has dedicated positive and negative fixtures, and compatibility method assignments to undeclared fields have the same focused missing-field diagnostic as modern methods, including a beginner-facing fallback when the assigned expression is not inferable yet.
|
||||||
8a. Keep method-body text expressions balanced: modern TEXT field concatenation is covered when the field is on either side of `+`, so both common beginner word-order patterns remain accepted.
|
8a. Keep method-body text expressions balanced: modern TEXT field concatenation is covered when the field is on either side of `+`, so both common beginner word-order patterns remain accepted.
|
||||||
|
8b. Keep compatibility method-body text expressions aligned: `TAKES` / `LEARNED` methods now have positive TEXT concatenation coverage in both operand orders beside the modern `TEACH` / `END` examples.
|
||||||
|
|
||||||
### 1. Strong static types
|
### 1. Strong static types
|
||||||
|
|
||||||
|
|||||||
+1
-1
File diff suppressed because one or more lines are too long
@@ -198,6 +198,12 @@ class ValidateTypecheckDiagnosticsTests(unittest.TestCase):
|
|||||||
MODULE.EXPECTED_OK,
|
MODULE.EXPECTED_OK,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
def test_includes_compatibility_method_text_concatenation_success_fixture(self):
|
||||||
|
self.assertIn(
|
||||||
|
"tests/typecheck_method_compat_text_concat_good.claro",
|
||||||
|
MODULE.EXPECTED_OK,
|
||||||
|
)
|
||||||
|
|
||||||
def test_includes_yesno_method_field_assignment_diagnostics(self):
|
def test_includes_yesno_method_field_assignment_diagnostics(self):
|
||||||
self.assertIn(
|
self.assertIn(
|
||||||
"tests/typecheck_method_yesno_field_assignment_bad.claro",
|
"tests/typecheck_method_yesno_field_assignment_bad.claro",
|
||||||
|
|||||||
@@ -0,0 +1,12 @@
|
|||||||
|
CLASS Player
|
||||||
|
HAS first TEXT
|
||||||
|
HAS last TEXT
|
||||||
|
|
||||||
|
TEACH full_name TAKES suffix
|
||||||
|
SET first first + suffix
|
||||||
|
SET last "Dr. " + last
|
||||||
|
LEARNED
|
||||||
|
ENDCLASS
|
||||||
|
|
||||||
|
NEW Player player
|
||||||
|
CALL player.full_name WITH "!"
|
||||||
@@ -350,6 +350,7 @@ EXPECTED_OK = [
|
|||||||
"tests/typecheck_method_compat_yesno_field_assignment_good.claro",
|
"tests/typecheck_method_compat_yesno_field_assignment_good.claro",
|
||||||
"tests/typecheck_method_compat_field_assignment_good.claro",
|
"tests/typecheck_method_compat_field_assignment_good.claro",
|
||||||
"tests/typecheck_method_text_concat_good.claro",
|
"tests/typecheck_method_text_concat_good.claro",
|
||||||
|
"tests/typecheck_method_compat_text_concat_good.claro",
|
||||||
"tests/typecheck_method_field_check_type_good.claro",
|
"tests/typecheck_method_field_check_type_good.claro",
|
||||||
"tests/typecheck_method_compat_field_check_type_good.claro",
|
"tests/typecheck_method_compat_field_check_type_good.claro",
|
||||||
"tests/typecheck_method_compat_yesno_field_check_type_good.claro",
|
"tests/typecheck_method_compat_yesno_field_check_type_good.claro",
|
||||||
|
|||||||
Reference in New Issue
Block a user