From f3290f3400b256c4e27f9df91b1fd672b5b8070b Mon Sep 17 00:00:00 2001 From: cartermp Date: Wed, 5 Aug 2020 14:32:49 -0700 Subject: [PATCH] Add withPreview to compiler testing API --- .../Language/CodeQuotationTests.fs | 2 +- tests/FSharp.Test.Utilities/Compiler.fs | 5 +++++ tests/fsharp/Compiler/Language/WitnessTests.fs | 2 +- 3 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs b/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs index 03712d32e1a..04e39bdb824 100644 --- a/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/Language/CodeQuotationTests.fs @@ -36,6 +36,6 @@ let z : unit = failwithf "did not expect expression for 'z': %A" e """ |> asExe - |> withOptions ["--langversion:preview"] + |> withPreview |> compileAndRun |> shouldSucceed diff --git a/tests/FSharp.Test.Utilities/Compiler.fs b/tests/FSharp.Test.Utilities/Compiler.fs index b31da1d4866..4e1850dbdc8 100644 --- a/tests/FSharp.Test.Utilities/Compiler.fs +++ b/tests/FSharp.Test.Utilities/Compiler.fs @@ -176,6 +176,11 @@ module rec Compiler = | FS fs -> FS { fs with Options = options } | _ -> failwith "withOptions is only supported n F#" + let withPreview (cUnit: CompilationUnit) : CompilationUnit = + match cUnit with + | FS fs -> FS { fs with Options = [ "--langversion:preview" ] } + | _ -> failwith "withPreview is only supported in F#" + let asLibrary (cUnit: CompilationUnit) : CompilationUnit = match cUnit with | FS fs -> FS { fs with OutputType = CompileOutput.Library } diff --git a/tests/fsharp/Compiler/Language/WitnessTests.fs b/tests/fsharp/Compiler/Language/WitnessTests.fs index 67f383c7827..f5f94eb9756 100644 --- a/tests/fsharp/Compiler/Language/WitnessTests.fs +++ b/tests/fsharp/Compiler/Language/WitnessTests.fs @@ -19,7 +19,7 @@ module WitnessTests = """ (dir ++ "provider.fsx")) |> asExe |> ignoreWarnings - |> withOptions ["--langversion:preview"] + |> withPreview |> compile |> shouldSucceed |> ignore