Skip to content

exercise util: generated tests should unpack input when possible #681

@coriolinus

Description

@coriolinus

First special rule: we need special handling for structured canonical data: in the case of the input map, it should not represent it as a hashmap, but unpack it into the input tuple sent to process_X_case.

That is, using abbreviate as an example, the generated code should not be:

process_abbreviate_case(
    {
        let mut hm = ::std::collections::HashMap::new();
        hm.insert("phrase", "GNU Image Manipulation Program");
        hm
    },
    "GIMP",
);

but instead:

process_abbreviate_case(
    ("GNU Image Manipulation Program",),
    "GIMP",
);

Second special rule: when the tuple sent to input contains exactly one item, it doesn't need to be a tuple, but can be a bare item. This means that the same generated code for abbreviate would actually be:

process_abbreviate_case(
    "GNU Image Manipulation Program",
    "GIMP",
);

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions