11// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
22
3- [<AutoOpen>]
4- module FSharp.Compiler.UnitTests.CompilerAssert
3+ namespace FSharp.TestHelpers
54
65open System
76open System.Diagnostics
@@ -20,7 +19,7 @@ open NUnit.Framework
2019open System.Reflection .Emit
2120open Microsoft.CodeAnalysis
2221open Microsoft.CodeAnalysis .CSharp
23- open FSharp.Compiler . UnitTests .Utilities
22+ open FSharp.TestHelpers .Utilities
2423
2524[<Sealed>]
2625type ILVerifier ( dllFilePath : string ) =
@@ -56,8 +55,8 @@ type CompileOutput =
5655 | Library
5756 | Exe
5857
59- type CompilationReference =
60- private
58+ type CompilationReference =
59+ private
6160 | CompilationReference of Compilation * staticLink : bool
6261 | TestCompilationReference of TestCompilation
6362
@@ -254,11 +253,11 @@ let main argv = 0"""
254253 |> Array.map ( fun info ->
255254 ( info.Severity, info.ErrorNumber, ( info.StartLineAlternate - libAdjust, info.StartColumn + 1 , info.EndLineAlternate - libAdjust, info.EndColumn + 1 ), info.Message))
256255
257- let checkEqual k a b =
258- if a <> b then
256+ let checkEqual k a b =
257+ if a <> b then
259258 Assert.AreEqual( a, b, sprintf " Mismatch in %s , expected '%A ', got '%A '.\n All errors:\n %A " k a b errors)
260259
261- checkEqual " Errors" ( Array.length expectedErrors) errors.Length
260+ checkEqual " Errors" ( Array.length expectedErrors) errors.Length
262261
263262 Array.zip errors expectedErrors
264263 |> Array.iter ( fun ( actualError , expectedError ) ->
@@ -278,16 +277,16 @@ let main argv = 0"""
278277 let compilationRefs , deps =
279278 match cmpl with
280279 | Compilation(_, _, _, _, cmpls, _) ->
281- let compiledRefs =
280+ let compiledRefs =
282281 cmpls
283282 |> List.map ( fun cmpl ->
284283 match cmpl with
285284 | CompilationReference ( cmpl, staticLink) ->
286285 compileCompilationAux outputPath disposals ignoreWarnings cmpl, staticLink
287- | TestCompilationReference ( cmpl) ->
286+ | TestCompilationReference ( cmpl) ->
288287 let tmp = Path.Combine( outputPath, Path.ChangeExtension( Path.GetRandomFileName(), " .dll" ))
289- disposals.Add({ new IDisposable with
290- member _. Dispose() =
288+ disposals.Add({ new IDisposable with
289+ member _. Dispose() =
291290 try File.Delete tmp with | _ -> () })
292291 cmpl.EmitAsFile tmp
293292 (([||], tmp), []), false )
@@ -330,14 +329,14 @@ let main argv = 0"""
330329 match cmpl with
331330 | Compilation( source, _, _, _, _, _) -> source
332331
333- let options =
332+ let options =
334333 match cmpl with
335334 | Compilation(_, _, _, options, _, _) -> options
336335
337336 let nameOpt =
338337 match cmpl with
339338 | Compilation(_, _, _, _, _, nameOpt) -> nameOpt
340-
339+
341340 let disposal , res = compileDisposable outputPath isScript isExe ( Array.append options compilationRefs) nameOpt source
342341 disposals.Add disposal
343342
@@ -362,7 +361,7 @@ let main argv = 0"""
362361
363362 static member CompileWithErrors ( cmpl : Compilation , expectedErrors , ? ignoreWarnings ) =
364363 let ignoreWarnings = defaultArg ignoreWarnings false
365- lock gate ( fun () ->
364+ lock gate ( fun () ->
366365 compileCompilation ignoreWarnings cmpl ( fun (( errors , _ ), _ ) ->
367366 assertErrors 0 ignoreWarnings errors expectedErrors))
368367
@@ -374,7 +373,7 @@ let main argv = 0"""
374373 let beforeExecute = defaultArg beforeExecute ( fun _ _ -> ())
375374 let newProcess = defaultArg newProcess false
376375 let onOutput = defaultArg onOutput ( fun _ -> ())
377- lock gate ( fun () ->
376+ lock gate ( fun () ->
378377 compileCompilation ignoreWarnings cmpl ( fun (( errors , outputFilePath ), deps ) ->
379378 assertErrors 0 ignoreWarnings errors [||]
380379 beforeExecute outputFilePath deps
@@ -447,9 +446,9 @@ let main argv = 0"""
447446
448447 Assert.IsEmpty( typeCheckResults.Errors, sprintf " Type Check errors: %A " typeCheckResults.Errors)
449448
450- static member TypeCheckWithErrorsAndOptionsAgainstBaseLine options ( sourceFile : string ) =
449+ static member TypeCheckWithErrorsAndOptionsAgainstBaseLine options ( sourceDirectory : string ) ( sourceFile : string ) =
451450 lock gate <| fun () ->
452- let absoluteSourceFile = System.IO.Path.Combine(__ SOURCE _ DIRECTORY __, " .. " , sourceFile)
451+ let absoluteSourceFile = System.IO.Path.Combine( sourceDirectory , sourceFile)
453452 let parseResults , fileAnswer =
454453 checker.ParseAndCheckFileInProject(
455454 sourceFile,
@@ -473,7 +472,7 @@ let main argv = 0"""
473472 let errorsActual =
474473 typeCheckResults.Errors
475474 |> Array.map ( sprintf " %A " )
476- |> String.concat " \n "
475+ |> String.concat " \n "
477476 File.WriteAllText( Path.ChangeExtension( absoluteSourceFile, " err" ), errorsActual)
478477
479478 Assert.AreEqual( errorsExpectedBaseLine.Replace( " \r\n " , " \n " ), errorsActual.Replace( " \r\n " , " \n " ))
@@ -489,7 +488,7 @@ let main argv = 0"""
489488 { defaultProjectOptions with OtherOptions = Array.append options defaultProjectOptions.OtherOptions})
490489 |> Async.RunSynchronously
491490
492- if parseResults.Errors.Length > 0 then
491+ if parseResults.Errors.Length > 0 then
493492 parseResults.Errors
494493 else
495494
0 commit comments