Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cleaning up tests
  • Loading branch information
TIHan committed Apr 5, 2019
commit 2b06a30f1b0ac0f0d6d3612e56c5489894e43090
12 changes: 10 additions & 2 deletions tests/FSharp.Compiler.UnitTests/ILHelpers.fs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ module ILChecker =
p.WaitForExit()
p.StandardError.ReadToEnd(), p.ExitCode

/// Filters i.e ['The system type \'System.ReadOnlySpan`1\' was required but no referenced system DLL contained this type']
let private filterSpecialComment (text: string) =
let pattern = @"(\[\'(.*?)\'\])"
System.Text.RegularExpressions.Regex.Replace(text, pattern,
(fun me -> String.Empty)
)

let private checkAux extraDlls source expectedIL =
let Is64BitOperatingSystem = sizeof<nativeint> = 8
let architectureMoniker = if Is64BitOperatingSystem then "x64" else "x86"
Expand All @@ -57,8 +64,8 @@ module ILChecker =

File.WriteAllText(tmpFs, source)

let extraPackages = extraDlls |> Array.ofList |> Array.map (fun package -> "-r:" + package)
let errors, exitCode = checker.Compile(Array.append [| "fsc.exe"; "--optimize+"; "-o"; tmpDll; "-a"; tmpFs; |] extraPackages) |> Async.RunSynchronously
let extraReferences = extraDlls |> Array.ofList |> Array.map (fun reference -> "-r:" + reference)
let errors, exitCode = checker.Compile(Array.append [| "fsc.exe"; "--optimize+"; "-o"; tmpDll; "-a"; tmpFs; |] extraReferences) |> Async.RunSynchronously
let errors =
String.concat "\n" (errors |> Array.map (fun x -> x.Message))

Expand All @@ -78,6 +85,7 @@ module ILChecker =
if me.Value.StartsWith("//") then Environment.NewLine else String.Empty
else
me.Value), System.Text.RegularExpressions.RegexOptions.Singleline)
|> filterSpecialComment

expectedIL
|> List.iter (fun (ilCode: string) ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let test () =
IL_0006: ldc.i4.0
IL_0007: stloc.2
IL_0008: ldloca.s V_0
IL_000a: call instance int32 valuetype ['The system type \'System.Span`1\' was required but no referenced system DLL contained this type']System.Span`1<object>::get_Length()
IL_000a: call instance int32 valuetype System.Span`1<object>::get_Length()
IL_000f: ldc.i4.1
IL_0010: sub
IL_0011: stloc.1
Expand All @@ -48,7 +48,7 @@ let test () =

IL_0016: ldloca.s V_0
IL_0018: ldloc.2
IL_0019: call instance !0& valuetype ['The system type \'System.Span`1\' was required but no referenced system DLL contained this type']System.Span`1<object>::get_Item(int32)
IL_0019: call instance !0& valuetype System.Span`1<object>::get_Item(int32)
IL_001e: stloc.3
IL_001f: ldloc.3
IL_0020: ldobj [mscorlib]System.Object
Expand Down Expand Up @@ -97,7 +97,7 @@ let test () =
IL_0006: ldc.i4.0
IL_0007: stloc.2
IL_0008: ldloca.s V_0
IL_000a: call instance int32 valuetype ['The system type \'System.ReadOnlySpan`1\' was required but no referenced system DLL contained this type']System.ReadOnlySpan`1<object>::get_Length()
IL_000a: call instance int32 valuetype System.ReadOnlySpan`1<object>::get_Length()
IL_000f: ldc.i4.1
IL_0010: sub
IL_0011: stloc.1
Expand All @@ -107,7 +107,7 @@ let test () =

IL_0016: ldloca.s V_0
IL_0018: ldloc.2
IL_0019: call instance !0 valuetype ['The system type \'System.ReadOnlySpan`1\' was required but no referenced system DLL contained this type']System.ReadOnlySpan`1<object>::get_Item(int32)
IL_0019: call instance !0 valuetype System.ReadOnlySpan`1<object>::get_Item(int32)
IL_001e: call void [mscorlib]System.Console::WriteLine(object)
IL_0023: ldloc.2
IL_0024: ldc.i4.1
Expand Down