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

Conformance (#13005)

* temp

* Conformance/BasicTypeAndModuleDefinitions/ModuleDefinitions

* Conformance/BasicTypeAndModuleDefinitions/NamespaceDeclGroups

* env

* BasicTypeAndModuleDefinitions/NullRepresentations

* Conformance/BasicTypeAndModuleDefinitions/TypeAbbreviations

* exits

* Conformance/BasicTypeAndModuleDefinitions/UnionTypes
上级 2bdc0989
......@@ -11,4 +11,4 @@ module M =
// While processing the anonomous module (this file) nested module M
// will automatically be opened, bringing x into scope.
exit x
if x <> 0 then failwith "Failed: 1"
......@@ -12,4 +12,4 @@ module A =
// Since module A is not opened, B shouldn't
// be auto opened, leading to the build error.
exit x
if x <> 0 then failwith "Failed: 1"
......@@ -20,10 +20,8 @@ module MyModule =
if x <> 1 then exit 1
if MyNestedModule.f x <> 2 then exit 1
if x <> 1 then failwith "Failed: 1"
if MyNestedModule.f x <> 2 then failwith "Failed: 2"
if MyOtherNestedModule.MyOtherNestedModuleTwo.x <> 10 then exit 1
if MyNestedModule.f MyOtherNestedModule.MyOtherNestedModuleTwo.x <> 11 then exit 1
exit 0
if MyOtherNestedModule.MyOtherNestedModuleTwo.x <> 10 then failwith "Failed: 3"
if MyNestedModule.f MyOtherNestedModule.MyOtherNestedModuleTwo.x <> 11 then failwith "Failed: 4"
......@@ -10,13 +10,10 @@ module Test =
module C =
module D =
let counter =
let x = ref 0
(fun () -> x := !x + 1; !x)
let mutable x = 0
(fun () -> x <- x + 1; x)
open A.B.C.D
if counter() <> 1 then exit 1
if counter() <> 1 then failwith "Failed 1"
if A.B.C.D.counter() <> 2 then exit 1
exit 0
if A.B.C.D.counter() <> 2 then failwith "Failed 2"
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace FSharp.Compiler.ComponentTests.Conformance.BasicTypeAndModuleDefinitions
open System.IO
open Xunit
open FSharp.Test
open FSharp.Test.Compiler
module ModuleDefinitions =
let verifyCompile compilation =
compilation
|> asExe
|> withOptions ["--nowarn:988"; "--nowarn:3370"]
|> compile
let verifyCompileAndRun compilation =
compilation
|> asExe
|> withOptions ["--nowarn:988"; "--nowarn:3370"]
|> compileAndRun
// SOURCE=AutoOpen01.fs # AutoOpen01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"AutoOpen01.fs"|])>]
let ``AutoOpen01_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=AutoOpen02.fs # AutoOpen02.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"AutoOpen02.fs"|])>]
let ``AutoOpen02_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 39, Line 15, Col 4, Line 15, Col 5, "The value or constructor 'x' is not defined.")
]
// SOURCE=AutoOpen03.fs # AutoOpen03.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"AutoOpen03.fs"|])>]
let ``AutoOpen03_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=DefineModule01.fs # DefineModule01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"DefineModule01.fs"|])>]
let ``DefineModule01_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=E_CannotAccessPrivateMembersOfAnotherType.fs SCFLAGS="--test:ErrorRanges" COMPILE_ONLY=1 # E_CannotAccessPrivateMembersOfAnotherType.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_CannotAccessPrivateMembersOfAnotherType.fs"|])>]
let ``E_CannotAccessPrivateMembersOfAnotherType_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Warning 1178, Line 12, Col 10, Line 12, Col 17, "The struct, record or union type 'SpecSet' is not structurally comparable because the type 'SpecMulti' does not satisfy the 'comparison' constraint. Consider adding the 'NoComparison' attribute to the type 'SpecSet' to clarify that the type is not comparable")
(Error 491, Line 22, Col 13, Line 22, Col 27, "The member or object constructor 'Impl' is not accessible. Private members may only be accessed from within the declaring type. Protected members may only be accessed from an extending type and cannot be accessed from inner lambda expressions.")
]
// SOURCE=E_ModuleSuffix01.fsx SCFLAGS="--test:ErrorRanges" # E_ModuleSuffix01.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_ModuleSuffix01.fsx"|])>]
let ``E_ModuleSuffix01_fsx`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 37, Line 13, Col 8, Line 13, Col 18, "Duplicate definition of type or module 'module'")
]
// SOURCE=E_ModuleSuffix_NameClash01.fsx SCFLAGS="--test:ErrorRanges" # E_ModuleSuffix_NameClash01.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_ModuleSuffix_NameClash01.fsx"|])>]
let ``E_ModuleSuffix_NameClash01_fsx`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 37, Line 12, Col 1, Line 12, Col 15, "Duplicate definition of type, exception or module 'mModule'")
]
// SOURCE=E_ModuleWithExpression02.fs COMPILE_ONLY=1 SCFLAGS="--test:ErrorRanges" # E_ModuleWithExpression02.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_ModuleWithExpression02.fs"|])>]
let ``E_ModuleWithExpression02_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 39, Line 8, Col 12, Line 8, Col 20, "The namespace 'DateTime' is not defined.")
]
// SOURCE=E_ModuleWithSameNameInNamespace01.fsx SCFLAGS="--test:ErrorRanges" # E_ModuleWithSameNameInNamespace01.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_ModuleWithSameNameInNamespace01.fsx"|])>]
let ``E_ModuleWithSameNameInNamespace01_fsx`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 37, Line 9, Col 1, Line 9, Col 18, "Duplicate definition of type, exception or module 'module'")
]
// SOURCE="E_ModuleWithSameNameInNamespace02a.fsx E_ModuleWithSameNameInNamespace02b.fsx" SCFLAGS="--test:ErrorRanges" # E_ModuleWithSameNameInNamespace02
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_ModuleWithSameNameInNamespace02a.fsx"|])>]
let ``E_ModuleWithSameNameInNamespace02a_fsx`` compilation =
compilation
|> withAdditionalSourceFile (SourceFromPath (__SOURCE_DIRECTORY__ ++"E_ModuleWithSameNameInNamespace02b.fsx"))
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 248, Line 7, Col 8, Line 7, Col 18, "Two modules named 'N.module' occur in two parts of this assembly")
]
// SOURCE=E_ObsoleteAttribOnModules01.fs SCFLAGS="--test:ErrorRanges" # E_ObsoleteAttribOnModules01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_ObsoleteAttribOnModules01.fs"|])>]
let ``E_ObsoleteAttribOnModules01_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 101, Line 21, Col 10, Line 21, Col 24, "This construct is deprecated. Don't use this module.")
(Error 101, Line 22, Col 25, Line 22, Col 39, "This construct is deprecated. Don't use this module.")
(Error 101, Line 23, Col 14, Line 23, Col 28, "This construct is deprecated. Don't use this module.")
(Warning 44, Line 26, Col 21, Line 26, Col 41, "This construct is deprecated. Don't use this nested module.")
]
// SOURCE=FullyQualify01.fs # FullyQualify01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"FullyQualify01.fs"|])>]
let ``FullyQualify01_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=LightSyntax01.fsx # LightSyntax01.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"LightSyntax01.fsx"|])>]
let ``LightSyntax01_fsx`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=ModuleAbbreviationWithModule01.fs COMPILE_ONLY=1 SCFLAGS="--test:ErrorRanges" # ModuleAbbreviationWithModule01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ModuleAbbreviationWithModule01.fs"|])>]
let ``ModuleAbbreviationWithModule01_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE="Module_internal01.fs Module_internalConsumer01.fs" # Module_internal01
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Module_internal01.fs"|])>]
let ``Module_internal01_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=ModuleSuffix02.fsx # ModuleSuffix02.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ModuleSuffix02.fsx"|])>]
let ``ModuleSuffix02_fsx`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// NoMT SOURCE=ModuleSuffix03.fsx PRECMD="\$FSC_PIPE -a ModuleSuffix03Lib.fsx" SCFLAGS="-r:ModuleSuffix03Lib.dll" # ModuleSuffix03.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ModuleSuffix03.fsx"|])>]
let ``ModuleSuffix03_fsx`` compilation =
let lib =
FsFromPath (Path.Combine(__SOURCE_DIRECTORY__, "ModuleSuffix03Lib.fsx"))
|> withOptimize
|> asLibrary
compilation
|> withReferences [lib]
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=ModuleSuffix04.fsx # ModuleSuffix04.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ModuleSuffix04.fsx"|])>]
let ``ModuleSuffix04_fsx`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=ModuleWithExpression01.fs COMPILE_ONLY=1 SCFLAGS="--test:ErrorRanges" # ModuleWithExpression01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ModuleWithExpression01.fs"|])>]
let ``ModuleWithExpression01_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=ModuleWithExpression02.fs COMPILE_ONLY=1 SCFLAGS="--test:ErrorRanges" # ModuleWithExpression02.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ModuleWithExpression02.fs"|])>]
let ``ModuleWithExpression02_fs`` compilation =
compilation
|> asFsx
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=Production_ExceptionDefinition.fsx # Production_ExceptionDefinition.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Production_ExceptionDefinition.fsx"|])>]
let ``Production_ExceptionDefinition_fsx`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=Production_ImportDeclaration.fsx # Production_ImportDeclaration.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Production_ImportDeclaration.fsx"|])>]
let ``Production_ImportDeclaration_fsx`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=Production_LetBindings_Binding.fsx # Production_LetBindings_Binding.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Production_LetBindings_Binding.fsx"|])>]
let ``Production_LetBindings_Binding_fsx`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=Production_LetBindings_SideEff.fsx # Production_LetBindings_SideEff.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Production_LetBindings_SideEff.fsx"|])>]
let ``Production_LetBindings_SideEff_fsx`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=Production_ModuleAbbreviation.fsx # Production_ModuleAbbreviation.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Production_ModuleAbbreviation.fsx"|])>]
let ``Production_ModuleAbbreviation_fsx`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=Production_ModuleDefinition.fsx # Production_ModuleDefinition.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Production_ModuleDefinition.fsx"|])>]
let ``Production_ModuleDefinition_fsx`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=Production_OCamlCompat.fsx # Production_OCamlCompat.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Production_OCamlCompat.fsx"|])>]
let ``Production_OCamlCompat_fsx`` compilation =
compilation
|> withOcamlCompat
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=Production_TypeDefinitions.fsx # Production_TypeDefinitions.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Production_TypeDefinitions.fsx"|])>]
let ``Production_TypeDefinitions_fsx`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=W_ModuleAbbreviationWithNamespace01.fs COMPILE_ONLY=1 SCFLAGS="--test:ErrorRanges" # W_ModuleAbbreviationWithNamespace01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"W_ModuleAbbreviationWithNamespace01.fs"|])>]
let ``W_ModuleAbbreviationWithNamespace01_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 965, Line 8, Col 1, Line 9, Col 26, "The path 'Microsoft.FSharp.Core' is a namespace. A module abbreviation may not abbreviate a namespace.")
]
// SOURCE=W_Production_OCamlCompat.fsx SCFLAGS="--test:ErrorRanges" # W_Production_OCamlCompat.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"W_Production_OCamlCompat.fsx"|])>]
let ``W_Production_OCamlCompat_fsx`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Warning 62, Line 14, Col 13, Line 14, Col 19, "This construct is for ML compatibility. The syntax 'module ... = struct .. end' is not used in F# code. Consider using 'module ... = begin .. end'. You can disable this warning by using '--mlcompatibility' or '--nowarn:62'.")
(Warning 62, Line 18, Col 13, Line 18, Col 19, "This construct is for ML compatibility. The syntax 'module ... = struct .. end' is not used in F# code. Consider using 'module ... = begin .. end'. You can disable this warning by using '--mlcompatibility' or '--nowarn:62'.")
(Warning 62, Line 22, Col 13, Line 22, Col 19, "This construct is for ML compatibility. The syntax 'module ... = struct .. end' is not used in F# code. Consider using 'module ... = begin .. end'. You can disable this warning by using '--mlcompatibility' or '--nowarn:62'.")
(Warning 62, Line 26, Col 13, Line 26, Col 19, "This construct is for ML compatibility. The syntax 'module ... = struct .. end' is not used in F# code. Consider using 'module ... = begin .. end'. You can disable this warning by using '--mlcompatibility' or '--nowarn:62'.")
(Warning 62, Line 30, Col 13, Line 30, Col 19, "This construct is for ML compatibility. The syntax 'module ... = struct .. end' is not used in F# code. Consider using 'module ... = begin .. end'. You can disable this warning by using '--mlcompatibility' or '--nowarn:62'.")
(Warning 62, Line 35, Col 13, Line 35, Col 19, "This construct is for ML compatibility. The syntax 'module ... = struct .. end' is not used in F# code. Consider using 'module ... = begin .. end'. You can disable this warning by using '--mlcompatibility' or '--nowarn:62'.")
(Warning 62, Line 39, Col 13, Line 39, Col 19, "This construct is for ML compatibility. The syntax 'module ... = struct .. end' is not used in F# code. Consider using 'module ... = begin .. end'. You can disable this warning by using '--mlcompatibility' or '--nowarn:62'.")
]
//
// #These 2 are not actual testcases, just test libraries for the next 2
// SOURCE=LibFoo1.fs SCFLAGS="-a"
// SOURCE=LibFOo2.fs SCFLAGS="-a"
// SOURCE=SameTypeInTwoReferences01.fs SCFLAGS="-r:LibFoo1.dll -r:LibFoo2.dll" # SameTypeInTwoReferences01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"SameTypeInTwoReferences01.fs"|])>]
let ``SameTypeInTwoReferences01_fs`` compilation =
let libFoo1 =
FsFromPath (Path.Combine(__SOURCE_DIRECTORY__, "LibFoo1.fs"))
|> withOptimize
|> asLibrary
let libFoo2 =
FsFromPath (Path.Combine(__SOURCE_DIRECTORY__, "LibFoo2.fs"))
|> withOptimize
|> asLibrary
compilation
|> withReferences [libFoo1; libFoo2]
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=SameTypeInTwoReferences02.fs SCFLAGS="-r:LibFoo2.dll -r:LibFoo1.dll" # SameTypeInTwoReferences02.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"SameTypeInTwoReferences02.fs"|])>]
let ``SameTypeInTwoReferences02_fs`` compilation =
let libFoo1 =
FsFromPath (Path.Combine(__SOURCE_DIRECTORY__, "LibFoo1.fs"))
|> withOptimize
|> asLibrary
let libFoo2 =
FsFromPath (Path.Combine(__SOURCE_DIRECTORY__, "LibFoo2.fs"))
|> withOptimize
|> asLibrary
compilation
|> withReferences [libFoo2; libFoo1]
|> verifyCompileAndRun
|> shouldSucceed
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace FSharp.Compiler.ComponentTests.Conformance.BasicTypeAndModuleDefinitions
open System.IO
open Xunit
open FSharp.Test
open FSharp.Test.Compiler
module NamespaceDeclGroups =
let verifyCompile compilation =
compilation
|> asExe
|> withOptions ["--nowarn:988"; "--nowarn:3370"]
|> compile
let verifyCompileAndRun compilation =
compilation
|> asExe
|> withOptions ["--nowarn:988"; "--nowarn:3370"]
|> compileAndRun
// SOURCE="E_BeginWithNamespace01a.fs E_BeginWithNamespace01b.fs" SCFLAGS="--test:ErrorRanges --vserrors" # E_BeginWithNamespace01
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_BeginWithNamespace01a.fs"|])>]
let ``E_BeginWithNamespace01a_fs`` compilation =
compilation
|> withAdditionalSourceFile (SourceFromPath (__SOURCE_DIRECTORY__ ++ "E_BeginWithNamespace01b.fs"))
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 222, Line 6, Col 1, Line 7, Col 1, "Files in libraries or multiple-file applications must begin with a namespace or module declaration, e.g. 'namespace SomeNamespace.SubNamespace' or 'module SomeNamespace.SomeModule'. Only the last source file of an application may omit such a declaration.")
]
// SOURCE=NoWarnOnJustNamespace.fs SCFLAGS="--warnaserror:58" # NoWarnOnJustNamespace.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"NoWarnOnJustNamespace.fs"|])>]
let ``NoWarnOnJustNamespace_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=TypeInGlobalNamespace01.fs SCFLAGS="-r:FooGlobal.dll" PRECMD="\$FSC_PIPE -a FooGlobal.fs" # TypeInGlobalNamespace01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"TypeInGlobalNamespace01.fs"|])>]
let ``TypeInGlobalNamespace01_fs`` compilation =
let libFoo =
FsFromPath (Path.Combine(__SOURCE_DIRECTORY__, "FooGlobal.fs"))
|> withOptimize
|> asLibrary
compilation
|> withReferences [libFoo]
|> verifyCompileAndRun
|> shouldSucceed
// SOURCE=TypeInGlobalNamespace02.fs SCFLAGS="-r:FooGlobal.dll" PRECMD="\$FSC_PIPE -a FooGlobal.fs" # TypeInGlobalNamespace02.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"TypeInGlobalNamespace02.fs"|])>]
let ``TypeInGlobalNamespace02_fs`` compilation =
let libFoo =
FsFromPath (Path.Combine(__SOURCE_DIRECTORY__, "FooGlobal.fs"))
|> withOptimize
|> asLibrary
compilation
|> withReferences [libFoo]
|> verifyCompileAndRun
|> shouldSucceed
\ No newline at end of file
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace FSharp.Compiler.ComponentTests.Conformance.BasicTypeAndModuleDefinitions
open System.IO
open Xunit
open FSharp.Test
open FSharp.Test.Compiler
module NullRepresentations =
let verifyCompile compilation =
compilation
|> asExe
|> withOptions ["--nowarn:988"; "--nowarn:3370"]
|> compile
let verifyCompileAndRun compilation =
compilation
|> asExe
|> withOptions ["--nowarn:988"; "--nowarn:3370"]
|> compileAndRun
// SOURCE=E_NullInvalidForFSTypes01.fs # E_NullInvalidForFSTypes01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_NullInvalidForFSTypes01.fs"|])>]
let ``E_NullInvalidForFSTypes01_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 43, Line 20, Col 10, Line 20, Col 14, "The type 'int list' does not have 'null' as a proper value")
(Error 43, Line 21, Col 10, Line 21, Col 14, "The type 'DU' does not have 'null' as a proper value")
(Error 43, Line 22, Col 10, Line 22, Col 14, "The type 'RecType' does not have 'null' as a proper value")
]
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace FSharp.Compiler.ComponentTests.Conformance.BasicTypeAndModuleDefinitions
open System.IO
open Xunit
open FSharp.Test
open FSharp.Test.Compiler
module TypeAbbreviations =
let verifyCompile compilation =
compilation
|> asExe
|> withOptions ["--nowarn:988"; "--nowarn:3370"]
|> compile
let verifyCompileAndRun compilation =
compilation
|> asExe
|> withOptions ["--nowarn:988"; "--nowarn:3370"]
|> compileAndRun
//SOURCE=AbbreviatedTypeSameAsValueId.fsx # AbbreviatedTypeSameAsValueId.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"AbbreviatedTypeSameAsValueId.fsx"|])>]
let ``AbbreviatedTypeSameAsValueId_fsx`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
//SOURCE=Constraints_SampleFromSpec01.fsx # Constraints_SampleFromSpec01.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Constraints_SampleFromSpec01.fsx"|])>]
let ``Constraints_SampleFromSpec01_fsx`` compilation =
compilation
|> verifyCompile
|> shouldSucceed
//SOURCE=E_AbbreviatedTypeAlreadyUsed01.fsx SCFLAGS="--test:ErrorRanges" # E_AbbreviatedTypeAlreadyUsed01.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AbbreviatedTypeAlreadyUsed01.fsx"|])>]
let ``E_AbbreviatedTypeAlreadyUsed01_fsx`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 39, Line 6, Col 32, Line 6, Col 38, "The type 'BigInt' is not defined in 'Microsoft.FSharp.Math'.")
(Error 37, Line 7, Col 6, Line 7, Col 7, "Duplicate definition of type, exception or module 'T'")
]
//SOURCE=E_AbbreviatedTypeDoesNotExist01.fsx SCFLAGS="--test:ErrorRanges" # E_AbbreviatedTypeDoesNotExist01.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_AbbreviatedTypeDoesNotExist01.fsx"|])>]
let ``E_AbbreviatedTypeDoesNotExist01_fsx`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 39, Line 7, Col 10, Line 7, Col 11, "The namespace or module 'X' is not defined.")
]
//SOURCE=E_InfiniteAbbreviation01.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_InfiniteAbbreviation01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_InfiniteAbbreviation01.fs"|])>]
let ``E_InfiniteAbbreviation01_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 953, Line 6, Col 6, Line 6, Col 7, "This type definition involves an immediate cyclic reference through an abbreviation")
(Error 1, Line 8, Col 16, Line 8, Col 20, "This expression was expected to have type\n 'X' \nbut here has type\n ''a option' ")
]
//SOURCE=E_InfiniteAbbreviation02.fs # E_InfiniteAbbreviation02.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_InfiniteAbbreviation02.fs"|])>]
let ``E_InfiniteAbbreviation02_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 953, Line 7, Col 6, Line 7, Col 7, "This type definition involves an immediate cyclic reference through an abbreviation")
]
//SOURCE=E_Constraints_SampleFromSpec02.fsx SCFLAGS="--test:ErrorRanges" # E_Constraints_SampleFromSpec02.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_Constraints_SampleFromSpec02.fsx"|])>]
let ``E_Constraints_SampleFromSpec02_fsx`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 1, Line 16, Col 14, Line 16, Col 19, "A type parameter is missing a constraint 'when 'b :> IB'")
(Error 35, Line 16, Col 6, Line 16, Col 7, "This construct is deprecated: This type abbreviation has one or more declared type parameters that do not appear in the type being abbreviated. Type abbreviations must use all declared type parameters in the type being abbreviated. Consider removing one or more type parameters, or use a concrete type definition that wraps an underlying type, such as 'type C<'a> = C of ...'.")
]
//SOURCE=E_DroppedTypeVariable01.fsx SCFLAGS="--test:ErrorRanges -a" # E_DroppedTypeVariable01.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_DroppedTypeVariable01.fsx"|])>]
let ``E_DroppedTypeVariable01_fsx`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 35, Line 6, Col 6, Line 6, Col 10, "This construct is deprecated: This type abbreviation has one or more declared type parameters that do not appear in the type being abbreviated. Type abbreviations must use all declared type parameters in the type being abbreviated. Consider removing one or more type parameters, or use a concrete type definition that wraps an underlying type, such as 'type C<'a> = C of ...'.")
]
//SOURCE=E_FlexibleType01.fsx SCFLAGS="--test:ErrorRanges" # E_FlexibleType01.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_FlexibleType01.fsx"|])>]
let ``E_FlexibleType01_fsx`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 10, Line 5, Col 1, Line 5, Col 2, "Unexpected infix operator in implementation file")
]
//SOURCE="E_FlexibleTypeInSignature01.fsi E_FlexibleTypeInSignature01.fsx" SCFLAGS="--test:ErrorRanges" # E_FlexibleTypeInSignature01.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_FlexibleTypeInSignature01.fsi"|])>]
let ``E_FlexibleTypeInSignature01_fsi`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 715, Line 15, Col 16, Line 15, Col 18, "Anonymous type variables are not permitted in this declaration")
(Error 35, Line 15, Col 6, Line 15, Col 13, "This construct is deprecated: This type abbreviation has one or more declared type parameters that do not appear in the type being abbreviated. Type abbreviations must use all declared type parameters in the type being abbreviated. Consider removing one or more type parameters, or use a concrete type definition that wraps an underlying type, such as 'type C<'a> = C of ...'.")
(Error 240, Line 5, Col 1, Line 15, Col 18, "The signature file 'E_FlexibleTypeInSignature01' does not have a corresponding implementation file. If an implementation file exists then check the 'module' and 'namespace' declarations in the signature and implementation files match.")
]
//SOURCE=E_IncorrectRightSide_Hash.fsx SCFLAGS="--test:ErrorRanges" # E_IncorrectRightSide_Hash.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_IncorrectRightSide_Hash.fsx"|])>]
let ``E_IncorrectRightSide_Hash_fsx`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 10, Line 8, Col 1, Line 8, Col 5, "Incomplete structured construct at or before this point in type definition")
(Error 547, Line 6, Col 6, Line 6, Col 15, "A type definition requires one or more members or other declarations. If you intend to define an empty class, struct or interface, then use 'type ... = class end', 'interface end' or 'struct end'.")
]
//SOURCE=E_IncorrectRightSide_Keyword.fsx SCFLAGS="--test:ErrorRanges" # E_IncorrectRightSide_Keyword.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_IncorrectRightSide_Keyword.fsx"|])>]
let ``E_IncorrectRightSide_Keyword_fsx`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 10, Line 6, Col 16, Line 6, Col 18, "Unexpected keyword 'of' in type definition")
]
//SOURCE=E_IncorrectRightSide_Quotation.fsx SCFLAGS="--test:ErrorRanges" # E_IncorrectRightSide_Quotation.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_IncorrectRightSide_Quotation.fsx"|])>]
let ``E_IncorrectRightSide_Quotation_fsx`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 10, Line 6, Col 16, Line 6, Col 18, "Unexpected start of quotation in type definition")
]
//SOURCE=E_InheritTypeAbrev.fs # E_InheritTypeAbrev.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_InheritTypeAbrev.fs"|])>]
let ``E_InheritTypeAbrev_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 945, Line 9, Col 9, Line 9, Col 22, "Cannot inherit a sealed type")
]
//SOURCE=E_PrivateTypeAbbreviation02.fs SCFLAGS="--test:ErrorRanges" # E_PrivateTypeAbbreviation02.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_PrivateTypeAbbreviation02.fs"|])>]
let ``E_PrivateTypeAbbreviation02_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 1092, Line 15, Col 10, Line 15, Col 13, "The type 'X' is not accessible from this code location")
]
//SOURCE=E_Recursive01.fsx SCFLAGS="--test:ErrorRanges" # E_Recursive01.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_Recursive01.fsx"|])>]
let ``E_Recursive01_fsx`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 953, Line 7, Col 18, Line 7, Col 20, "This type definition involves an immediate cyclic reference through an abbreviation")
]
//SOURCE=E_Recursive02.fsx SCFLAGS="--test:ErrorRanges" # E_Recursive02.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_Recursive02.fsx"|])>]
let ``E_Recursive02_fsx`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 953, Line 7, Col 6, Line 7, Col 7, "This type definition involves an immediate cyclic reference through an abbreviation")
]
//SOURCE=E_Recursive03.fsx SCFLAGS="--test:ErrorRanges" # E_Recursive03.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_Recursive03.fsx"|])>]
let ``E_Recursive03_fsx`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 953, Line 7, Col 6, Line 7, Col 7, "This type definition involves an immediate cyclic reference through an abbreviation")
]
//SOURCE=E_UnexpectedCharInTypeName01.fs SCFLAGS="--test:ErrorRanges" # E_UnexpectedCharInTypeName01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_UnexpectedCharInTypeName01.fs"|])>]
let ``E_UnexpectedCharInTypeName01_fs`` compilation =
compilation
|> verifyCompile
|> shouldFail
|> withDiagnostics [
(Error 10, Line 5, Col 6, Line 5, Col 7, "Unexpected character '' in type name")
]
//SOURCE=Identity01.fsx # Identity01.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Identity01.fsx"|])>]
let ``Identity01_fsx`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
//SOURCE=PrivateTypeAbbreviation01.fs # PrivateTypeAbbreviation01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"PrivateTypeAbbreviation01.fs"|])>]
let ``PrivateTypeAbbreviation01_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
//SOURCE=ReorderingTypeVariables01.fsx SCFLAGS="--test:ErrorRanges --warnaserror+ -a" # ReorderingTypeVariables01.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ReorderingTypeVariables01.fsx"|])>]
let ``ReorderingTypeVariables01_fsx`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
//SOURCE=TypeNestedInModules01.fsx # TypeNestedInModules01.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"TypeNestedInModules01.fsx"|])>]
let ``TypeNestedInModules01_fsx`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
//SOURCE=TypeAbbreviationAfterForwardRef.fs # TypeAbbreviationAfterForwardRef.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"TypeAbbreviationAfterForwardRef.fs"|])>]
let ``TypeAbbreviationAfterForwardRef_fs`` compilation =
compilation
|> verifyCompileAndRun
|> shouldSucceed
......@@ -15,4 +15,4 @@ type Q = M1.M2.M3.TypeNestedInModules
let q = Q.A
let q' = M1.M2.M3.TypeNestedInModules.A
(if q = q' then 0 else 1) |> exit
if q <> q' then failwith "Failed: 1"
......@@ -23,4 +23,4 @@ let r4 = not (t1.Equals(t4))
let r5 = t1.Equals(t1)
let r6 = not (t1.Equals(t3))
(if r1 && r2 && r3 && r4 && r5 && r6 then 0 else 1) |> exit
if r1 && r2 && r3 && r4 && r5 && r6 then 0 else failwith "Failed: 1"
......@@ -10,5 +10,5 @@ type T1 = | A
type T2 = | A
| C
(if (T1.A.GetHashCode() <> T1.B.GetHashCode()) &&
(T2.A.GetHashCode() <> T2.C.GetHashCode()) then 0 else 1) |> exit
if (T1.A.GetHashCode() <> T1.B.GetHashCode()) &&
(T2.A.GetHashCode() <> T2.C.GetHashCode()) then 0 else failwith "Failed: 1"
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册