stryker-mutator / stryker-net

Mutation testing for .NET core and .NET framework!
https://stryker-mutator.io
Apache License 2.0
1.74k stars 177 forks source link

List pattern syntax mutation #2951

Open richardwerkman opened 3 weeks ago

richardwerkman commented 3 weeks ago

Is your feature request related to a problem? Please describe. The following code (in the switch expression) should be mutated but is not:

    public void ListPatterns()
    {
        decimal balance = 0m;
        string[][] transactions = new[]
        {
            new[] { "1", "DEPOSIT", "100.00" },
        };
        foreach (string[] transaction in transactions)
        {
            balance += transaction switch
            {
            // "DEPOSIT" should be mutated here
            [_, "DEPOSIT", _, var amount] => decimal.Parse(amount),
            [_, "WITHDRAWAL", .., var amount] => -decimal.Parse(amount),
            [_, "INTEREST", var amount] => decimal.Parse(amount),
            [_, "FEE", var fee] => -decimal.Parse(fee),
                _ => throw new InvalidOperationException($"Record {string.Join(", ", transaction)} is not in the expected format!"),
            };
            Console.WriteLine($"Record: {string.Join(", ", transaction)}, New balance: {balance:C}");
        }
    }

Describe the solution you'd like We should introduce a new orchestrator for the syntax type ListPatternSyntax.