diff --git a/tested/languages/config.py b/tested/languages/config.py index a6320ab5..1e8ba2cb 100644 --- a/tested/languages/config.py +++ b/tested/languages/config.py @@ -35,7 +35,7 @@ class TypeDeclarationMetadata(TypedDict): - names: dict[AllTypes, str | bool] + names: dict[AllTypes, str | tuple[bool, str]] inner_names: NotRequired[dict[AllTypes, str]] nested: NotRequired[tuple[str, str]] nested_overrides: NotRequired[dict[AllTypes, tuple[str, str]]] diff --git a/tested/languages/generation.py b/tested/languages/generation.py index e14185aa..60bb0ddd 100644 --- a/tested/languages/generation.py +++ b/tested/languages/generation.py @@ -292,7 +292,7 @@ def generate_selector( def _convert_single_type( language: Language, type_: AllTypes | VariableType, inner: bool -) -> str | bool: +) -> str | tuple[bool, str]: if isinstance(type_, VariableType): return type_.data meta = language.get_declaration_metadata() @@ -307,6 +307,8 @@ def generate_type_declaration( ) -> str: if not isinstance(declaration, tuple): simple_result = _convert_single_type(language, declaration, inner) + if isinstance(simple_result, tuple): + simple_result = simple_result[1] assert isinstance( simple_result, str ), f"{declaration} is a simple type and should generate a string" @@ -315,6 +317,8 @@ def generate_type_declaration( meta = language.get_declaration_metadata() base_type, nested = declaration base = _convert_single_type(language, base_type, inner) + if isinstance(base, tuple): + base = base[0] start, finish = meta.get("nested", ("[", "]")) @@ -335,7 +339,7 @@ def generate_type_declaration( # This is a type with "inner" types, i.e. no name, such as Tuple[bool] return f"{start}{', '.join(converted_nested)}{finish}" elif base is False: - # This is a type with "rigt" types, i.e. no name, such as bool[] + # This is a type with "right" types, i.e. no name, such as bool[] return f"{', '.join(converted_nested)}{start}{finish}" else: return f"{base}{start}{', '.join(converted_nested)}{finish}" diff --git a/tested/languages/haskell/config.py b/tested/languages/haskell/config.py index 7ae4cb82..db674995 100644 --- a/tested/languages/haskell/config.py +++ b/tested/languages/haskell/config.py @@ -183,7 +183,7 @@ def generate_encoder(self, values: list[Value]) -> str: def get_declaration_metadata(self) -> TypeDeclarationMetadata: return { - "names": { # type: ignore + "names": { "integer": "Int", "real": "Double", "char": "Char", @@ -204,9 +204,9 @@ def get_declaration_metadata(self) -> TypeDeclarationMetadata: "single_precision": "Float", "double_precision": "Double", "any": "Object", - "list": True, - "tuple": True, - "sequence": True, + "list": (True, "Data.List"), + "tuple": (True, "Data.Tuple"), + "sequence": (True, "Data.List"), }, "nested_overrides": {"tuple": ("(", ")")}, # type: ignore "exception": "Exception", diff --git a/tested/languages/java/config.py b/tested/languages/java/config.py index 67a7d716..2d67f641 100644 --- a/tested/languages/java/config.py +++ b/tested/languages/java/config.py @@ -188,7 +188,7 @@ def get_declaration_metadata(self) -> TypeDeclarationMetadata: "fixed_precision": "BigDecimal", "list": "List", "any": "Object", - "array": False, + "array": (False, "array"), }, "inner_names": { "boolean": "Boolean",