Johan B.W. de Vries ff0286bcf6 More framework
2023-11-11 13:45:03 +01:00

46 lines
817 B
Markdown

# module_constant_def_ok
As a developer
I want to define $TYPE module constants
In order to make hardcoded values more visible
and to make it easier to change hardcoded values
```py
CONSTANT: $TYPE = $VAL0
@exported
def testEntry() -> i32:
return 9
```
```py
expect(9)
```
# module_constant_def_bad
As a developer
I want to receive a type error on an invalid assignment on a $TYPE module constant
In order to make debugging easier
```py
CONSTANT: $OTHER_TYPE = $VAL0
@exported
def testEntry() -> i32:
return 0
```
```py
if TYPE_NAME.startswith('tuple_'):
expect_type_error(
'Tuple element count mismatch',
'The given literal must fit the expected type',
)
else:
expect_type_error(
'Must be tuple',
'The given literal must fit the expected type',
)
```