未验证 提交 271dd95d 编写于 作者: K Kevin Ransom (msft) 提交者: GitHub

Fsharpqa (#13053)

上级 f207669f
......@@ -3,5 +3,3 @@
//<Expects id="FS0534" status="error" span="(5,1)">A module abbreviation must be a simple name, not a path</Expects>
module MS.FS.Co.L = Microsoft.FSharp.Collections.List
exit 1
......@@ -11,6 +11,4 @@ let ListMod x = [x]
module ListMod = Microsoft.FSharp.Collections.List
// Error: function wins due to name resolution rules
if ListMod.sum [1; 2; 3] <> 6 then exit 1
exit 1
if ListMod.sum [1; 2; 3] <> 6 then failwith "Failed: 1"
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace FSharp.Compiler.ComponentTests.Conformance.DeclarationElements
open Xunit
open FSharp.Test
open FSharp.Test.Compiler
module ModuleAbbreviations =
let verifyCompile compilation =
compilation
|> asExe
|> withOptions ["--nowarn:988"]
|> compile
let verifyCompileAndRun compilation =
compilation
|> asExe
|> withOptions ["--nowarn:988"]
|> compileAndRun
// SOURCE=E_AbbreviationOnNamespace01.fs SCFLAGS="--test:ErrorRanges" # E_AbbreviationOnNamespace01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AbbreviationOnNamespace01.fs"|])>]
let ``E_AbbreviationOnNamespace01_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 965, Line 11, Col 1, Line 11, Col 22, "The path 'System.IO' is a namespace. A module abbreviation may not abbreviate a namespace.")
(Error 39, Line 13, Col 15, Line 13, Col 17, "The value, namespace, type or module 'IO' is not defined.")
(Error 965, Line 16, Col 1, Line 16, Col 43, "The path 'System.Text.RegularExpressions' is a namespace. A module abbreviation may not abbreviate a namespace.")
(Error 39, Line 18, Col 19, Line 18, Col 21, "The namespace or module 'rx' is not defined.")
(Error 72, Line 21, Col 4, Line 21, Col 19, "Lookup on object of indeterminate type based on information prior to this program point. A type annotation may be needed prior to this program point to constrain the type of the object. This may allow the lookup to be resolved.")
]
// SOURCE=E_InvalidAbbrevName01.fs SCFLAGS="--test:ErrorRanges" # E_InvalidAbbrevName01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_InvalidAbbrevName01.fs"|])>]
let ``E_InvalidAbbrevName01_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 10, Line 5, Col 11, Line 5, Col 12, "Unexpected symbol '$' in definition. Expected incomplete structured construct at or before this point or other token.")
]
// SOURCE=E_InvalidAbbrevName02.fs # E_InvalidAbbrevName02.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_InvalidAbbrevName02.fs"|])>]
let ``E_InvalidAbbrevName02_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 534, Line 5, Col 1, Line 5, Col 18, "A module abbreviation must be a simple name, not a path")
]
// SOURCE=E_NameConflict01.fs # E_NameConflict01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_NameConflict01.fs"|])>]
let ``E_NameConflict01_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 39, Line 14, Col 12, Line 14, Col 15, "The field, constructor or member 'sum' is not defined.")
]
// SOURCE=E_UseInsideFunc.fs SCFLAGS="--test:ErrorRanges" # E_UseInsideFunc.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_UseInsideFunc.fs"|])>]
let ``E_UseInsideFunc_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 10, Line 7, Col 5, Line 7, Col 11, "Incomplete structured construct at or before this point in binding")
]
// SOURCE=SanityCheck.fs # SanityCheck.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"SanityCheck.fs"|])>]
let ``SanityCheck_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=SanityCheck02.fs # SanityCheck02.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"SanityCheck02.fs"|])>]
let ``SanityCheck02_fs`` compilation =
compilation
|> withNoWarn 1104
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=useInsideModuleDef.fs # useInsideModuleDef.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"useInsideModuleDef.fs"|])>]
let ``useInsideModuleDef_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=useInsideNamespaceDef.fs COMPILE_ONLY=1 # useInsideNamespaceDef.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"useInsideNamespaceDef.fs"|])>]
let ``useInsideNamespaceDef_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// NoMT SOURCE=useInsideNamespaceDefExternal.fs PRECMD="\$FSC_PIPE -a useInsideNamespaceDefExternal_DLL.fs" SCFLAGS="-r:useInsideNamespaceDefExternal_DLL.dll" # useInsideNamespaceDefExternal.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"useInsideNamespaceDefExternal.fs"|])>]
let ``useInsideNamespaceDefExternal_fs`` compilation =
let useInsideNamespaceDefExternal_DLL =
FsFromPath(__SOURCE_DIRECTORY__ ++ "useInsideNamespaceDefExternal_DLL.fs")
|> asLibrary
|> withName "useInsideNamespaceDefExternal_DLL"
compilation
|> withReferences [useInsideNamespaceDefExternal_DLL]
|> verifyCompileAndRun
|> shouldSucceed
......@@ -17,4 +17,4 @@ module Abbreviated_A_B_C = A.B.C
let blue = int Abbreviated_A_B_C.X.Blue
let red = int Abbreviated_A_B.C.X.Red
if (blue = 2) && (red = 1) then 0 else 1
if (blue = 2) && (red = 1) then () else failwith "Failed: 1"
......@@ -6,6 +6,4 @@ module ``Some Crazy Identifier !@#`` = Microsoft.FSharp.Collections.List
let result = ``Some Crazy Identifier !@#``.sum [1; 2; 3]
if result <> 6 then exit 1
exit 0
if result <> 6 then failwith "Failed: 1"
......@@ -18,6 +18,4 @@ module TestModule1 =
let dsc = ABC.DirectorySeparatorChar
printfn "Current directory seperator char is %c" dsc
// If this compiles ok, then we are good to go
exit 0
......@@ -56,6 +56,7 @@
<Compile Include="Conformance\DeclarationElements\MemberDefinitions\OptionalArguments\OptionalArguments.fs" />
<Compile Include="Conformance\DeclarationElements\MemberDefinitions\OptionalDefaultParamArgs\OptionalDefaultParamArgs.fs" />
<Compile Include="Conformance\DeclarationElements\MemberDefinitions\OverloadingMembers\OverloadingMembers.fs" />
<Compile Include="Conformance\DeclarationElements\ModuleAbbreviations\ModuleAbbreviations.fs" />
<Compile Include="Conformance\DeclarationElements\UseBindings\UseBindings.fs" />
<Compile Include="Conformance\Expressions\ApplicationExpressions\BasicApplication\BasicApplication.fs" />
<Compile Include="Conformance\Expressions\BindingExpressions\BindingExpressions.fs" />
......
......@@ -169,6 +169,15 @@ module rec Compiler =
| Success of CompilationOutput
| Failure of CompilationOutput
type ExecutionPlatform =
| Anycpu = 0
| AnyCpu32bitPreferred = 1
| X86 = 2
| Itanium = 3
| X64 = 4
| Arm = 5
| Arm64 = 6
let private defaultOptions : string list = []
// Not very safe version of reading stuff from file, but we want to fail fast for now if anything goes wrong.
......@@ -427,6 +436,23 @@ module rec Compiler =
| FS fs -> FS { fs with OutputType = CompileOutput.Exe }
| _ -> failwith "TODO: Implement where applicable."
let withPlatform (platform:ExecutionPlatform) (cUnit: CompilationUnit) : CompilationUnit =
match cUnit with
| FS _ ->
let p =
match platform with
| ExecutionPlatform.Anycpu -> "anycpu"
| ExecutionPlatform.AnyCpu32bitPreferred -> "anycpu32bitpreferred"
| ExecutionPlatform.Itanium -> "itanium"
| ExecutionPlatform.X64 -> "x64"
| ExecutionPlatform.X86 -> "x86"
| ExecutionPlatform.Arm -> "arm"
| ExecutionPlatform.Arm64 -> "arm64"
| _ -> failwith $"Unknown value for ExecutionPlatform: {platform}"
withOptionsHelper [ $"--platform:{p}" ] "withPlatform is only supported for F#" cUnit
| _ -> failwith "TODO: Implement ignorewarnings for the rest."
let ignoreWarnings (cUnit: CompilationUnit) : CompilationUnit =
match cUnit with
| FS fs -> FS { fs with IgnoreWarnings = true }
......
SOURCE=SanityCheck.fs # SanityCheck.fs
SOURCE=SanityCheck02.fs # SanityCheck02.fs
SOURCE=useInsideModuleDef.fs # useInsideModuleDef.fs
SOURCE=useInsideNamespaceDef.fs COMPILE_ONLY=1 # useInsideNamespaceDef.fs
SOURCE=W_AbbreviationOnNamespace01.fs SCFLAGS="--test:ErrorRanges" # W_AbbreviationOnNamespace01.fs
NoMT SOURCE=useInsideNamespaceDefExternal.fs PRECMD="\$FSC_PIPE -a useInsideNamespaceDefExternal_DLL.fs" SCFLAGS="-r:useInsideNamespaceDefExternal_DLL.dll" # useInsideNamespaceDefExternal.fs
SOURCE=E_UseInsideFunc.fs SCFLAGS="--test:ErrorRanges" # E_UseInsideFunc.fs
SOURCE=E_NameConflict01.fs # E_NameConflict01.fs
SOURCE=E_InvalidAbbrevName01.fs SCFLAGS="--test:ErrorRanges" # E_InvalidAbbrevName01.fs
SOURCE=E_InvalidAbbrevName02.fs # E_InvalidAbbrevName02.fs
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册