Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace FSharp.Compiler.ComponentTests.CompilerOptions

open FSharp.Test
open FSharp.Test.Compiler
open Xunit

module Checked =

// SOURCE=unchecked01.fs # fsc-default
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"unchecked01.fs"|])>]
let ``fsc-unchecked - unchecked01.fs`` compilation =
compilation
|> asFs
|> compile
|> shouldSucceed

// SOURCE=checked01.fs SCFLAGS="--checked" # fsc-checked
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"unchecked01.fs"|])>]
let ``fsc-unchecked - unchecked01.fs --checked`` compilation =
compilation
|> asFs
|> withOptions["--checked"]
|> compile
|> shouldSucceed

// SOURCE=checked01.fs SCFLAGS="--checked+" # fsc-checked+
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"unchecked01.fs"|])>]
let ``fsc-unchecked - unchecked01.fs --checked+`` compilation =
compilation
|> asFs
|> withOptions["--checked+"]
|> compile
|> shouldSucceed

// SOURCE=unchecked01.fs SCFLAGS="--checked-" # fsc-checked-
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"unchecked01.fs"|])>]
let ``fsc-unchecked - unchecked01.fs --checked-`` compilation =
compilation
|> asFs
|> withOptions["--checked-"]
|> compile
|> shouldSucceed

// SOURCE=unchecked01.fs SCFLAGS="--checked-" # fsc-checked-
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"unchecked01.fs"|])>]
let ``fsi-unchecked - unchecked01.fs --checked-`` compilation =
compilation
|> asFsx
|> withOptions["--checked-"]
|> compile
|> shouldSucceed

// SOURCE=checked01.fs SCFLAGS="--checked" FSIMODE=EXEC COMPILE_ONLY=1 # fsi-checked
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"checked01.fs"|])>]
let ``fsi-checked - checked01.fs --checked`` compilation =
compilation
|> asFsx
|> withOptions["--checked"]
|> compile
|> shouldSucceed

// SOURCE=checked01.fs SCFLAGS="--checked+" FSIMODE=EXEC COMPILE_ONLY=1 # fsi-checked+
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"checked01.fs"|])>]
let ``fsi-checked - checked01.fs --checked+`` compilation =
compilation
|> asFsx
|> withOptions["--checked+"]
|> compile
|> shouldSucceed

// SOURCE=checked01.fs SCFLAGS="--checked-" FSIMODE=EXEC COMPILE_ONLY=1 # fsi-checked+
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"checked01.fs"|])>]
let ``fsi-checked - checked01.fs --checked-`` compilation =
compilation
|> asFsx
|> withOptions["--checked-"]
|> compile
|> shouldSucceed


//# Last one wins

// SOURCE=checked01.fs SCFLAGS="--checked --checked+" # fsc-checkedchecked+
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"checked01.fs"|])>]
let ``fsc-checked - checked01.fs --checked --checked+`` compilation =
compilation
|> asFs
|> withOptions["--checked"; "--checked+"]
|> compile
|> shouldSucceed

// SOURCE=checked01.fs SCFLAGS="--checked- --checked+" # fsc-checked-checked+
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"checked01.fs"|])>]
let ``fsc-checked - checked01.fs --checked- --checked+`` compilation =
compilation
|> asFs
|> withOptions["--checked-"; "--checked+"]
|> compile
|> shouldSucceed

// SOURCE=unchecked01.fs SCFLAGS="--checked+ --checked-" # fsc-checked+checked-
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"unchecked01.fs"|])>]
let ``fsc-checked - unchecked01.fs --checked+ --checked-`` compilation =
compilation
|> asFs
|> withOptions["--checked+"; "--checked-"]
|> compile
|> shouldSucceed

// SOURCE=checked01.fs SCFLAGS="--checked --checked+" # fsc-checkedchecked+
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"checked01.fs"|])>]
let ``fsi-checked - checked01.fs --checked --checked+`` compilation =
compilation
|> asFsx
|> withOptions["--checked"; "--checked+"]
|> compile
|> shouldSucceed

// SOURCE=checked01.fs SCFLAGS="--checked- --checked+" # fsc-checked-checked+
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"checked01.fs"|])>]
let ``fsi-checked - checked01.fs --checked- --checked+`` compilation =
compilation
|> asFsx
|> withOptions["--checked-"; "--checked+"]
|> compile
|> shouldSucceed

// SOURCE=unchecked01.fs SCFLAGS="--checked+ --checked-" # fsc-checked+checked-
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"unchecked01.fs"|])>]
let ``fsi-checked - unchecked01.fs --checked+ --checked-`` compilation =
compilation
|> asFsx
|> withOptions["--checked+"; "--checked-"]
|> compile
|> shouldSucceed

//# Unrecognized argument
// SOURCE=unrecogarg.fs SCFLAGS="--Checked" # fsc--Checked
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"unrecogarg.fs"|])>]
let ``fsc-checked - unchecked01.fs Checked`` compilation =
compilation
|> asFs
|> withOptions["--Checked"]
|> compile
|> shouldFail
|> withDiagnostics [
(Error 243, Line 0, Col 1, Line 0, Col 1, "Unrecognized option: '--Checked'")
]

// SOURCE=unrecogarg.fs SCFLAGS="--checked*" # fsc--checked*
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"unrecogarg.fs"|])>]
let ``fsc-checked - unchecked01.fs --checked-star`` compilation =
compilation
|> asFs
|> withOptions["--checked*"]
|> compile
|> shouldFail
|> withDiagnostics [
(Error 243, Line 0, Col 1, Line 0, Col 1, "Unrecognized option: '--checked*'")
]

// SOURCE=unrecogarg.fs SCFLAGS="--checked*" # fsc--checked*
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"UncheckedDefaultOf01.fs"|])>]
let ``fsc-checked - UncheckedDefaultOf01`` compilation =
compilation
|> asFs
|> asExe
|> compile
|> shouldSucceed
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace FSharp.Compiler.ComponentTests.CompilerOptions

open Xunit
open FSharp.Test
open FSharp.Test.Compiler

module cliversion =

//# SOURCE=E_fsc_cliversion.fs SCFLAGS="--cliversion:2.0" # fsc --cliversion:2.0
[<Fact>]
let ``fsc --cliversion:2.0``() =
FSharp """
"""
|> asExe
|> withOptions ["--cliversion:2.0"]
|> compile
|> shouldFail
|> withDiagnostics [
(Error 243, Line 0, Col 1, Line 0, Col 1, "Unrecognized option: '--cliversion'")
]

//# SOURCE=E_fsi_cliversion.fs SCFLAGS="--cliversion:2.0" FSIMODE=EXEC COMPILE_ONLY=1 # fsi --cliversion:2.0
[<Fact>]
let ``fsi --cliversion:2.0``() =
FSharp """
"""
|> asFsx
|> withOptions ["--cliversion:2.0"]
|> compile
|> shouldFail
|> withDiagnostics [
(Error 243, Line 0, Col 1, Line 0, Col 1, "Unrecognized option: '--cliversion'")
]

Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@
<Compile Include="Scripting\Interactive.fs" />
<Compile Include="TypeChecks\CheckDeclarationsTests.fs" />
<Compile Include="TypeChecks\ParallelCheckingWithSignatureFilesTests.fs" />
<Compile Include="CompilerOptions\fsc\checked\checked.fs" />
<Compile Include="CompilerOptions\fsc\cliversion.fs" />
<Compile Include="CompilerOptions\fsc\langversion.fs" />
<Compile Include="CompilerOptions\fsc\noframework\noframework.fs" />
<Compile Include="CompilerOptions\fsc\platform\platform.fs" />
Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Test.Utilities/CompilerAssert.fs
Original file line number Diff line number Diff line change
Expand Up @@ -565,7 +565,7 @@ module rec CompilerAssertHelpers =
"tfm": "net7.0",
"framework": {
"name": "Microsoft.NETCore.App",
"version": "6.0"
"version": "7.0"
}
}
}"""
Expand Down
2 changes: 1 addition & 1 deletion tests/FSharp.Test.Utilities/FSharp.Test.Utilities.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</EmbeddedResource>
</ItemGroup>
<ItemGroup />

</Project>
6 changes: 2 additions & 4 deletions tests/FSharp.Test.Utilities/Utilities.fs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ module Utilities =
<TargetFramework>$TARGETFRAMEWORK</TargetFramework>
<UseFSharpPreview>true</UseFSharpPreview>
<DisableImplicitFSharpCoreReference>true</DisableImplicitFSharpCoreReference>
<DotnetFscCompilerPath>$DOTNETFSCCOMPILERPATH</DotnetFscCompilerPath>
</PropertyGroup>

<ItemGroup><Compile Include="Program.fs" /></ItemGroup>
Expand Down Expand Up @@ -171,7 +170,6 @@ let main argv = 0"""
let pathToTemp = Path.Combine(pathToArtifacts, "Temp")
let projectDirectory = Path.Combine(pathToTemp,Guid.NewGuid().ToString() + ".tmp")
let pathToFSharpCore = typeof<RequireQualifiedAccessAttribute>.Assembly.Location
let dotNetFscCompilerPath = config.DOTNETFSCCOMPILERPATH
try
try
Directory.CreateDirectory(projectDirectory) |> ignore
Expand All @@ -181,9 +179,9 @@ let main argv = 0"""
let directoryBuildTargetsFileName = Path.Combine(projectDirectory, "Directory.Build.targets")
let frameworkReferencesFileName = Path.Combine(projectDirectory, "FrameworkReferences.txt")
#if NETCOREAPP
File.WriteAllText(projectFileName, projectFile.Replace("$TARGETFRAMEWORK", "net7.0").Replace("$FSHARPCORELOCATION", pathToFSharpCore).Replace("$DOTNETFSCCOMPILERPATH", dotNetFscCompilerPath))
File.WriteAllText(projectFileName, projectFile.Replace("$TARGETFRAMEWORK", "net7.0").Replace("$FSHARPCORELOCATION", pathToFSharpCore))
#else
File.WriteAllText(projectFileName, projectFile.Replace("$TARGETFRAMEWORK", "net472").Replace("$FSHARPCORELOCATION", pathToFSharpCore).Replace("$DOTNETFSCCOMPILERPATH", dotNetFscCompilerPath))
File.WriteAllText(projectFileName, projectFile.Replace("$TARGETFRAMEWORK", "net472").Replace("$FSHARPCORELOCATION", pathToFSharpCore))
#endif
File.WriteAllText(programFsFileName, programFs)
File.WriteAllText(directoryBuildPropsFileName, directoryBuildProps)
Expand Down
29 changes: 0 additions & 29 deletions tests/fsharpqa/Source/CompilerOptions/fsc/checked/env.lst

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.