diff --git a/tests/FSharp.Test.Utilities/ScriptHelpers.fs b/tests/FSharp.Test.Utilities/ScriptHelpers.fs index 012c27c5198..2a31729dcaa 100644 --- a/tests/FSharp.Test.Utilities/ScriptHelpers.fs +++ b/tests/FSharp.Test.Utilities/ScriptHelpers.fs @@ -108,9 +108,15 @@ type FSharpScript(?additionalArgs: string[], ?quiet: bool, ?langVersion: LangVer member _.Fsi = fsi - member _.Eval(code: string, ?cancellationToken: CancellationToken) = + member _.Eval(code: string, ?cancellationToken: CancellationToken, ?desiredCulture: Globalization.CultureInfo) = + let originalCulture = Thread.CurrentThread.CurrentCulture + Thread.CurrentThread.CurrentCulture <- Option.defaultValue Globalization.CultureInfo.InvariantCulture desiredCulture + let cancellationToken = defaultArg cancellationToken CancellationToken.None let ch, errors = fsi.EvalInteractionNonThrowing(code, cancellationToken) + + Thread.CurrentThread.CurrentCulture <- originalCulture + match ch with | Choice1Of2 v -> Ok(v), errors | Choice2Of2 ex -> Error(ex), errors