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

Conformance/BasicTypeAndModuleDefinitions/GeneratedEqualityHashingComparison/I...

Conformance/BasicTypeAndModuleDefinitions/GeneratedEqualityHashingComparison/IComparison;Conformance/BasicTypeAndModuleDefinitions/GeneratedEqualityHashingComparison/Basic (#12999)
上级 8b5c9863
SOURCE=Test01.fs SCFLAGS="--test:ErrorRanges" # Test01.fs
SOURCE=Test02.fs SCFLAGS="--test:ErrorRanges" # Test02.fs
SOURCE=Test03.fs SCFLAGS="--test:ErrorRanges" # Test03.fs
SOURCE=Test04.fs SCFLAGS="--test:ErrorRanges" # Test04.fs
SOURCE=Test05.fs SCFLAGS="--test:ErrorRanges" # Test05.fs
SOURCE=Test06.fs SCFLAGS="--test:ErrorRanges" # Test06.fs
SOURCE=Test07.fs SCFLAGS="--test:ErrorRanges" # Test07.fs
SOURCE=Test08.fs SCFLAGS="--test:ErrorRanges" # Test08.fs
SOURCE=Test09.fs SCFLAGS="--test:ErrorRanges" # Test09.fs
SOURCE=Test10.fs SCFLAGS="--test:ErrorRanges" # Test10.fs
SOURCE=Test11.fs SCFLAGS="--test:ErrorRanges" # Test11.fs
SOURCE=Test12.fs SCFLAGS="--test:ErrorRanges" # Test12.fs
SOURCE=Test13.fs SCFLAGS="--test:ErrorRanges" # Test13.fs
SOURCE=Test14.fs SCFLAGS="--test:ErrorRanges" # Test14.fs
SOURCE=Test15.fs SCFLAGS="--test:ErrorRanges" # Test15.fs
SOURCE=Test16.fs SCFLAGS="--test:ErrorRanges" # Test16.fs
SOURCE=Test17.fs SCFLAGS="--test:ErrorRanges" # Test17.fs
SOURCE=Test18.fs SCFLAGS="--test:ErrorRanges" # Test18.fs
SOURCE=Test19.fs SCFLAGS="--test:ErrorRanges" # Test19.fs
SOURCE=Test20.fs SCFLAGS="--test:ErrorRanges" # Test20.fs
SOURCE=Test21.fs SCFLAGS="--test:ErrorRanges" # Test21.fs
SOURCE=Test22.fs SCFLAGS="--test:ErrorRanges" # Test22.fs
SOURCE=Test23.fs SCFLAGS="--test:ErrorRanges" # Test23.fs
SOURCE=Test24.fs SCFLAGS="--test:ErrorRanges" # Test24.fs
SOURCE=Test25.fs SCFLAGS="--test:ErrorRanges" # Test25.fs
SOURCE=Test26.fs SCFLAGS="--test:ErrorRanges" # Test26.fs
SOURCE=Test27.fs SCFLAGS="--test:ErrorRanges" # Test27.fs
SOURCE=Test28.fs SCFLAGS="--test:ErrorRanges" # Test28.fs
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.
namespace FSharp.Compiler.ComponentTests.Conformance.BasicTypeAndModuleDefinitions.GeneratedEqualityHashingComparison
open System.IO
open Xunit
open FSharp.Test
open FSharp.Test.Compiler
module Basic =
// SOURCE=Arrays.fsx # Arrays.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Arrays.fsx"|])>]
let``Arrays_fsx`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=Comparison01.fs # Comparison01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Comparison01.fs"|])>]
let``Comparison01_fs`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=CustomEquality01.fs # CustomEquality01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"CustomEquality01.fs"|])>]
let``CustomEquality01_fs`` compilation =
compilation
|> asExe
|> compile
|> shouldFail
|> withDiagnostics [
(Warning 988, Line 37, Col 1, Line 37, Col 1, "Main module of program is empty: nothing will happen when it is run")
]
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_CustomEqualityEquals01.fs"|])>]
let``E_CustomEqualityEquals01_fs`` compilation =
compilation
|> asExe
|> compile
|> shouldFail
|> withDiagnostics [
(Error 344, Line 13, Col 6, Line 13, Col 7, "The struct, record or union type 'R' has an explicit implementation of 'Object.GetHashCode' or 'Object.Equals'. You must apply the 'CustomEquality' attribute to the type")
(Warning 346, Line 13, Col 6, Line 13, Col 7, "The struct, record or union type 'R' has an explicit implementation of 'Object.Equals'. Consider implementing a matching override for 'Object.GetHashCode()'")
(Error 344, Line 17, Col 6, Line 17, Col 7, "The struct, record or union type 'U' has an explicit implementation of 'Object.GetHashCode' or 'Object.Equals'. You must apply the 'CustomEquality' attribute to the type")
(Warning 346, Line 17, Col 6, Line 17, Col 7, "The struct, record or union type 'U' has an explicit implementation of 'Object.Equals'. Consider implementing a matching override for 'Object.GetHashCode()'")
(Error 344, Line 21, Col 6, Line 21, Col 7, "The struct, record or union type 'S' has an explicit implementation of 'Object.GetHashCode' or 'Object.Equals'. You must apply the 'CustomEquality' attribute to the type")
(Warning 346, Line 21, Col 6, Line 21, Col 7, "The struct, record or union type 'S' has an explicit implementation of 'Object.Equals'. Consider implementing a matching override for 'Object.GetHashCode()'")
]
// SOURCE=E_CustomEqualityGetHashCode01.fs SCFLAGS="--test:ErrorRanges" # E_CustomEqualityGetHashCode01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_CustomEqualityGetHashCode01.fs"|])>]
let``E_CustomEqualityGetHashCode01_fs`` compilation =
compilation
|> asExe
|> compile
|> shouldFail
|> withDiagnostics [
(Error 344, Line 13, Col 6, Line 13, Col 7, "The struct, record or union type 'R' has an explicit implementation of 'Object.GetHashCode' or 'Object.Equals'. You must apply the 'CustomEquality' attribute to the type")
(Warning 345, Line 13, Col 6, Line 13, Col 7, "The struct, record or union type 'R' has an explicit implementation of 'Object.GetHashCode'. Consider implementing a matching override for 'Object.Equals(obj)'")
(Error 359, Line 13, Col 6, Line 13, Col 7, "More than one override implements 'GetHashCode: unit -> int'")
(Error 54, Line 13, Col 6, Line 13, Col 7, "This type is 'abstract' since some abstract members have not been given an implementation. If this is intentional then add the '[<AbstractClass>]' attribute to your type.")
(Error 344, Line 17, Col 6, Line 17, Col 7, "The struct, record or union type 'U' has an explicit implementation of 'Object.GetHashCode' or 'Object.Equals'. You must apply the 'CustomEquality' attribute to the type")
(Warning 345, Line 17, Col 6, Line 17, Col 7, "The struct, record or union type 'U' has an explicit implementation of 'Object.GetHashCode'. Consider implementing a matching override for 'Object.Equals(obj)'")
(Error 359, Line 17, Col 6, Line 17, Col 7, "More than one override implements 'GetHashCode: unit -> int'")
(Error 54, Line 17, Col 6, Line 17, Col 7, "This type is 'abstract' since some abstract members have not been given an implementation. If this is intentional then add the '[<AbstractClass>]' attribute to your type.")
(Error 344, Line 21, Col 6, Line 21, Col 7, "The struct, record or union type 'S' has an explicit implementation of 'Object.GetHashCode' or 'Object.Equals'. You must apply the 'CustomEquality' attribute to the type")
(Warning 345, Line 21, Col 6, Line 21, Col 7, "The struct, record or union type 'S' has an explicit implementation of 'Object.GetHashCode'. Consider implementing a matching override for 'Object.Equals(obj)'")
(Error 359, Line 21, Col 6, Line 21, Col 7, "More than one override implements 'GetHashCode: unit -> int'")
(Error 54, Line 21, Col 6, Line 21, Col 7, "This type is 'abstract' since some abstract members have not been given an implementation. If this is intentional then add the '[<AbstractClass>]' attribute to your type.")
]
// SOURCE=E_ExceptionsNoComparison.fs SCFLAGS="--test:ErrorRanges" # E_ExceptionsNoComparison.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_ExceptionsNoComparison.fs"|])>]
let``E_ExceptionsNoComparison_fs`` compilation =
compilation
|> asExe
|> compile
|> shouldFail
|> withDiagnostics [
(Error 1, Line 9, Col 9, Line 9, Col 15, "The type 'exn' does not support the 'comparison' constraint. For example, it does not support the 'System.IComparable' interface")
(Error 1, Line 10, Col 9, Line 10, Col 15, "The type 'exn' does not support the 'comparison' constraint. For example, it does not support the 'System.IComparable' interface")
]
// SOURCE=EqualOnTuples01.fs # EqualOnTuples01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"EqualOnTuples01.fs"|])>]
let``EqualOnTuples01_fs`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=Equality01.fs # Equality01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Equality01.fs"|])>]
let``Equality01_fs`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=Exceptions.fsx # Exceptions.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Exceptions.fsx"|])>]
let``Exceptions_fsx`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=Generated_Record.fsx # Generated_Record.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Generated_Record.fsx"|])>]
let``Generated_Record_fsx`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=Hashing01.fs # Hashing01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Hashing01.fs"|])>]
let``Hashing01_fs`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=Lists.fsx # Lists.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Lists.fsx"|])>]
let``Lists_fsx`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=NeverGenerated_Class.fsx # NeverGenerated_Class.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"NeverGenerated_Class.fsx"|])>]
let``NeverGenerated_Class_fsx`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=NeverGenerated_Delegate.fsx # NeverGenerated_Delegate.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"NeverGenerated_Delegate.fsx"|])>]
let``NeverGenerated_Delegate_fsx`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=NeverGenerated_Enum.fsx # NeverGenerated_Enum.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"NeverGenerated_Enum.fsx"|])>]
let``NeverGenerated_Enum_fsx`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=NeverGenerated_Interface.fsx # NeverGenerated_Interface.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"NeverGenerated_Interface.fsx"|])>]
let``NeverGenerated_Interface_fsx`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=Options.fsx # Options.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Options.fsx"|])>]
let``Options_fsx`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=Sample_Records.fsx # Sample_Records.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Sample_Records.fsx"|])>]
let``Sample_Records_fsx`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=Sample_Tuples.fsx # Sample_Tuples.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Sample_Tuples.fsx"|])>]
let``Sample_Tuples_fsx`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=Structs.fsx # Structs.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Structs.fsx"|])>]
let``Structs_fsx`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=Unions.fsx # Unions.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Unions.fsx"|])>]
let``Unions_fsx`` compilation =
compilation
|> asExe
|> compile
|> shouldSucceed
// SOURCE=E_CustomEqualityEquals01.fs SCFLAGS="--test:ErrorRanges" # E_CustomEqualityEquals01.fs
// #Conformance #TypesAndModules #GeneratedEqualityAndHashing
#light
// Test generated hashing implementations.
// Test by making sure the hashes of each function is the same.
#light
// Sanity check generated equality
// *** Tupes ***
......
......@@ -9,7 +9,8 @@ type DU =
interface System.IComparable with
override this.CompareTo(a:obj) = -1 // first always less than second
let a = A(1)
let b = A(2)
(if a < b && b < a then 0 else 1) |> exit
if not (a < b && b < a) 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.BasicTypeAndModuleDefinitions.GeneratedEqualityHashingComparison
open Xunit
open FSharp.Test
open FSharp.Test.Compiler
module IComparison =
// SOURCE=DU.fs # DU.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"DU.fs"|])>]
let``DU_fs`` compilation =
compilation
|> asExe
|> withOptions ["--nowarn:342"]
|> compileAndRun
|> shouldSucceed
// SOURCE=Record.fs # Record.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Record.fs"|])>]
let``Record_fs`` compilation =
compilation
|> asExe
|> withOptions ["--nowarn:342"]
|> compileAndRun
|> shouldSucceed
// SOURCE=Struct.fs # Struct.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Struct.fs"|])>]
let``Struct_fs`` compilation =
compilation
|> asExe
|> withOptions ["--nowarn:342"]
|> compileAndRun
|> shouldSucceed
// SOURCE=W_ImplIComparable.fs # W_ImplIComparable.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"W_ImplIComparable.fs"|])>]
let``W_ImplIComparable_fs`` compilation =
compilation
|> asExe
|> compile
|> shouldFail
|> withDiagnostics [
(Warning 342, Line 10, Col 6, Line 10, Col 7, "The type 'S' implements 'System.IComparable'. Consider also adding an explicit override for 'Object.Equals'")
(Warning 343, Line 15, Col 6, Line 15, Col 7, "The type 'C' implements 'System.IComparable' explicitly but provides no corresponding override for 'Object.Equals'. An implementation of 'Object.Equals' has been automatically provided, implemented via 'System.IComparable'. Consider implementing the override 'Object.Equals' explicitly")
(Warning 988, Line 19, Col 1, Line 19, Col 1, "Main module of program is empty: nothing will happen when it is run")
]
......@@ -23,7 +23,8 @@
<Compile Include="Conformance\BasicTypeAndModuleDefinitions\ExceptionDefinitions\ExceptionDefinitions.fs" />
<Compile Include="Conformance\BasicTypeAndModuleDefinitions\GeneratedEqualityHashingComparison\Attributes\Diags\Diags.fs" />
<Compile Include="Conformance\BasicTypeAndModuleDefinitions\GeneratedEqualityHashingComparison\Attributes\Legacy\Legacy.fs" />
<Compile Include="Conformance\BasicTypeAndModuleDefinitions\GeneratedEqualityHashingComparison\Attributes\New\New.fs" />
<Compile Include="Conformance\BasicTypeAndModuleDefinitions\GeneratedEqualityHashingComparison\Basic\Basic.fs" />
<Compile Include="Conformance\BasicTypeAndModuleDefinitions\GeneratedEqualityHashingComparison\IComparison\IComparison.fs" />
<Compile Include="Conformance\ClassTypes\ExplicitObjectConstructors\ExplicitObjectConstructors.fs" />
<Compile Include="Conformance\ClassTypes\ImplicitObjectConstructors\ImplicitObjectConstructors.fs" />
<Compile Include="Conformance\ClassTypes\ValueRestriction\ValueRestriction.fs" />
......
SOURCE=EqualOnTuples01.fs # EqualOnTuples01.fs
SOURCE=Equality01.fs # Equality01.fs
SOURCE=Hashing01.fs # Hashing01.fs
SOURCE=Comparison01.fs # Comparison01.fs
SOURCE=Arrays.fsx # Arrays.fsx
SOURCE=Exceptions.fsx # Exceptions.fsx
SOURCE=E_ExceptionsNoComparison.fs SCFLAGS="--test:ErrorRanges" # E_ExceptionsNoComparison.fs
SOURCE=Generated_Record.fsx # Generated_Record.fsx
SOURCE=Lists.fsx # Lists.fsx
SOURCE=NeverGenerated_Class.fsx # NeverGenerated_Class.fsx
SOURCE=NeverGenerated_Delegate.fsx # NeverGenerated_Delegate.fsx
SOURCE=NeverGenerated_Enum.fsx # NeverGenerated_Enum.fsx
SOURCE=NeverGenerated_Interface.fsx # NeverGenerated_Interface.fsx
SOURCE=Options.fsx # Options.fsx
SOURCE=Sample_Records.fsx # Sample_Records.fsx
SOURCE=Sample_Tuples.fsx # Sample_Tuples.fsx
SOURCE=Structs.fsx # Structs.fsx
SOURCE=Unions.fsx # Unions.fsx
SOURCE=E_CustomEqualityEquals01.fs SCFLAGS="--test:ErrorRanges" # E_CustomEqualityEquals01.fs
SOURCE=E_CustomEqualityGetHashCode01.fs SCFLAGS="--test:ErrorRanges" # E_CustomEqualityGetHashCode01.fs
SOURCE=CustomEquality01.fs # CustomEquality01.fs
SOURCE=DU.fs # DU.fs
SOURCE=Record.fs # Record.fs
SOURCE=Struct.fs # Struct.fs
SOURCE=W_ImplIComparable.fs # W_ImplIComparable.fs
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册