From 198b0f54126574525c6f994518546274212ca125 Mon Sep 17 00:00:00 2001 From: Patrick Stevens <3138005+Smaug123@users.noreply.github.com> Date: Tue, 4 Jun 2024 21:40:27 +0100 Subject: [PATCH] Stop requiring reference types in enumeration (#10) --- TestRunner/Program.fs | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/TestRunner/Program.fs b/TestRunner/Program.fs index ab3c024..b14cf03 100644 --- a/TestRunner/Program.fs +++ b/TestRunner/Program.fs @@ -1,7 +1,6 @@ namespace TestRunner open System -open System.Collections.Generic open System.IO open System.Reflection open System.Threading @@ -199,15 +198,19 @@ module TestFixture = ||| BindingFlags.Static ) - args.GetValue null :?> IEnumerable - |> Seq.map (fun arg -> - match arg with - | :? TestCaseData as tcd -> runOne test.Method tcd.Arguments - | :? Tuple as (a, b) -> runOne test.Method [| a ; b |] - | :? Tuple as (a, b, c) -> runOne test.Method [| a ; b ; c |] - | :? Tuple as (a, b, c, d) -> runOne test.Method [| a ; b ; c ; d |] - | arg -> runOne test.Method [| arg |] - ) + seq { + // Might not be an IEnumerable of a reference type. + // Concretely, `FSharpList :> IEnumerable` fails. + for arg in args.GetValue null :?> System.Collections.IEnumerable do + yield + match arg with + | :? TestCaseData as tcd -> runOne test.Method tcd.Arguments + | :? Tuple as (a, b) -> runOne test.Method [| a ; b |] + | :? Tuple as (a, b, c) -> runOne test.Method [| a ; b ; c |] + | :? Tuple as (a, b, c, d) -> + runOne test.Method [| a ; b ; c ; d |] + | arg -> runOne test.Method [| arg |] + } ) |> Seq.concat |> Seq.toList