Skip to content

Commit 736e9c1

Browse files
enricosadaKevinRansom
authored andcommitted
Migrate "fsharpqa" suite to use NUnit
commit 9db27bae8df0444f794b70b12c4873cf55af08fc Merge: 2597c84 fc0ac12 Author: KevinRansom <[email protected]> Date: Thu Jan 21 16:49:35 2016 -0800 Merge branch 'fsharpqa_nunit' of https://github.com/enricosada/visualfsharp into enricosada-fsharpqa_nunit commit fc0ac127ea511ba84bc1ac2025973aacaafbef54 Author: enricosada <[email protected]> Date: Thu Jan 14 11:22:01 2016 +0100 add support for "<<OUTPUT" match commit c74d9202617e876ee589ea888f2ad8bb33e4552e Author: enricosada <[email protected]> Date: Wed Jan 13 12:59:55 2016 +0100 FIX TEST SPEC: use lowercase name for status attribute commit a86bb3baad8d7d101e01d99f944d5bd5ec025473 Author: enricosada <[email protected]> Date: Tue Jan 12 23:16:25 2016 +0100 FIX TEST SPEC: use valid xml commit 12d683d4ab10877757a99c1058cb35a997ffdb0f Author: enricosada <[email protected]> Date: Tue Jan 12 17:53:45 2016 +0100 deprecate some helper functions in tests attempt instead of processor computation ++ instead of / for Path.Combine commit e2d38c93c7d33a9398f0bf1c9d420643180d112c Author: enricosada <[email protected]> Date: Sun Jan 10 17:33:03 2016 +0100 add fsharpqa tests
1 parent 2597c84 commit 736e9c1

File tree

13 files changed

+2301
-7
lines changed

13 files changed

+2301
-7
lines changed

src/fsharp.sln

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Tests", "Tests", "{E49B77EA
3737
EndProject
3838
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharp.Tests", "..\tests\fsharp\FSharp.Tests.fsproj", "{C163E892-5BF7-4B59-AA99-B0E8079C67C4}"
3939
EndProject
40+
Project("{F2A71F9B-5D33-465A-A702-920D77279786}") = "FSharpQA.Tests", "..\tests\fsharpqa\Source\FSharpQA.Tests.fsproj", "{21958DEB-133B-4760-A238-1293ED9687EC}"
41+
EndProject
4042
Global
4143
GlobalSection(SolutionConfigurationPlatforms) = preSolution
4244
Debug|Any CPU = Debug|Any CPU
@@ -89,6 +91,10 @@ Global
8991
{C163E892-5BF7-4B59-AA99-B0E8079C67C4}.Debug|Any CPU.Build.0 = Debug|Any CPU
9092
{C163E892-5BF7-4B59-AA99-B0E8079C67C4}.Release|Any CPU.ActiveCfg = Release|Any CPU
9193
{C163E892-5BF7-4B59-AA99-B0E8079C67C4}.Release|Any CPU.Build.0 = Release|Any CPU
94+
{21958DEB-133B-4760-A238-1293ED9687EC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
95+
{21958DEB-133B-4760-A238-1293ED9687EC}.Debug|Any CPU.Build.0 = Debug|Any CPU
96+
{21958DEB-133B-4760-A238-1293ED9687EC}.Release|Any CPU.ActiveCfg = Release|Any CPU
97+
{21958DEB-133B-4760-A238-1293ED9687EC}.Release|Any CPU.Build.0 = Release|Any CPU
9298
EndGlobalSection
9399
GlobalSection(SolutionProperties) = preSolution
94100
HideSolutionNode = FALSE
@@ -97,5 +103,6 @@ Global
97103
{88E2D422-6852-46E3-A740-83E391DC7973} = {E49B77EA-64DE-451A-A5E6-A6632FC1F03C}
98104
{A8D9641A-9170-4CF4-8FE0-6DB8C134E1B5} = {E49B77EA-64DE-451A-A5E6-A6632FC1F03C}
99105
{C163E892-5BF7-4B59-AA99-B0E8079C67C4} = {E49B77EA-64DE-451A-A5E6-A6632FC1F03C}
106+
{21958DEB-133B-4760-A238-1293ED9687EC} = {E49B77EA-64DE-451A-A5E6-A6632FC1F03C}
100107
EndGlobalSection
101108
EndGlobal

tests/fsharp/PlatformHelpers.fs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -175,8 +175,8 @@ type AttemptBuilder() =
175175
this.While(enum.MoveNext,
176176
this.Delay(fun () -> body enum.Current)))
177177

178-
let processor = new AttemptBuilder()
179-
178+
let attempt = new AttemptBuilder()
179+
let processor = attempt //TODO deprecated
180180

181181
let log format = Printf.ksprintf (printfn "%s") format
182182

@@ -201,4 +201,13 @@ let redirectTo (writer: TextWriter) =
201201

202202
let redirectToLog () = redirectTo System.Console.Out
203203

204-
let inline (/) a (b: string) = System.IO.Path.Combine(a,b)
204+
let inline (++) a (b: string) = System.IO.Path.Combine(a,b)
205+
let inline (/) a b = a ++ b //TODO deprecated
206+
207+
let splitAtFirst (c: char -> bool) (s: string) =
208+
let rec helper x (rest: string) =
209+
match x with
210+
| [] -> rest, None
211+
| x :: xs when c(x) -> rest, Some (xs |> Array.ofList |> System.String)
212+
| x :: xs -> helper xs (rest + x.ToString())
213+
helper (s.ToCharArray() |> List.ofArray) ""

tests/fsharpqa/Source/.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
#ignore all build outputs
3+
*.exe
4+
*.dll
5+
*.pdb

tests/fsharpqa/Source/Conformance/LexicalAnalysis/Comments/E_embeddedString005.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// #Regression #Conformance #LexicalAnalysis
22
// string embedded in a comment: malformed string
33
// which yield to a compilation error
4-
//<Expects Status="error" id="FS0517" span="(9,1-9,3)>End of file in string embedded in comment begun at or before here</Expects>
4+
//<Expects status="error" id="FS0517" span="(9,1-9,3)>End of file in string embedded in comment begun at or before here</Expects>
55

66

77

tests/fsharpqa/Source/EnvLst.fs

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
module EnvLst
2+
3+
open System
4+
5+
open PlatformHelpers
6+
7+
type EnvLstFile = EnvLstLine list
8+
and EnvLstLine =
9+
| Comment of string
10+
| Data of EnvLstLineData
11+
and EnvLstLineData = {
12+
Tags: string list
13+
Vars: (string * string) list
14+
Comment: string option }
15+
16+
let private (|Comment|_|) (s: string) =
17+
match s with
18+
| s when s.StartsWith("#") -> Some (s.TrimStart([| '#' |]))
19+
| _ -> None
20+
21+
[<RequireQualifiedAccess>]
22+
type private DataPart =
23+
| Var of string * string
24+
| Comment of string
25+
26+
let private parseDataParts (from: string) =
27+
let rec parseDataPartsHelper (v: string) xs =
28+
match (v.TrimStart()) with
29+
| s when s.Trim() = "" ->
30+
Choice1Of2 xs
31+
| Comment (comment) ->
32+
Choice1Of2 (DataPart.Comment comment :: xs)
33+
| s ->
34+
match s |> splitAtFirst ((=) '=') with
35+
| name, None ->
36+
Choice2Of2 (sprintf "Expected '=' after %s" name)
37+
| name, Some(v) ->
38+
match v.TrimStart() with
39+
| a when a.StartsWith("\"") -> //quoted (escape char \ ), like SOURCE="some value with spaces"
40+
let rec innerQuote (alreadyParsed: string) (s: string) =
41+
let current, rest = match s with "" -> "","" | x -> (x.Substring(0,1)), (x.Substring(1))
42+
match alreadyParsed, current, rest with
43+
| pre, "", _ ->
44+
pre, ""
45+
| pre, "\"", xs when pre.EndsWith("\\") -> //escaped "
46+
innerQuote (pre + "\"") xs
47+
| pre, "\"", xs -> //final "
48+
pre, xs
49+
| pre, x, xs ->
50+
innerQuote (pre + x) xs
51+
let value, rest = innerQuote "" (a.Substring(1))
52+
parseDataPartsHelper rest (DataPart.Var(name, value) :: xs)
53+
| a -> //unquoted, like SOURCE=avalue
54+
let value, rest =
55+
match a |> splitAtFirst Char.IsWhiteSpace with
56+
| p0, None -> p0, ""
57+
| p0, Some (rest) -> p0, rest
58+
parseDataPartsHelper rest (DataPart.Var(name, value) :: xs)
59+
60+
match parseDataPartsHelper from [] with
61+
| Choice1Of2 parts -> parts |> List.rev |> Choice1Of2
62+
| failure -> failure
63+
64+
let parseLine (line: string) =
65+
match line with
66+
| s when s.Trim() = "" -> Choice1Of2 None
67+
| Comment(comment) -> Comment (comment) |> Some |> Choice1Of2
68+
| s ->
69+
match s |> splitAtFirst ((=) '\t') with
70+
| s, None -> Choice2Of2 (sprintf "Expected '\\t' not found")
71+
| tagList, Some rest ->
72+
let tags = tagList.Split([| " " |], StringSplitOptions.RemoveEmptyEntries)
73+
match parseDataParts rest with
74+
| Choice1Of2 parts ->
75+
let vars =
76+
parts
77+
|> List.choose (function DataPart.Var (k,v) -> Some (k,v) | _ -> None)
78+
let comment =
79+
parts
80+
|> List.choose (function DataPart.Comment c -> Some c | _ -> None)
81+
|> List.tryHead
82+
Data { Tags = tags |> List.ofArray; Vars = vars; Comment = comment }
83+
|> Some |> Choice1Of2
84+
| Choice2Of2 failure ->
85+
Choice2Of2 failure
86+
87+
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<FSharpSourcesRoot>..\..\..\src</FSharpSourcesRoot>
5+
<FSharpTestsRoot>..\..\..\tests</FSharpTestsRoot>
6+
<ProjectGuid>{21958DEB-133B-4760-A238-1293ED9687EC}</ProjectGuid>
7+
</PropertyGroup>
8+
<Import Project="$(FSharpSourcesRoot)\FSharpSource.Settings.targets" />
9+
<PropertyGroup>
10+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
11+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
12+
<SchemaVersion>2.0</SchemaVersion>
13+
<AllowCrossTargeting>true</AllowCrossTargeting>
14+
<ReferenceVsAssemblies>true</ReferenceVsAssemblies>
15+
<OutputType>Library</OutputType>
16+
<AssemblyName>FSharp.Tests.FSharpQA</AssemblyName>
17+
<Name>SystematicUnitTests</Name>
18+
<!-- Prevent compiler from inlining calls to FSharp.Core to improve code coverage accuracy -->
19+
<Optimize>false</Optimize>
20+
<Tailcalls>false</Tailcalls>
21+
</PropertyGroup>
22+
<PropertyGroup>
23+
<DefineConstants>$(DefineConstants);EXTENSIONTYPING</DefineConstants>
24+
<NoWarn>$(NoWarn);3180</NoWarn>
25+
</PropertyGroup>
26+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
27+
<DebugSymbols>true</DebugSymbols>
28+
<DebugType>full</DebugType>
29+
<Optimize>false</Optimize>
30+
<OutputPath>bin\Debug\</OutputPath>
31+
<DefineConstants>DEBUG;TRACE</DefineConstants>
32+
<ErrorReport>prompt</ErrorReport>
33+
<WarningLevel>3</WarningLevel>
34+
</PropertyGroup>
35+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
36+
<DebugType>pdbonly</DebugType>
37+
<Optimize>true</Optimize>
38+
<OutputPath>bin\Release\</OutputPath>
39+
<DefineConstants>TRACE</DefineConstants>
40+
<ErrorReport>prompt</ErrorReport>
41+
<WarningLevel>3</WarningLevel>
42+
</PropertyGroup>
43+
<Import Project="$(FSharpSourcesRoot)\FSharpSource.targets" />
44+
<ItemGroup>
45+
<ProjectReference Include="$(FSharpSourcesRoot)\fsharp\FSharp.Core\FSharp.Core.fsproj">
46+
<Project>{DED3BBD7-53F4-428A-8C9F-27968E768605}</Project>
47+
<Name>FSharp.Core</Name>
48+
</ProjectReference>
49+
<Reference Include="mscorlib" />
50+
<Reference Include="nunit.framework">
51+
<HintPath>..\..\..\packages\NUnit.3.0.0\lib\net45\nunit.framework.dll</HintPath>
52+
<Private>True</Private>
53+
</Reference>
54+
<Reference Include="System" />
55+
<Reference Include="System.Core" />
56+
<Reference Include="System.Xml" />
57+
<Reference Include="System.Xml.Linq" />
58+
</ItemGroup>
59+
<ItemGroup>
60+
<Compile Include="$(FSharpTestsRoot)\fsharp\PlatformHelpers.fs">
61+
<Link>PlatformHelpers.fs</Link>
62+
</Compile>
63+
<Compile Include="$(FSharpTestsRoot)\fsharp\Commands.fs">
64+
<Link>Commands.fs</Link>
65+
</Compile>
66+
<Compile Include="$(FSharpTestsRoot)\fsharp\FSharpTestSuiteTypes.fs">
67+
<Link>FSharpTestSuiteTypes.fs</Link>
68+
</Compile>
69+
<Compile Include="$(FSharpTestsRoot)\windowsPlatform.fs">
70+
<Link>windowsPlatform.fs</Link>
71+
</Compile>
72+
<Compile Include="$(FSharpTestsRoot)\config.fs">
73+
<Link>config.fs</Link>
74+
</Compile>
75+
<Compile Include="$(FSharpSourcesRoot)\update.fs">
76+
<Link>update.fs</Link>
77+
</Compile>
78+
<Compile Include="EnvLst.fs" />
79+
<Compile Include="nunitConf.fs" />
80+
<Compile Include="run.fs" />
81+
</ItemGroup>
82+
<ItemGroup>
83+
<Compile Include="test_EnvLst.fs" />
84+
</ItemGroup>
85+
<ItemGroup>
86+
<Compile Include="test_simple.fs" />
87+
</ItemGroup>
88+
</Project>

tests/fsharpqa/Source/InteractiveSession/Misc/LoadOrderOfExecution3a.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// #Regression #NoMT #FSI
22
// Regression test for FSHARP1.0:5427
3-
//<Expects Status="success"></Expects>
3+
//<Expects status="success"></Expects>
44

55
//<<Output
66
//let f x = x \+ 1

tests/fsharpqa/Source/Libraries/Core/Collections/Seq_Cast_Dispose01.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
// This test should probably go under the SystematicUnitTests suite, but
77
// I could not decide how to make it fit... so I'm leaving it here.
88
//
9-
//<Expect status=success><Expect>
9+
//<Expect status="success"></Expect>
1010

1111
let mutable dispose_called_in_E = 0 // we expect this to be incremented 3 times
1212
let mutable dispose_called_in_C = 0 // we expect this to be incremented once (=this is what the bug was about, i.e. .Dispose() was never invoked)

tests/fsharpqa/Source/Simple/hellow.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//<Expects Status=success></Expects>
1+
//<Expects status="success"></Expects>
22

33
//<<Output
44
//Hello, world.

0 commit comments

Comments
 (0)