From 63fd85d26c71e88075523943996ddadde7a06df4 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 7 Aug 2023 17:16:01 +0200 Subject: [PATCH 1/4] Moved Pattern Matching Test from FSharpQA to ComponentTests --- .../Conformance/PatternMatching/And/And.fs | 56 +++ .../PatternMatching/And/E_IdentBoundTwice.fs | 11 + .../PatternMatching/And/andPattern01.fs | 29 ++ .../PatternMatching/And/andPattern02.fs | 23 + .../PatternMatching/And/andPattern03.fs | 28 ++ .../PatternMatching/Array/Array.fs | 48 ++ .../PatternMatching/Array/TrailingSemi01.fs | 102 ++++ .../PatternMatching/Array/arrayMatch01.fs | 18 + .../PatternMatching/Array/arrayMatch02.fs | 13 + .../PatternMatching/Array/arrayMatch03.fs | 16 + .../Conformance/PatternMatching/As/As.fs | 63 +++ .../PatternMatching/As/asPattern01.fs | 11 + .../PatternMatching/As/asPattern02.fs | 20 + .../PatternMatching/ConsList/ConsList.fs | 56 +++ .../ConsList/E_consOnNonList.fs | 7 + .../ConsList/E_consPattern01.fs | 17 + .../ConsList/OutsideMatch01.fs | 12 + .../PatternMatching/ConsList/consPattern01.fs | 17 + .../DynamicTypeTest/ArrayTypeTest01.fs | 16 + .../DynamicTypeTest/DynamicTypeTest.fs | 158 ++++++ .../DynamicTypeTest/E_DynamTyTestVarType01.fs | 15 + .../E_DynamicTestPrimType01.fs | 14 + .../DynamicTypeTest/Regression01.fs | 27 + .../DynamicTypeTest/Regression02.fs | 18 + .../DynamicTypeTest/TwoAtOnce01.fs | 33 ++ .../DynamicTypeTest/W_RedundantPattern01.fs | 21 + .../W_TypeTestWillAlwaysHold01.fs | 17 + .../DynamicTypeTest/dynTestSealedType01.fs | 27 + .../DynamicTypeTest/dynamicTypeTest01.fs | 27 + .../DynamicTypeTest/dynamicTypeTest02.fs | 45 ++ .../DynamicTypeTest/dynamicTypeTest03.fs | 63 +++ .../DynamicTypeTest/dynamicTypeTest04.fs | 12 + .../DynamicTypeTest/genericType01.fs | 16 + .../Expression/E_CounterExample01.fs | 9 + .../PatternMatching/Expression/Expression.fs | 138 ++++++ .../Expression/NoCounterExampleTryWith01.fs | 25 + .../Expression/W_CounterExampleWithEnum01.fs | 36 ++ .../Expression/W_CounterExampleWithEnum02.fs | 32 ++ .../Expression/W_whenGuards01.fs | 16 + .../PatternMatching/Expression/patterns01.fs | 18 + .../PatternMatching/Expression/patterns02.fs | 16 + .../Expression/whenGuards01.fs | 37 ++ .../Expression/whenGuards02.fs | 20 + .../Expression/whenGuardss01.fs | 37 ++ .../Expression/whenGuardss02.fs | 20 + .../Named/ActivePatternOutsideMatch01.fs | 20 + .../Named/ActivePatternOutsideMatch02.fs | 13 + .../Named/ActivePatternUnconstrained01.fs | 13 + .../Named/AsHighOrderFunc01.fs | 34 ++ .../Named/E_ActivePatternHasNoFields.fs | 13 + .../Named/E_ActivePatternNotAFuncion.fs | 5 + .../Named/E_ActivePatternUnconstrained01.fs | 14 + .../Named/E_ActivePatterns01.fs | 20 + .../Named/E_ActivePatterns02.fs | 8 + .../PatternMatching/Named/E_Error_LetRec01.fs | 8 + .../PatternMatching/Named/E_Error_LetRec02.fs | 4 + .../PatternMatching/Named/E_Error_LetRec03.fs | 4 + .../PatternMatching/Named/E_Error_LetRec04.fs | 5 + .../Named/E_Error_NonParam01.fs | 5 + .../Named/E_Error_NonParam02.fs | 4 + .../Named/E_Error_NonParam03.fs | 4 + .../Named/E_Error_NonParam04.fs | 5 + .../PatternMatching/Named/E_Error_Param01.fs | 5 + .../PatternMatching/Named/E_Error_Param02.fs | 4 + .../PatternMatching/Named/E_Error_Param03.fs | 4 + .../PatternMatching/Named/E_Error_Param04.fs | 5 + .../Named/E_LargeActivePat01.fs | 7 + .../Named/E_MulticasePartialNotAllowed01.fs | 24 + .../Named/E_ParameterRestrictions01.fs | 17 + .../Named/E_PatternMatchRegressions02.fs | 33 ++ .../Named/MultiActivePatterns01.fs | 49 ++ .../PatternMatching/Named/Named.fs | 469 ++++++++++++++++++ .../PatternMatching/Named/NamedLiteral01.fs | 21 + .../PatternMatching/Named/NamedLiteral02.fs | 58 +++ .../ParamertizedPartialActivePattern01.fs | 33 ++ .../Named/PatternMatchRegressions01.fs | 29 ++ .../Named/PatternMatchRegressions02.fs | 27 + .../Named/RecursiveActivePats.fs | 40 ++ .../PatternMatching/Named/activePatterns01.fs | 15 + .../PatternMatching/Named/activePatterns02.fs | 13 + .../PatternMatching/Named/activePatterns03.fs | 18 + .../PatternMatching/Named/activePatterns05.fs | 16 + .../PatternMatching/Named/activePatterns06.fs | 3 + .../PatternMatching/Named/activePatterns07.fs | 48 ++ .../PatternMatching/Named/activePatterns08.fs | 40 ++ .../PatternMatching/Named/discUnion01.fs | 27 + .../PatternMatching/Named/discUnion02.fs | 24 + .../Null/E_notNullCompatible01.fs | 18 + .../Conformance/PatternMatching/Null/Null.fs | 27 + .../PatternMatching/Null/matchNull01.fs | 16 + .../Record/E_RecTypesNotMatch01.fs | 12 + .../Record/E_RecordFieldNotDefined01.fs | 12 + .../PatternMatching/Record/E_SyntaxError01.fs | 12 + .../PatternMatching/Record/Record.fs | 83 ++++ .../Record/recordPatterns01.fs | 32 ++ .../Record/recordPatterns02.fs | 39 ++ .../Record/structRecordPatterns01.fs | 32 ++ .../Record/structRecordPatterns02.fs | 39 ++ .../Conformance/PatternMatching/Simple.fs | 129 ----- .../PatternMatching/Simple/CodeGenReg01.fs | 49 ++ .../PatternMatching/Simple/E_SyntaxError01.fs | 11 + .../Simple/E_ValueCapture01.fs | 17 + .../Simple/E_constPattern01.fs | 16 + .../Simple/E_namedLiberal01.fs | 23 + .../Simple/MatchFailureExn01.fs | 26 + .../PatternMatching/Simple/Simple.fs | 380 ++++++++++++++ .../PatternMatching/Simple/ValueCapture01.fs | 19 + .../PatternMatching/Simple/ValueCapture02.fs | 35 ++ .../Simple/W_BindCaptialIdent.fs | 0 .../PatternMatching/Simple/W_Incomplete01.fs | 0 .../PatternMatching/Simple/W_Incomplete02.fs | 0 .../Simple/simplePatterns01.fs | 15 + .../Simple/simplePatterns02.fs | 13 + .../Simple/simplePatterns03.fs | 22 + .../Simple/simplePatterns04.fs | 14 + .../Simple/simplePatterns05.fs | 28 ++ .../Simple/simplePatterns06.fs | 26 + .../Simple/simplePatterns07.fs | 20 + .../Simple/simplePatterns08.fs | 17 + .../Simple/simplePatterns09.fs | 19 + .../Simple/simplePatterns10.fs | 18 + .../Simple/simplePatterns11.fs | 15 + .../Simple/simplePatterns12.fs | 21 + .../Simple/simplePatterns13.fs | 20 + .../Simple/simplePatterns14.fs | 10 + .../Simple/simplePatterns15.fs | 18 + .../Simple/simplePatterns16.fs | 27 + .../Simple/simplePatterns17.fs | 19 + .../Simple/simplePatterns18.fs | 30 ++ .../Simple/simplePatterns19.fs | 26 + .../Simple/simplePatterns20.fs | 26 + .../SimpleConstant/DiffAssembly.fs | 16 + .../SimpleConstant/E_NoRangeConst01.fs | 25 + .../SimpleConstant/E_type_bigint.fs | 13 + .../SimpleConstant/E_type_bignum40.fs | 14 + .../SimpleConstant/FullyQualify01.fs | 33 ++ .../SimpleConstant/MatchLiteral01.fs | 30 ++ .../SimpleConstant/MatchNaN.fs | 29 ++ .../SimpleConstant/SimpleConstant.fs | 295 +++++++++++ .../SimpleConstant/matchConst01.fs | 15 + .../SimpleConstant/matchConst02.fs | 15 + .../SimpleConstant/matchConst03.fs | 26 + .../SimpleConstant/matchConst04.fs | 24 + .../SimpleConstant/type_bigint.fs | 12 + .../SimpleConstant/type_bool.fs | 12 + .../SimpleConstant/type_byte.fs | 12 + .../SimpleConstant/type_byteArr.fs | 14 + .../SimpleConstant/type_char.fs | 12 + .../SimpleConstant/type_double.fs | 13 + .../SimpleConstant/type_float32.fs | 13 + .../SimpleConstant/type_int.fs | 12 + .../SimpleConstant/type_int16.fs | 12 + .../SimpleConstant/type_int64.fs | 14 + .../SimpleConstant/type_nativenint.fs | 12 + .../SimpleConstant/type_sbyte.fs | 12 + .../SimpleConstant/type_string.fs | 14 + .../SimpleConstant/type_uint16.fs | 12 + .../SimpleConstant/type_uint32.fs | 12 + .../SimpleConstant/type_uint64.fs | 12 + .../SimpleConstant/type_unativenint.fs | 12 + .../SimpleConstant/type_unit.fs | 11 + .../PatternMatching/Tuple/SimpleTuples01.fs | 12 + .../PatternMatching/Tuple/Tuple.fs | 57 +++ .../Tuple/W_IncompleteMatches01.fs | 14 + .../Tuple/W_RedundantPattern01.fs | 15 + .../Tuple/W_RedundantPattern02.fs | 19 + .../PatternMatching/Tuple/tuples01.fs | 19 + .../TypeConstraint/E_typecontraint01.fs | 21 + .../TypeConstraint/TypeConstraint.fs | 22 + .../Union/E_CapturesDiffVal01.fs | 13 + .../Union/E_NotAllCaptureSameVal01.fs | 13 + .../Union/E_UnionCapturesDiffType01.fs | 11 + .../PatternMatching/Union/Union.fs | 84 ++++ .../PatternMatching/Union/unionPattern01.fs | 21 + .../PatternMatching/Union/unionPattern02.fs | 18 + .../PatternMatching/Union/unionPattern03.fs | 33 ++ .../PatternMatching/Union/unionPattern04.fs | 12 + .../PatternMatching/Wildcard/Wildcard.fs | 17 + .../Wildcard/wildCardPatterns01.fs | 17 + .../FSharp.Compiler.ComponentTests.fsproj | 17 +- 180 files changed, 5162 insertions(+), 130 deletions(-) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/And.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/E_IdentBoundTwice.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern03.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/Array.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/TrailingSemi01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/arrayMatch01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/arrayMatch02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/arrayMatch03.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/As/As.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/As/asPattern01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/As/asPattern02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/ConsList.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/E_consOnNonList.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/E_consPattern01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/OutsideMatch01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/consPattern01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/ArrayTypeTest01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/DynamicTypeTest.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/E_DynamTyTestVarType01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/E_DynamicTestPrimType01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/Regression01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/Regression02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/TwoAtOnce01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/W_RedundantPattern01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/W_TypeTestWillAlwaysHold01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynTestSealedType01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest03.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest04.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/genericType01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/E_CounterExample01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/Expression.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/NoCounterExampleTryWith01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/W_CounterExampleWithEnum01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/W_CounterExampleWithEnum02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/W_whenGuards01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/patterns01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/patterns02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/whenGuards01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/whenGuards02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/whenGuardss01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/whenGuardss02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/ActivePatternOutsideMatch01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/ActivePatternOutsideMatch02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/ActivePatternUnconstrained01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/AsHighOrderFunc01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatternHasNoFields.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatternNotAFuncion.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatternUnconstrained01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatterns01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatterns02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_LetRec01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_LetRec02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_LetRec03.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_LetRec04.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_NonParam01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_NonParam02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_NonParam03.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_NonParam04.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_Param01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_Param02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_Param03.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_Param04.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_LargeActivePat01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_MulticasePartialNotAllowed01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ParameterRestrictions01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_PatternMatchRegressions02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/MultiActivePatterns01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/Named.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/NamedLiteral01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/NamedLiteral02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/ParamertizedPartialActivePattern01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/PatternMatchRegressions01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/PatternMatchRegressions02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/RecursiveActivePats.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns03.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns05.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns06.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns07.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns08.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/discUnion01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/discUnion02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Null/E_notNullCompatible01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Null/Null.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Null/matchNull01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/E_RecTypesNotMatch01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/E_RecordFieldNotDefined01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/E_SyntaxError01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/Record.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/recordPatterns01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/recordPatterns02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/structRecordPatterns01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/structRecordPatterns02.fs delete mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/CodeGenReg01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/E_SyntaxError01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/E_ValueCapture01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/E_constPattern01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/E_namedLiberal01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/MatchFailureExn01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/ValueCapture01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/ValueCapture02.fs rename tests/FSharp.Compiler.ComponentTests/{resources/tests => }/Conformance/PatternMatching/Simple/W_BindCaptialIdent.fs (100%) rename tests/FSharp.Compiler.ComponentTests/{resources/tests => }/Conformance/PatternMatching/Simple/W_Incomplete01.fs (100%) rename tests/FSharp.Compiler.ComponentTests/{resources/tests => }/Conformance/PatternMatching/Simple/W_Incomplete02.fs (100%) create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns03.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns04.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns05.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns06.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns07.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns08.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns09.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns10.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns11.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns12.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns13.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns14.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns15.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns16.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns17.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns18.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns19.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns20.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/DiffAssembly.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/E_NoRangeConst01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/E_type_bigint.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/E_type_bignum40.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/FullyQualify01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/MatchLiteral01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/MatchNaN.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/SimpleConstant.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/matchConst01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/matchConst02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/matchConst03.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/matchConst04.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_bigint.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_bool.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_byte.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_byteArr.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_char.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_double.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_float32.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_int.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_int16.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_int64.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_nativenint.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_sbyte.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_string.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_uint16.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_uint32.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_uint64.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_unativenint.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_unit.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/SimpleTuples01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/Tuple.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/W_IncompleteMatches01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/W_RedundantPattern01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/W_RedundantPattern02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/tuples01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/TypeConstraint/E_typecontraint01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/TypeConstraint/TypeConstraint.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_CapturesDiffVal01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_NotAllCaptureSameVal01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionCapturesDiffType01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/unionPattern01.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/unionPattern02.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/unionPattern03.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/unionPattern04.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Wildcard/Wildcard.fs create mode 100644 tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Wildcard/wildCardPatterns01.fs diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/And.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/And.fs new file mode 100644 index 00000000000..73ccde330e9 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/And.fs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Conformance.PatternMatching + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module And = + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/And) + [] + let ``And - andPattern01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/And) + [] + let ``And - andPattern02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/And) + [] + let ``And - andPattern03_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 41, Line 7, Col 28, Line 7, Col 45, "A unique overload for method 'TryParse' could not be determined based on type information prior to this program point. A type annotation may be needed. + +Known type of argument: 'a + +Candidates: + - Int32.TryParse(s: ReadOnlySpan, result: byref) : bool + - Int32.TryParse(s: string, result: byref) : bool") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/And) + [] + let ``And - E_IdentBoundTwice_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 38, Line 9, Col 20, Line 9, Col 21, "'x' is bound twice in this pattern") \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/E_IdentBoundTwice.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/E_IdentBoundTwice.fs new file mode 100644 index 00000000000..ae14b063a73 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/E_IdentBoundTwice.fs @@ -0,0 +1,11 @@ +// #Regression #Conformance #PatternMatching #PatternMatchingGuards +#light + +//'x' is bound twice in this pattern + +let test input = + match input with + | (1, _) & (_, 1) -> 1 + | (x, _) & (_, x) -> 2 + +exit 1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern01.fs new file mode 100644 index 00000000000..7bc37f0613e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern01.fs @@ -0,0 +1,29 @@ +// #Conformance #PatternMatching #PatternMatchingGuards +#light + +// Verify that and patterns must match both sides + +// And patterns are pretty much only useful with active patterns... +let (|MulTwo|_|) x = if x % 2 = 0 then Some() else None +let (|MulThree|_|) x = if x % 3 = 0 then Some() else None +let (|MulFour|_|) x = if x % 4 = 0 then Some() else None + +let mulOf234 x = + match x with + | MulTwo & MulThree & MulFour -> (true, true, true) + | MulTwo & MulThree -> (true, true, false) + | MulThree & MulFour -> (false, true, true) + | MulTwo & MulFour -> (true, false, true) + | MulTwo -> (true, false, false) + | MulThree -> (false, true, false) + | MulFour -> (false, false, true) + | _ -> (false,false,false) + + +for i = 1 to 100 do + let m2,m3,m4 = mulOf234 i + if m2 <> (i % 2 = 0) then exit 1 + if m3 <> (i % 3 = 0) then exit 1 + if m4 <> (i % 4 = 0) then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern02.fs new file mode 100644 index 00000000000..312fef3d201 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern02.fs @@ -0,0 +1,23 @@ +// #Conformance #PatternMatching #PatternMatchingGuards +#light + +// Verify multiple pattern parts can introduce new identifiers +type Foo = + | A of int + | B of string * int + +let (|ToString|) x = match x with A x | B(_,x) -> x.ToString() + +let test v = + match v with + | A(x) & ToString (vToStr) when x = vToStr.Length -> true + | B(str, value) & ToString (vToStr) when str = vToStr -> true + | _ -> false + +if test (A(1)) <> true then exit 1 +if test (B("123", 123)) <> true then exit 1 + +if test (A(2)) <> false then exit 1 +if test (B("100", 10)) <> false then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern03.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern03.fs new file mode 100644 index 00000000000..b7dcac145ca --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern03.fs @@ -0,0 +1,28 @@ +// #Conformance #PatternMatching #PatternMatchingGuards +#light + +open System + +let (|ToInt|) x = + let (parsed, result) = Int32.TryParse(x) + if parsed then result + else -1 + +let (|ToStr|) (x : int) = x.ToString() + +let test input = + match input with + | ToInt (ToStr "1") -> 1 + | ToInt 2 & ToInt (ToStr "2") -> 2 + | ToInt (ToStr "3") & ToInt (ToStr (ToInt (ToStr "3"))) -> 3 + | _ -> -1 + +if test "1" <> 1 then exit 1 +if test "2" <> 2 then exit 2 +if test "3" <> 3 then exit 3 + +exit 0 + + + + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/Array.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/Array.fs new file mode 100644 index 00000000000..423453ff445 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/Array.fs @@ -0,0 +1,48 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Conformance.PatternMatching + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module Array = + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Array) + [] + let ``Array - arrayMatch01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Array) + [] + let ``Array - arrayMatch02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Array) + [] + let ``Array - arrayMatch03_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Array) + [] + let ``Array - TrailingSemi01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/TrailingSemi01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/TrailingSemi01.fs new file mode 100644 index 00000000000..62db9992e8e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/TrailingSemi01.fs @@ -0,0 +1,102 @@ +// #Regression #Conformance #PatternMatching #Arrays +#light + +// Verify ability to match a list, array, or record with trailing semicolon +// (Regression for bug 1190 - minor glitch in record pattern) + +let list1 = [1;2;3;4;] +let list2 = [ + 5; + 6; + 7; + 8; + ] + +if List.length list1 <> 4 then exit 1 +if List.length list2 <> 4 then exit 1 + +// ---------------------------------------- + +let array1 = [| 1;2;3;4; |] +let array2 = [| + 5; + 6; + 7; + 8; + |] + +if Array.length array1 <> 4 then exit 1 +if Array.length array2 <> 4 then exit 1 + +// ---------------------------------------- + +type recordType1 = { + label1 : int; + label2 : int; +} +type recordType2 = { label1B : int; label2B : int; } + +let record1 = { label1 = 0; label2 = 1; } +let record2 = { + label1 = 2; + label2 = 3; + } + +// ------------------------------------------------------------------------- + +let isList1 x = + match x with + | [ + 1; + 2; + 3; + 4; ] -> true + | _ -> false + +let isList2 x = + match x with + | [5; 6; 7; 8;] -> true + | _ -> false + +if not (isList1 list1) then exit 1 +if not (isList2 list2) then exit 1 + +// ---------------------------------------- + +let isArray1 x = + match x with + | [| + 1; + 2; + 3; + 4; |] -> true + | _ -> false + +let isArray2 x = + match x with + | [| 5; 6; 7; 8; |] -> true + | _ -> false + +if not (isArray1 array1) then exit 1 +if not (isArray2 array2) then exit 1 + +// ---------------------------------------- + +let isRecord1 x = + match x with + | { + label1 = 0; + label2 = 1; + } -> true + | _ -> false + +let isRecord2 x = + match x with + | { label1 = 2; label2 = 3; } -> true + | _ -> false + + +if not (isRecord1 record1) then exit 1 +if not (isRecord2 record2) then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/arrayMatch01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/arrayMatch01.fs new file mode 100644 index 00000000000..3aa935b7a70 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/arrayMatch01.fs @@ -0,0 +1,18 @@ +// #Conformance #PatternMatching #Arrays +#light + +// Verify ability to match against arrays + +let test x = + match x with + | [| 1 |] -> 1 + | [| 1; 2 |] -> 2 + | [| 1; 2; 3 |] -> 3 + | _ -> -1 + + +if test [| 1 |] <> 1 then exit 1 +if test [| 1; 2 |] <> 2 then exit 1 +if test [| 1; 2; 3 |] <> 3 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/arrayMatch02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/arrayMatch02.fs new file mode 100644 index 00000000000..f41bfa698d4 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/arrayMatch02.fs @@ -0,0 +1,13 @@ +// #Conformance #PatternMatching #Arrays +#light + +// Verify ability to match against empty arrays +let isEmpty x = + match x with + | [| |] -> true + | _ -> false + +if isEmpty [| |] <> true then exit 1 +if isEmpty [| 1 .. 10 |] <> false then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/arrayMatch03.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/arrayMatch03.fs new file mode 100644 index 00000000000..b22696f27ee --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/arrayMatch03.fs @@ -0,0 +1,16 @@ +// #Conformance #PatternMatching #Arrays +#light + +// Verify ability to match against null arrays + +let isNull x = + match x with + | [| |] -> false + | null -> true + | _ -> false + +if isNull [| |] <> false then exit 1 +if isNull [| 1 .. 10 |] <> false then exit 1 +if isNull null <> true then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/As/As.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/As/As.fs new file mode 100644 index 00000000000..81867fed44a --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/As/As.fs @@ -0,0 +1,63 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Conformance.PatternMatching + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module As = + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/As) + [] + let ``Simple - asPattern01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/As) + [] + let ``Simple - asPattern02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + + [] + let ``As patterns``() = + Fsx """ + let (|Id|) = id + let a = [1..4] + match a with + | 1 | 1 as b::(Id 2 as c as c2)::[d as 3; Id e & Id _ as Id 4] as Id f when b = 1 && c = 2 && c2 = 2 && d = 3 && e = 4 && a = f -> () + | _ -> failwith "Match failed" + """ + |> asExe + |> withLangVersion60 + |> compileExeAndRun + |> shouldSucceed + + [] + [] + [] + [] + [] + [] + let ``Test type matching for subtypes and interfaces`` typ value = + Fsx $""" +open System +let classify (o: obj) = + match o with + | :? {typ} as d when d = Unchecked.defaultof<_> -> "default" + | :? IFormattable -> "formattable" + | _ -> "not a {typ}" + +let res = classify {value} +if res <> "formattable" then + failwith $"Unexpected result: {{res}}" + """ + |> asExe + |> compileAndRun + |> shouldSucceed \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/As/asPattern01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/As/asPattern01.fs new file mode 100644 index 00000000000..a21ff5850b5 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/As/asPattern01.fs @@ -0,0 +1,11 @@ +// #Conformance #PatternMatching +#light + +let t1 = (1, 2) +let (x, y) as asPatResult = t1 + +if x <> 1 then exit 1 +if y <> 2 then exit 1 +if asPatResult <> (1, 2) then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/As/asPattern02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/As/asPattern02.fs new file mode 100644 index 00000000000..6ed1a381e52 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/As/asPattern02.fs @@ -0,0 +1,20 @@ +// #Conformance #PatternMatching +#light + +// Verify 'as pattern' construct + +let test x = + match x with + | (1, _) | (_, 2) as result + -> if fst result <> 1 && + snd result <> 2 then + false + else + true + | _ -> false + +if test (1, 0) <> true then exit 1 +if test (0, 2) <> true then exit 1 +if test (3, 3) <> false then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/ConsList.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/ConsList.fs new file mode 100644 index 00000000000..574036ad9a2 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/ConsList.fs @@ -0,0 +1,56 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Conformance.PatternMatching + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module ConsList = + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/ConsList) + [] + let ``ConsList - consPattern01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/ConsList) + [] + let ``ConsList - E_consOnNonList_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1, Line 4, Col 21, Line 4, Col 28, "This expression was expected to have type + 'int' +but here has type + ''a list' ") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/ConsList) + [] + let ``ConsList - E_consPattern01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 15, Col 22, Line 15, Col 24, "This expression was expected to have type + 'int' +but here has type + ''a list' ") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/ConsList) + [] + let ``ConsList - OutsideMatch01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 25, Line 6, Col 5, Line 6, Col 16, "Incomplete pattern matches on this expression. For example, the value '[_]' may indicate a case not covered by the pattern(s).") \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/E_consOnNonList.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/E_consOnNonList.fs new file mode 100644 index 00000000000..b7ce650ebd6 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/E_consOnNonList.fs @@ -0,0 +1,7 @@ +// #Regression #Conformance #PatternMatching +//This expression was expected to have type. 'int' .but here has type. ''a list' +let f (x : int) = match x with + | _ :: [] -> 1 + | _ :: _ :: [] -> 2 + | _ -> 0 + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/E_consPattern01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/E_consPattern01.fs new file mode 100644 index 00000000000..26e6aff27b4 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/E_consPattern01.fs @@ -0,0 +1,17 @@ +// #Regression #Conformance #PatternMatching +//This expression was expected to have type. 'int' .but here has type. ''a list' +// Verify that a '[]' is only valid at the end of a list in a cons pattern +// This is OK. Type inference will pick up that this x is a generic list of lists. + +let test x = + match x with + | firstele :: secondele :: thirdele :: fourthele -> 0//firstele + secondele + | firstele :: [] :: thirdele -> 0//first + thirdele + | _ -> 0 + +let test2 (x : int list) = + match x with + | fst :: snd :: tail -> fst + snd + | lastElement :: [] :: [] -> 0 + | fst :: [] :: tail -> failwith "Shouldn't get here." + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/OutsideMatch01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/OutsideMatch01.fs new file mode 100644 index 00000000000..bff09153aa7 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/OutsideMatch01.fs @@ -0,0 +1,12 @@ +// #Conformance #PatternMatching +#light + +// Verify pattern matching on lists outside of a patch statement + +let a :: b :: c = [1; 2; 3] + +if a <> 1 then exit 1 +if b <> 2 then exit 1 +if c <> [3] then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/consPattern01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/consPattern01.fs new file mode 100644 index 00000000000..c752b680855 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/consPattern01.fs @@ -0,0 +1,17 @@ +// #Conformance #PatternMatching +#light + +// Verify that [] works at the end of a list +let rec lengthOf x = + match x with + | [] -> 0 + | _ :: [] -> 1 + | _ :: _ :: [] -> 2 + | hd :: tail -> 1 + lengthOf tail + +if lengthOf [] <> 0 then exit 1 +if lengthOf [1] <> 1 then exit 1 +if lengthOf [1;2] <> 2 then exit 1 +if lengthOf [1..10] <> 10 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/ArrayTypeTest01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/ArrayTypeTest01.fs new file mode 100644 index 00000000000..aac4071fbc9 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/ArrayTypeTest01.fs @@ -0,0 +1,16 @@ +// #Conformance #PatternMatching #TypeTests +#light + +// Verify ability to specify an integer array in a dynamic type test + +let isIntArray (o: obj) = + match o with + | :? (int[]) -> 1 + | :? (string array) -> 2 + | _ -> 3 + +if isIntArray (box [| 0; 1 |]) <> 1 then exit 1 +if isIntArray (box [| "xx" |]) <> 2 then exit 1 +if isIntArray (box [1 .. 100]) <> 3 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/DynamicTypeTest.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/DynamicTypeTest.fs new file mode 100644 index 00000000000..24d0b08e67d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/DynamicTypeTest.fs @@ -0,0 +1,158 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Conformance.PatternMatching + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module DynamicTypeTest = + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) + [] + let ``DynamicTypeTest - consPattern01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) + [] + let ``DynamicTypeTest - dynamicTypeTest01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) + [] + let ``DynamicTypeTest - dynamicTypeTest02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 26, Line 31, Col 7, Line 31, Col 22, "This rule will never be matched") + (Warning 26, Line 32, Col 7, Line 32, Col 22, "This rule will never be matched") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) + [] + let ``DynamicTypeTest - dynamicTypeTest03_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) + [] + let ``DynamicTypeTest - dynamicTypeTest04_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 64, Line 8, Col 7, Line 8, Col 11, "This construct causes code to be less generic than indicated by its type annotations. The type variable implied by the use of a '#', '_' or other type annotation at or near 'dynamicTypeTest04.fs(8,9)-(8,10)' has been constrained to be type 'exn'.") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) + [] + let ``DynamicTypeTest - dynTestSealedType01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) + [] + let ``DynamicTypeTest - E_DynamicTestPrimType01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 16, Line 11, Col 7, Line 11, Col 15, "The type 'int' does not have any proper subtypes and cannot be used as the source of a type test or runtime coercion.") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) + [] + let ``DynamicTypeTest - E_DynamTyTestVarType01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 8, Line 12, Col 7, Line 12, Col 13, "This runtime coercion or type test from type + 'a + to + obj +involves an indeterminate type based on information prior to this program point. Runtime type tests are not allowed on some types. Further type annotations are needed.") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) + [] + let ``DynamicTypeTest - genericType01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) + [] + let ``DynamicTypeTest - Regression01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) + [] + let ``DynamicTypeTest - Regression02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) + [] + let ``DynamicTypeTest - TwoAtOnce01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) + [] + let ``DynamicTypeTest - W_RedundantPattern01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 26, Line 12, Col 7, Line 12, Col 22, "This rule will never be matched") + (Warning 26, Line 18, Col 7, Line 18, Col 22, "This rule will never be matched") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) + [] + let ``DynamicTypeTest - W_TypeTestWillAlwaysHold01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 67, Line 13, Col 7, Line 13, Col 13, "This type test or downcast will always hold") \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/E_DynamTyTestVarType01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/E_DynamTyTestVarType01.fs new file mode 100644 index 00000000000..bb9698f08c5 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/E_DynamTyTestVarType01.fs @@ -0,0 +1,15 @@ +// #Regression #Conformance #PatternMatching #TypeTests +#light + +// Verify error associated with doing a dynamic type +// test on a variable type. + +//This runtime coercion or type test from type + +// Error, x has type 'a and cannot be used in a dynamic type test. +let f x = + match x with + | :? obj as o -> true + | _ -> false + +exit 1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/E_DynamicTestPrimType01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/E_DynamicTestPrimType01.fs new file mode 100644 index 00000000000..08240f6da0e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/E_DynamicTestPrimType01.fs @@ -0,0 +1,14 @@ +// #Regression #Conformance #PatternMatching #TypeTests +#light + +// Verify error when using a dynamic type test on +// type without any proper sub types. + +//The type 'int' does not have any proper subtypes and cannot be used as the source of a type test or runtime coercion + +let test (x : int) = + match x with + | :? float -> false + | _ -> false + +exit 1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/Regression01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/Regression01.fs new file mode 100644 index 00000000000..7c3c7bc0d8e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/Regression01.fs @@ -0,0 +1,27 @@ +// #Conformance #PatternMatching #TypeTests +// + +type Foo () = class end + +type Bar () = + inherit Foo() + +let instOfBox = box <| Bar() + +let test1() = + match true, instOfBox with + | false, :? Bar -> 1 // Shouldn't match, true <> false + | _, :? Foo -> 2 // Should return 2 + | _ -> 3 // Unexplored + +let test2() = + match instOfBox, true with + | :? Bar, false -> 1 // Shouldn't match, false <> true + | :? Foo, _ -> 2 // Should return 2 + | _ -> 3 // Unexplored + + +if test1() <> 2 then exit 1 +if test2() <> 2 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/Regression02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/Regression02.fs new file mode 100644 index 00000000000..25d35db2165 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/Regression02.fs @@ -0,0 +1,18 @@ +// #Conformance #PatternMatching #TypeTests +#light + +// Verify you can use a dynamic type test against unit + +let isUnit (x : obj) = + match x with + | :? unit -> true + | _ -> false + + +let test1 = isUnit (box ()) +let test2 = isUnit (box 42) + +if test1 <> true then exit 1 +if test2 <> false then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/TwoAtOnce01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/TwoAtOnce01.fs new file mode 100644 index 00000000000..5c8e984ee7e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/TwoAtOnce01.fs @@ -0,0 +1,33 @@ +// #Conformance #PatternMatching #TypeTests +#light + +// Perform multiple dynamic type tests at once + +let printCode x y = + match box x, box y with + | (:? int as ix), (:? int as iy) + -> sprintf "%d-%d" ix iy + | (:? string as sx), (:? string as sy) + -> sprintf "%s-%s" sx sy + | (:? int as ix), (:? string as sy) + -> sprintf "%d-%s" ix sy + | (:? string as sx), (:? int as iy) + -> sprintf "%s-%d" sx iy + | _ -> "" + +let test1 = printCode 1 2 +if test1 <> "1-2" then exit 1 + +let test2 = printCode "foo" "baz" +if test2 <> "foo-baz" then exit 1 + +let test3 = printCode 4 "aire" +if test3 <> "4-aire" then exit 1 + +let test4 = printCode "Z" 26 +if test4 <> "Z-26" then exit 1 + +let test5 = printCode 'a' 1 +if test5 <> "" then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/W_RedundantPattern01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/W_RedundantPattern01.fs new file mode 100644 index 00000000000..5b31ed91546 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/W_RedundantPattern01.fs @@ -0,0 +1,21 @@ +// #Regression #Conformance #PatternMatching #TypeTests +#light + +// FSB 1488, Implement redundancy checking for dynamic type test patterns + +//This rule will never be matched +//This rule will never be matched + +let _ = + match box "3" with + | :? string -> 1 + | :? string -> 1 // check this rule is marked as 'never be matched' + | _ -> 2 + +let _ = + match box "3" with + | :? System.IComparable -> 1 + | :? string -> 1 // check this rule is marked as 'never be matched' + | _ -> 2 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/W_TypeTestWillAlwaysHold01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/W_TypeTestWillAlwaysHold01.fs new file mode 100644 index 00000000000..b4e8e83a785 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/W_TypeTestWillAlwaysHold01.fs @@ -0,0 +1,17 @@ +// #Regression #Conformance #PatternMatching #TypeTests +#light + +// Verify warning for when dynamic type test will always hold. +//This type test or downcast will always hold + + +type Foo() = + member this.Value = 42 + +let test (x : Foo) = + match x with + | :? Foo as xAsInt -> false + | _ -> false + + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynTestSealedType01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynTestSealedType01.fs new file mode 100644 index 00000000000..1128961fc6c --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynTestSealedType01.fs @@ -0,0 +1,27 @@ +// #Conformance #PatternMatching #TypeTests +#light + +// Verify result of dynamic type test on sealed type. + +type Foo() = + member this.FooValue = 42 + +[] +type Bar() = + inherit Foo() + member this.BarValue = 42 + + +let test (x : obj) = + match x with + | :? Bar -> 2 + | :? Foo -> 1 + | _ -> 3 + +let foo = new Foo() +let bar = new Bar() + +if test (foo :> obj) <> 1 then exit 1 +if test (bar :> obj) <> 2 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest01.fs new file mode 100644 index 00000000000..e618196f7a4 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest01.fs @@ -0,0 +1,27 @@ +// #Conformance #PatternMatching #TypeTests +#light + +open System + +// Verify "If present the identifier after as is bound to the value coerced to the given type." +let testException (ex : obj) = + let orgType = ex.GetType().ToString() + match ex with + | :? System.NotSupportedException as dynamicType -> + let typeStr = dynamicType.GetType().ToString() + if typeStr <> orgType then + false + else + true + | :? System.Exception as dynamicType -> + let typeStr = dynamicType.GetType().ToString() + if typeStr <> orgType then + false + else + true + | _ -> false + +if testException (new ArgumentException("") :> obj) <> true then exit 1 +if testException (new NotSupportedException("") :> obj) <> true then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest02.fs new file mode 100644 index 00000000000..1566b387920 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest02.fs @@ -0,0 +1,45 @@ +// #Conformance #PatternMatching #TypeTests +#light + +open System + +type Shape() = + abstract VirtMember : unit -> string + default this.VirtMember () = "shape" + member this.StaticMember() = "shape" + +type Ellipse() = + inherit Shape() + override this.VirtMember() = "ellipse" + member this.StaticMember() = "ellipse" + +type Circle() = + inherit Shape() + override this.VirtMember() = "circle" + member this.StaticMember() = "circle" + +let test1 (x:obj) = + match x with + | :? Circle -> 1 + | :? Ellipse -> 2 + | :? Shape -> 3 + | _ -> 4 + +let test2 (x:obj) = + match x with + | :? Shape -> 1 + | :? Ellipse -> 2 + | :? Circle -> 3 + | _ -> 4 + +if test1 (new Circle() :> obj) <> 1 then exit 1 +if test1 (new Ellipse() :> obj) <> 2 then exit 1 +if test1 (new Shape() :> obj) <> 3 then exit 1 +if test1 ("foo" :> obj) <> 4 then exit 1 + +if test2 (new Circle() :> obj) <> 1 then exit 1 +if test2 (new Ellipse() :> obj) <> 1 then exit 1 +if test2 (new Shape() :> obj) <> 1 then exit 1 +if test2 ("foo" :> obj) <> 4 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest03.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest03.fs new file mode 100644 index 00000000000..46cfe11da48 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest03.fs @@ -0,0 +1,63 @@ +// #Regression #Conformance #PatternMatching #TypeTests +// FSB 1034, Downcasting for interface types +// This test verifies that dynamic type test patterns work on objects which cannot +// statically be checked if they implement the interface. (For example, A implements IFoo and IBar +// dynamically checking if an instance of (A :> IFoo) implements IBar. + +// NB. Years hard coded to avoid introducing non-determinism +type IAge = interface + abstract Age : int + end + +type IAges = interface + abstract GrowOlder : int -> unit + end + +type Car(modelYear : int) = + let mutable m_miles = 0 + let Odometer = m_miles + + interface IAge with + member this.Age = 2008 - modelYear + interface IAges with + member this.GrowOlder x = m_miles <- m_miles + x + +type Person(yearBorn : int) = + let mutable m_yearsOld = 2008 - yearBorn + + interface IAge with + member this.Age = m_yearsOld + + interface IAges with + member this.GrowOlder x = m_yearsOld <- m_yearsOld + x + +type Wine(year : int) = + interface IAge with + member this.Age = year + +// Variables +let me = new Person(1982) +let myCar = new Car(2005) +let myWine = new Wine(1) + +let myStuff = [ (myWine :> IAge); (me :> IAge); (myCar :> IAge) ] + +// Functions +let totalAge (iAgeList : IAge list) = iAgeList |> List.map (fun iage -> iage.Age) |> List.sum + +let rec ageOneYear (l:IAge list) = + match l with + | (:? IAges as agingThing) :: tl -> agingThing.GrowOlder 1 + ageOneYear tl + | hd :: tl -> ageOneYear tl + | [] -> () + +// Tests +if totalAge myStuff <> 30 then exit 1 + +ageOneYear myStuff +// (In this test, wine doesn't age, and cars 'grow older' doesn't incement age') +if totalAge myStuff <> 31 then exit 2 + +exit 0 + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest04.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest04.fs new file mode 100644 index 00000000000..9cc6748b093 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest04.fs @@ -0,0 +1,12 @@ +// #Conformance #PatternMatching #TypeTests +#light + +let mutable testPassed = false +try + raise (System.Exception("")) +with + | :? _ -> testPassed <- true + +if testPassed <> true then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/genericType01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/genericType01.fs new file mode 100644 index 00000000000..df44c954dd0 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/genericType01.fs @@ -0,0 +1,16 @@ +// #Conformance #PatternMatching #TypeTests +#light + +let listOfWhat (x : 'a list) = + match box x with + | :? List -> "int list" + | :? List -> "string list" + | :? List -> "obj list" + | _ -> "unknown" + +if listOfWhat ["foo"] <> "string list" then exit 1 +if listOfWhat [1 .. 10] <> "int list" then exit 2 +if listOfWhat [([]:>obj)] <> "obj list" then exit 3 +if listOfWhat [ ] <> "obj list" then exit 4 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/E_CounterExample01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/E_CounterExample01.fs new file mode 100644 index 00000000000..a21c10ff946 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/E_CounterExample01.fs @@ -0,0 +1,9 @@ +// #Regression #Conformance #PatternMatching + // Regression test for FSHARP1.0:2034 +//Incomplete pattern matches on this expression\. For example, the value '0' may indicate a case not covered by the pattern\(s\) + +module TestModule +let f x = + match x with // warning FS0025: Incomplete pattern matches on this expression. For example, the value '0' may indicate a case not covered by the pattern(s) + | 1 -> 7 + | 2 -> 49 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/Expression.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/Expression.fs new file mode 100644 index 00000000000..de69758f748 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/Expression.fs @@ -0,0 +1,138 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Conformance.PatternMatching + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module Expression = + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Expression) + [] + let ``Expression - E_CounterExample01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 25, Line 7, Col 11, Line 7, Col 12, "Incomplete pattern matches on this expression. For example, the value '0' may indicate a case not covered by the pattern(s).") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Expression) + [] + let ``Expression - NoCounterExampleTryWith01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Expression) + [] + let ``Expression - patterns01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Expression) + [] + let ``Expression - patterns02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 25, Line 6, Col 24, Line 6, Col 25, "Incomplete pattern matches on this expression. For example, the value 'false' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 7, Col 24, Line 7, Col 25, "Incomplete pattern matches on this expression. For example, the value '0' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 8, Col 35, Line 8, Col 36, "Incomplete pattern matches on this expression.") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Expression) + [] + let ``Expression - W_CounterExampleWithEnum01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 25, Line 14, Col 10, Line 14, Col 18, "Incomplete pattern matches on this expression. For example, the value '\"a\"' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 18, Col 10, Line 18, Col 18, "Incomplete pattern matches on this expression. For example, the value '0.0' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 22, Col 10, Line 22, Col 18, "Incomplete pattern matches on this expression. For example, the value '' '' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 26, Col 10, Line 26, Col 18, "Incomplete pattern matches on this expression. For example, the value '1y' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 30, Col 10, Line 30, Col 18, "Incomplete pattern matches on this expression. For example, the value '[_;_;_]' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 34, Col 10, Line 34, Col 18, "Incomplete pattern matches on this expression. For example, the value '[|_; 1|]' may indicate a case not covered by the pattern(s).") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Expression) + [] + let ``Expression - W_CounterExampleWithEnum02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 104, Line 14, Col 10, Line 14, Col 18, "Enums may take values outside known cases. For example, the value 'enum (2)' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 18, Col 10, Line 18, Col 18, "Incomplete pattern matches on this expression. For example, the value 'T.Y' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 21, Col 10, Line 21, Col 18, "Incomplete pattern matches on this expression. For example, the value 'T.Y' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 24, Col 10, Line 24, Col 18, "Incomplete pattern matches on this expression. For example, the value 'T.Y' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 27, Col 10, Line 27, Col 18, "Incomplete pattern matches on this expression. For example, the value 'T.Y' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 30, Col 10, Line 30, Col 18, "Incomplete pattern matches on this expression. For example, the value 'T.Y' may indicate a case not covered by the pattern(s).") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Expression) + [] + let ``Expression - W_whenGuards01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 25, Line 11, Col 9, Line 11, Col 10, "Incomplete pattern matches on this expression. For example, the value '1' may indicate a case not covered by the pattern(s). However, a pattern rule with a 'when' clause might successfully match this value.") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Expression) + [] + let ``Expression - whenGuards01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Expression) + [] + let ``Expression - whenGuards02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Expression) + [] + let ``Expression - whenGuardss01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Expression) + [] + let ``Expression - whenGuardss02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/NoCounterExampleTryWith01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/NoCounterExampleTryWith01.fs new file mode 100644 index 00000000000..920200ca911 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/NoCounterExampleTryWith01.fs @@ -0,0 +1,25 @@ +// #Regression #Conformance #PatternMatching +// Regression test for DevDiv:198999 ("Warning messages for incomplete matches involving enum types are wrong") +// Not really regression tests for the bug, but these 2 cases cover code that was touched +// + +module M + +// Unterminated try-with +let h1 = + try + () + raise (new System.NotImplementedException()) + with + | :? System.NotFiniteNumberException -> () + +// Unterminated try-with in a computation expr +let a = + async { + try + () + raise (new System.NotImplementedException()) + with + | :? System.NotFiniteNumberException -> () + } + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/W_CounterExampleWithEnum01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/W_CounterExampleWithEnum01.fs new file mode 100644 index 00000000000..0a9a8c17b4e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/W_CounterExampleWithEnum01.fs @@ -0,0 +1,36 @@ +// #Regression #Conformance #PatternMatching +// Regression test for DevDiv:198999 ("Warning messages for incomplete matches involving enum types are wrong") +//Incomplete pattern matches on this expression\. For example, the value '"a"' may indicate a case not covered by the pattern\(s\)\.$ +//Incomplete pattern matches on this expression\. For example, the value '0\.0' may indicate a case not covered by the pattern\(s\)\.$ +//Incomplete pattern matches on this expression\. For example, the value '' '' may indicate a case not covered by the pattern\(s\)\.$ +//Incomplete pattern matches on this expression\. For example, the value '1y' may indicate a case not covered by the pattern\(s\)\.$ +//Incomplete pattern matches on this expression\. For example, the value '\[_;_;_\]' may indicate a case not covered by the pattern\(s\)\.$ +//Incomplete pattern matches on this expression\. For example, the value '\[|_; 1|\]' may indicate a case not covered by the pattern\(s\)\.$ + +module M + +type T = | X = 0 | Y = 1 + +let f1 = function + | "X" -> T.X + | "Y" -> T.Y + +let f2 = function + | 1. -> T.X + | 2. -> T.Y + +let f3 = function + | 'a' -> T.X + | 'b' -> T.Y + +let f4 = function + | 0y -> T.X + | 2y -> T.Y + +let f5 = function + | [1 ; 2] -> T.X + | [_] -> T.Y + +let f6 = function + | [|1 ; 2|] -> T.X + | [|_;0|] -> T.Y diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/W_CounterExampleWithEnum02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/W_CounterExampleWithEnum02.fs new file mode 100644 index 00000000000..f93dab37adb --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/W_CounterExampleWithEnum02.fs @@ -0,0 +1,32 @@ +// #Regression #Conformance #PatternMatching +// Regression test for DevDiv:198999 ("Warning messages for incomplete matches involving enum types are wrong") +//Enums may take values outside known cases\. For example, the value 'enum \(2\)' may indicate a case not covered by the pattern\(s\)\.$ +//Incomplete pattern matches on this expression\. For example, the value 'T.Y' may indicate a case not covered by the pattern\(s\)\.$ +//Incomplete pattern matches on this expression\. For example, the value 'T.Y' may indicate a case not covered by the pattern\(s\)\.$ +//Incomplete pattern matches on this expression\. For example, the value 'T.Y' may indicate a case not covered by the pattern\(s\)\.$ +//Incomplete pattern matches on this expression\. For example, the value 'T.Y' may indicate a case not covered by the pattern\(s\)\.$ +//Incomplete pattern matches on this expression\. For example, the value 'T.Y' may indicate a case not covered by the pattern\(s\)\.$ + +module M + +type T = | X = 0 | Y = 1 + +let g1 = function + | T.X -> "X" + | T.Y -> "y" + +let g2 = function + | T.X -> 1. + +let g3 = function + | T.X -> 'a' + +let g4 = function + | T.X -> 2y + +let g5 = function + | T.X -> [1 ; 2] + +let g6 = function + | T.X -> [|1 ; 2|] + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/W_whenGuards01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/W_whenGuards01.fs new file mode 100644 index 00000000000..bba3809ea50 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/W_whenGuards01.fs @@ -0,0 +1,16 @@ +// #Regression #Conformance #PatternMatching +module TestModule + +// Regression testcase for FSharp 1.0: 2070 +// Warn on incomplete match with when guard + +//Incomplete pattern matches on this expression\. For example, the value '1' may indicate a case not covered by the pattern\(s\)\. However, a pattern rule with a 'when' clause might successfully match this value + + +let matchWarning s = + match s with + | 0 -> true + | n when n>0 -> false + +exit 0 + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/patterns01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/patterns01.fs new file mode 100644 index 00000000000..92e27717e82 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/patterns01.fs @@ -0,0 +1,18 @@ +// #Conformance #PatternMatching +#light + +// Verify the first verticle bar in a pattern match is optinal. + +let test1 x = match x with "0" -> 0 | "1" -> 1 | _ -> -1 + +let test2 x = + match x with + "0" -> 0 + | "1" -> 1 + | _ -> -1 + +if (test1 "0") <> (test2 "0") then exit 1 +if (test1 "1") <> (test2 "1") then exit 1 +if (test1 "2") <> (test2 "2") then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/patterns02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/patterns02.fs new file mode 100644 index 00000000000..a8ebbe39689 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/patterns02.fs @@ -0,0 +1,16 @@ +// #Conformance #PatternMatching +#light + +// Verify ability to match just a single identifier + +let testTrue x = match x with true -> true +let test42 x = match x with 42 -> true +let testEven (x : string) = match x with _ when x.Length % 2 = 0 -> true +let identity x = match x with y -> y + +if (testTrue true) <> true then exit 1 +if (test42 42) <> true then exit 1 +if (testEven "aabbcc") <> true then exit 1 +if (identity ("apple", "ORANGE")) <> ("apple", "ORANGE") then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/whenGuards01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/whenGuards01.fs new file mode 100644 index 00000000000..d14f4fa3b0b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/whenGuards01.fs @@ -0,0 +1,37 @@ +// #Conformance #PatternMatching +#light + +// Test that when guards only execute once the match value has +// matched the pattern associated with the rule. + +let mutable m_flag = 0 +let flagSet() = m_flag = 1 +let resetFlag() = m_flag <- 0 + +let testMatch x = + match x with + | 1 when (m_flag <- 1; true) -> 1 + | 2 when (m_flag <- 1; false) -> 2 + | _ -> 0 + + +// 0 should hit the wildcard, and testMatch should return 0 +resetFlag() +if testMatch 0 <> 0 then exit 1 +if flagSet() then exit 1 + +// 1 should have been matched, setting the flag to true +// and with the where guard succeeding, the match statement +// returned 1 as well. +resetFlag() +if testMatch 1 <> 1 then exit 1 +if not (flagSet()) then exit 1 + +// 2 should have been matched, setting the flat to true +// but, since the where guard failed, the match statement +// hit the wild card- returning 0 +resetFlag() +if testMatch 2 <> 0 then exit 1 +if not (flagSet()) then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/whenGuards02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/whenGuards02.fs new file mode 100644 index 00000000000..530ed514f06 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/whenGuards02.fs @@ -0,0 +1,20 @@ +// #Conformance #PatternMatching +#light + +// Verify that if the when guard fails, that pattern is not matched. + +let complexXOR x y = + match x with + | true when not y -> true + | false when y -> true + | true when y -> false + | false when not y -> false + | _ -> failwith "not possible" + +let simpleXOR x y = x <> y + +let runTest (x, y) = if complexXOR x y <> simpleXOR x y then exit 1 +let testSuite = [(true, true); (true, false); (false, true); (false, false)] +List.iter runTest testSuite + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/whenGuardss01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/whenGuardss01.fs new file mode 100644 index 00000000000..d14f4fa3b0b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/whenGuardss01.fs @@ -0,0 +1,37 @@ +// #Conformance #PatternMatching +#light + +// Test that when guards only execute once the match value has +// matched the pattern associated with the rule. + +let mutable m_flag = 0 +let flagSet() = m_flag = 1 +let resetFlag() = m_flag <- 0 + +let testMatch x = + match x with + | 1 when (m_flag <- 1; true) -> 1 + | 2 when (m_flag <- 1; false) -> 2 + | _ -> 0 + + +// 0 should hit the wildcard, and testMatch should return 0 +resetFlag() +if testMatch 0 <> 0 then exit 1 +if flagSet() then exit 1 + +// 1 should have been matched, setting the flag to true +// and with the where guard succeeding, the match statement +// returned 1 as well. +resetFlag() +if testMatch 1 <> 1 then exit 1 +if not (flagSet()) then exit 1 + +// 2 should have been matched, setting the flat to true +// but, since the where guard failed, the match statement +// hit the wild card- returning 0 +resetFlag() +if testMatch 2 <> 0 then exit 1 +if not (flagSet()) then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/whenGuardss02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/whenGuardss02.fs new file mode 100644 index 00000000000..530ed514f06 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/whenGuardss02.fs @@ -0,0 +1,20 @@ +// #Conformance #PatternMatching +#light + +// Verify that if the when guard fails, that pattern is not matched. + +let complexXOR x y = + match x with + | true when not y -> true + | false when y -> true + | true when y -> false + | false when not y -> false + | _ -> failwith "not possible" + +let simpleXOR x y = x <> y + +let runTest (x, y) = if complexXOR x y <> simpleXOR x y then exit 1 +let testSuite = [(true, true); (true, false); (false, true); (false, false)] +List.iter runTest testSuite + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/ActivePatternOutsideMatch01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/ActivePatternOutsideMatch01.fs new file mode 100644 index 00000000000..a33f0d712b7 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/ActivePatternOutsideMatch01.fs @@ -0,0 +1,20 @@ +// #Conformance #PatternMatching #ActivePatterns +// Verify active patterns can be used outside of a match statement + +// This is really needed to make sure the test runs fine on non-ENU boxes! +// ToString() may use , or . or whatever symbols is defined for the floating point +System.Threading.Thread.CurrentThread.CurrentCulture <- System.Globalization.CultureInfo.InvariantCulture + +let (|ToString|) (x : decimal) = x.ToString() + +let (ToString test1) = 1234.56789M +if test1 <> "1234.56789" then exit 1 + +// Test nesting outside of match statements +let (|ToFloat|) (x : string) = System.Double.Parse(x) + +// decimal -> string -> float +let (ToString (ToFloat test2)) = 1234.56789M +if test2 <> 1234.56789 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/ActivePatternOutsideMatch02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/ActivePatternOutsideMatch02.fs new file mode 100644 index 00000000000..3dd34ab58a0 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/ActivePatternOutsideMatch02.fs @@ -0,0 +1,13 @@ +// #Conformance #PatternMatching #ActivePatterns +#light + +// Verify active patterns outside of match statement +// where active pattern defines a function. (Regression.) + +let (|ApplyTwice|) (x : int -> int) = x >> x + +let (ApplyTwice result) = fun x -> x * x + +if result 2 <> 2 * 2 * 2 * 2 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/ActivePatternUnconstrained01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/ActivePatternUnconstrained01.fs new file mode 100644 index 00000000000..40d9a92b90d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/ActivePatternUnconstrained01.fs @@ -0,0 +1,13 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for FSHARP1.0:5590 +// Note that the real test is E_ActivePatternUnconstrained01.fs +// This ones shows just one way to make the code compile again + +let (|A1|A2|A3|) (inp:int) : Choice = + printfn "hello" + printfn "hello" + A1 + +let f2 x = match x with A1 -> 1 | A2 -> 2 | A3 -> 3 + +f2 3 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/AsHighOrderFunc01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/AsHighOrderFunc01.fs new file mode 100644 index 00000000000..a153b48a2f3 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/AsHighOrderFunc01.fs @@ -0,0 +1,34 @@ +// #Conformance #PatternMatching #ActivePatterns +#light + +// Verify ability to treat active patterns like higher-order functions + +// Single Case +let (|ToString|) (x : obj) = x.ToString() + +let sc = (|ToString|) +if sc 42 <> "42" then exit 1 + +// Multi Case +let rec (|Odd|Even|) x = + match x with + | 0 -> Even + | 1 -> Odd + | _ -> match x - 1 with + | Even -> Odd + | Odd -> Even + +let mc = (|Odd|Even|) + +let _ = match mc 3, mc 4 with + | Choice1Of2(_), Choice2Of2(_) -> () + | _ -> exit 1 + +// Partial +let (|IsThree|_|) x = if x = 3 then Some() else None + +let pap = (|IsThree|_|) +if pap 4 <> None then exit 1 +if pap 3 <> Some() then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatternHasNoFields.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatternHasNoFields.fs new file mode 100644 index 00000000000..9d323f7b4e0 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatternHasNoFields.fs @@ -0,0 +1,13 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for https://github.com/Microsoft/visualfsharp/issues/5745 +//Active patterns do not have fields. This syntax is invalid\. +open System.Text.RegularExpressions + +let (|USZipPlus4Code|_|) s = + let m = Regex.Match(s, @"^(\d{5})\-(\d{4})$") + if m.Success then + USZipPlus4Code(x=m.Groups.[1].Value, + y=m.Groups.[2].Value) + |> Some + else + None diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatternNotAFuncion.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatternNotAFuncion.fs new file mode 100644 index 00000000000..aa1ff9f0165 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatternNotAFuncion.fs @@ -0,0 +1,5 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for FSHARP1.0:5590 +//Active pattern '|A|B|' is not a function$ + +let (|A|B|) = failwith "" : Choice diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatternUnconstrained01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatternUnconstrained01.fs new file mode 100644 index 00000000000..86e8689d061 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatternUnconstrained01.fs @@ -0,0 +1,14 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for FSHARP1.0:5590 +// This code used to compile, but fail peverification +// Now, it just does not compile anymore telling the user to annotated it a bit. +//The result of this expression has type 'int' and is implicitly ignored\. Consider using 'ignore' to discard this value explicitly, e\.g\. 'expr \|> ignore', or 'let' to bind the result to a name, e\.g\. 'let result = expr'.$ +//Active pattern '\|A1\|A2\|A3\|' has a result type containing type variables that are not determined by the input\. The common cause is a when a result case is not mentioned, e\.g\. 'let \(\|A\|B\|\) \(x:int\) = A x'\. This can be fixed with a type constraint, e\.g\. 'let \(\|A\|B\|\) \(x:int\) : Choice = A x'$ +let (|A1|A2|A3|) (inp:int) : Choice = + printfn "hello" + printfn "hello" + A1 + +let f2 x = match x with A1 -> 1 | A2 -> 2 | A3 -> 3 + +f2 3 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatterns01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatterns01.fs new file mode 100644 index 00000000000..19bf8faee6c --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatterns01.fs @@ -0,0 +1,20 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Verify error if Active Patterns do not start with an upper case letter +//Active pattern case identifiers must begin with an uppercase letter +//Active pattern case identifiers must begin with an uppercase letter +//Active pattern case identifiers must begin with an uppercase letter +//Active pattern case identifiers must begin with an uppercase letter +//Active pattern case identifiers must begin with an uppercase letter +//The '\|' character is not permitted in active pattern case identifiers +//The '\|' character is not permitted in active pattern case identifiers +//Active pattern case identifiers must begin with an uppercase letter + +let (|positive|negative|) n = if n < 0 then positive else negative +let (|`` A``|) (x:int) = x +let (|B1|``+B2``|) (x:int) = if x = 0 then OneA else ``+B2`` +let (|`` C``|_|) (x:int) = if x = 0 then Some(x) else None +let (|``D|E``|F|) (x:int) = if x = 0 then D elif x = 1 then E else F +let (|G|``H||I``|) (x:int) = if x = 0 then G elif x = 1 then H else ``|I`` +let (|_J|) (x:int) = _J + +exit 1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatterns02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatterns02.fs new file mode 100644 index 00000000000..50273c1058f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ActivePatterns02.fs @@ -0,0 +1,8 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Verify error if Active Patterns used with named parameters +//A is an active pattern and cannot be treated as a discriminated union case with named fields. + +let (|A|B|) n = if n%2 = 0 then A n else B n +match 10 with A(hoho=n) -> n | _ -> 0 + +exit 1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_LetRec01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_LetRec01.fs new file mode 100644 index 00000000000..7269796810b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_LetRec01.fs @@ -0,0 +1,8 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for FSHARP1.0:4621 +//This expression was expected to have type. 'Choice<'a,'b>' .but here has type. 'string' + +let rec (|Foo|Bar|) (a:int) x = "BAD DOG!" + +exit 1 + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_LetRec02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_LetRec02.fs new file mode 100644 index 00000000000..c135beefc1a --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_LetRec02.fs @@ -0,0 +1,4 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for FSHARP1.0:4621 +//This is not a valid name for an active pattern +let rec (|Foo2|Bar2|_|) (a:int) x = "BAD DOG!" diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_LetRec03.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_LetRec03.fs new file mode 100644 index 00000000000..e39c8fb59bd --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_LetRec03.fs @@ -0,0 +1,4 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for FSHARP1.0:4621 +//This is not a valid name for an active pattern +let rec (|Foo2b|Bar2b|Baz2b|_|) (a:int) x = "BAD DOG!" diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_LetRec04.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_LetRec04.fs new file mode 100644 index 00000000000..5ed84d6a36e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_LetRec04.fs @@ -0,0 +1,5 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for FSHARP1.0:4621 +//This expression was expected to have type. ''a option' .but here has type. 'string' +let rec (|Foo3|_|) (a:int) x = "BAD DOG!" + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_NonParam01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_NonParam01.fs new file mode 100644 index 00000000000..25f75485341 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_NonParam01.fs @@ -0,0 +1,5 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for FSHARP1.0:4621 +//This expression was expected to have type. 'Choice<'a,'b>' .but here has type. 'string' +let (|Foo|Bar|) x = "BAD DOG!" + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_NonParam02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_NonParam02.fs new file mode 100644 index 00000000000..1ed1e40e379 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_NonParam02.fs @@ -0,0 +1,4 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for FSHARP1.0:4621 +//This is not a valid name for an active pattern +let (|Foo2|Bar2|_|) x = "BAD DOG!" // expect: invalid name for an active pattern diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_NonParam03.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_NonParam03.fs new file mode 100644 index 00000000000..4387147760d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_NonParam03.fs @@ -0,0 +1,4 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for FSHARP1.0:4621 +//This is not a valid name for an active pattern +let (|Foo2b|Bar2b|Baz2b|_|) x = "BAD DOG!" // expect: type string doesn't match type 'choice' diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_NonParam04.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_NonParam04.fs new file mode 100644 index 00000000000..0553d6f6892 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_NonParam04.fs @@ -0,0 +1,5 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for FSHARP1.0:4621 +//This expression was expected to have type. ''a option' .but here has type. 'string' +let (|Foo3|_|) x = "BAD DOG!" // expect: type string doesn't match type 'option' + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_Param01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_Param01.fs new file mode 100644 index 00000000000..067d07a46aa --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_Param01.fs @@ -0,0 +1,5 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for FSHARP1.0:4621 +//This expression was expected to have type. 'Choice<'a,'b>' .but here has type. 'string' +let (|Foo|Bar|) (a:int) x = "BAD DOG!" + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_Param02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_Param02.fs new file mode 100644 index 00000000000..74ced64a2ed --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_Param02.fs @@ -0,0 +1,4 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for FSHARP1.0:4621 +//This is not a valid name for an active pattern +let (|Foo2|Bar2|_|) (a:int) x = "BAD DOG!" // expect: invalid name for an active pattern diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_Param03.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_Param03.fs new file mode 100644 index 00000000000..372bde3ce8c --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_Param03.fs @@ -0,0 +1,4 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for FSHARP1.0:4621 +//This is not a valid name for an active pattern +let (|Foo2b|Bar2b|Baz2b|_|) (a:int) x = "BAD DOG!" // expect: type string doesn't match type 'choice' diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_Param04.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_Param04.fs new file mode 100644 index 00000000000..4467425d462 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_Error_Param04.fs @@ -0,0 +1,5 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for FSHARP1.0:4621 +//This expression was expected to have type. ''a option' .but here has type. 'string' +let (|Foo3|_|) (a:int) x = "BAD DOG!" + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_LargeActivePat01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_LargeActivePat01.fs new file mode 100644 index 00000000000..d356af71baa --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_LargeActivePat01.fs @@ -0,0 +1,7 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Verify error when defining an Active Pattern with more than seven 'values' +// This is regression test for FSHARP1.0:3562 +//Active patterns cannot return more than 7 possibilities$ + +let (|One|Two|Three|Four|Five|Six|Seven|Eight|) x = One + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_MulticasePartialNotAllowed01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_MulticasePartialNotAllowed01.fs new file mode 100644 index 00000000000..f1633373916 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_MulticasePartialNotAllowed01.fs @@ -0,0 +1,24 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Regression test for FSHARP1.0:4621 +// Multi case partial active patterns are not allowed + +//This is not a valid name for an active pattern +//The pattern discriminator 'Sentence' is not defined + +let (|Sentence|Word|Punctuation|WhiteSpace|_|) (input : string) = + if input.Trim() = "" then + Some(WhiteSpace()) + elif input.IndexOf(" ") <> -1 then + Some(Sentence (input.Split([|" "|], System.StringSplitOptions.RemoveEmptyEntries))) + else + match input with + | "." | ";" | "," | ":" | "?" | "!" -> Some(Punctuation(input.ToCharArray().[0])) + | _ -> Some(Word (input)) + +let test str = + match str with + | Sentence words -> words.Length // All words in sentence + | Word word -> word.Length // Characters in word + | WhiteSpace -> 0 + | Punctuation _ -> -1 + | _ -> failwith "Should not happen" diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ParameterRestrictions01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ParameterRestrictions01.fs new file mode 100644 index 00000000000..c3e907519e3 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_ParameterRestrictions01.fs @@ -0,0 +1,17 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +#light + +// Verify error cases for restrictions on active pattern parameters. +//Only active patterns returning exactly one result may accept arguments + + +// Multi-Case +let rec (|MCAP|MCAP2|) (times : int) (ip : string) = + match times with + | 0 -> MCAP (ip + "!") + | 1 -> MCAP2(ip + ".") + | x -> (|MCAP|MCAP2|) (times - 1) (ip + "-") + +let _ = match "" with MCAP 0 "!" -> () | _ -> exit 1 + +exit 1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_PatternMatchRegressions02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_PatternMatchRegressions02.fs new file mode 100644 index 00000000000..a20ca0f6fd8 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/E_PatternMatchRegressions02.fs @@ -0,0 +1,33 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// FSHARP1.0:5590 (see also FSHARP1.0:1104, which is where this source came from) +//Incomplete pattern matches on this expression\.$ +//Incomplete pattern matches on this expression\.$ +//Active pattern '\|ClientExternalTypeUse\|WillFail\|' has a result type containing type variables that are not determined by the input\. The common cause is a when a result case is not mentioned, e\.g\. 'let \(\|A\|B\|\) \(x:int\) = A x'\. This can be fixed with a type constraint, e\.g\. 'let \(\|A\|B\|\) \(x:int\) : Choice = A x'$ + +#nowarn "57" + +open System +open System.Collections.Generic +open System.Reflection + +open Microsoft.FSharp.Reflection +open Microsoft.FSharp.Quotations + +let (|MapDeclaringType|_|) (mi:#MemberInfo) : Option = failwith "" +let (|CastToMemberInfo|) (mi:#MemberInfo) = (mi :> MemberInfo) +let (|MethodCall|_|) (e:Expr) : Option = failwith "" +let (|CtorCall|_|) (e:Expr) : Option = failwith "" + +// Error when multicase active patterns result type doesn't correspond to input value +let (|ClientExternalTypeUse|WillFail|) e = + match e with + | (MethodCall(MapDeclaringType(_, CastToMemberInfo(_)), _)) + | (CtorCall(MapDeclaringType(_, CastToMemberInfo(_)), _)) -> + failwith "" + +// Error above doesn't apply for single case active patterns +let (|ClientExternalTypeUse|_|) e = + match e with + | (MethodCall(MapDeclaringType(_, CastToMemberInfo(_)), _)) + | (CtorCall(MapDeclaringType(_, CastToMemberInfo(_)), _)) -> + failwith "" diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/MultiActivePatterns01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/MultiActivePatterns01.fs new file mode 100644 index 00000000000..59b209a258d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/MultiActivePatterns01.fs @@ -0,0 +1,49 @@ +// #Conformance #PatternMatching #ActivePatterns +#light + +// Test ability to spedify multiple active patterns in the same pattern match + +let (|A|_|) x = if x = 'A' then Some() else None +let (|B|_|) x = if x = 'B' then Some() else None +let (|C|_|) x = if x = 'C' then Some() else None +let (|D|_|) x = if x = 'D' then Some() else None +let (|E|_|) x = if x = 'E' then Some() else None +let (|F|_|) x = if x = 'F' then Some() else None +let (|G|_|) x = if x = 'G' then Some() else None +let (|H|_|) x = if x = 'H' then Some() else None +let (|I|_|) x = if x = 'I' then Some() else None +let (|J|_|) x = if x = 'J' then Some() else None +let (|K|_|) x = if x = 'K' then Some() else None +let (|L|_|) x = if x = 'L' then Some() else None +let (|M|_|) x = if x = 'M' then Some() else None +let (|N|_|) x = if x = 'N' then Some() else None +let (|O|_|) x = if x = 'O' then Some() else None +let (|P|_|) x = if x = 'P' then Some() else None +let (|Q|_|) x = if x = 'Q' then Some() else None +let (|R|_|) x = if x = 'R' then Some() else None +let (|S|_|) x = if x = 'S' then Some() else None +let (|T|_|) x = if x = 'T' then Some() else None +let (|U|_|) x = if x = 'U' then Some() else None +let (|V|_|) x = if x = 'V' then Some() else None +let (|W|_|) x = if x = 'W' then Some() else None +let (|X|_|) x = if x = 'X' then Some() else None +let (|Y|_|) x = if x = 'Y' then Some() else None +let (|Z|_|) x = if x = 'Z' then Some() else None + +let isLetter x = + match x with + | A | B | C | D | E + | F | G | H | I | J + | K | L | M | N | O + | P | Q | R | S | T + | U | V | W | X | Y + | Z -> true + | _ -> false + +let nonLetters = ['.'; ';'; '<'; '>'] |> List.map isLetter +let letters = ['A' .. 'Z'] |> List.map isLetter + +nonLetters |> List.iter (fun r -> if r = true then exit 1) +letters |> List.iter (fun r -> if r = false then exit 1) + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/Named.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/Named.fs new file mode 100644 index 00000000000..96c5fe773f2 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/Named.fs @@ -0,0 +1,469 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Conformance.PatternMatching + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module Named = + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - ActivePatternOutsideMatch01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - ActivePatternOutsideMatch02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - activePatterns01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - activePatterns02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - activePatterns03_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - activePatterns05_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - activePatterns06_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - activePatterns07_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - activePatterns08_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - ActivePatternUnconstrained01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> ignoreWarnings + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - AsHighOrderFunc01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - discUnion01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - _DiscUnion01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_ActivePatternHasNoFields_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 3174, Line 10, Col 24, Line 10, Col 25, "Active patterns do not have fields. This syntax is invalid.") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_ActivePatternNotAFuncion_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1209, Line 5, Col 6, Line 5, Col 11, "Active pattern '|A|B|' is not a function") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_ActivePatterns01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 623, Line 12, Col 7, Line 12, Col 15, "Active pattern case identifiers must begin with an uppercase letter") + (Error 623, Line 12, Col 16, Line 12, Col 24, "Active pattern case identifiers must begin with an uppercase letter") + (Error 623, Line 13, Col 7, Line 13, Col 13, "Active pattern case identifiers must begin with an uppercase letter") + (Error 623, Line 14, Col 10, Line 14, Col 17, "Active pattern case identifiers must begin with an uppercase letter") + (Error 623, Line 15, Col 7, Line 15, Col 13, "Active pattern case identifiers must begin with an uppercase letter") + (Error 624, Line 16, Col 7, Line 16, Col 14, "The '|' character is not permitted in active pattern case identifiers") + (Error 624, Line 17, Col 9, Line 17, Col 17, "The '|' character is not permitted in active pattern case identifiers") + (Error 623, Line 18, Col 7, Line 18, Col 9, "Active pattern case identifiers must begin with an uppercase letter") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_ActivePatterns02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 3210, Line 6, Col 15, Line 6, Col 24, "A is an active pattern and cannot be treated as a discriminated union case with named fields.") + (Warning 20, Line 6, Col 1, Line 6, Col 38, "The result of this expression has type 'int' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_ActivePatternUnconstrained01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 25, Line 12, Col 18, Line 12, Col 19, "Incomplete pattern matches on this expression.") + (Warning 20, Line 14, Col 1, Line 14, Col 5, "The result of this expression has type 'int' and is implicitly ignored. Consider using 'ignore' to discard this value explicitly, e.g. 'expr |> ignore', or 'let' to bind the result to a name, e.g. 'let result = expr'.") + (Error 1210, Line 7, Col 6, Line 7, Col 16, "Active pattern '|A1|A2|A3|' has a result type containing type variables that are not determined by the input. The common cause is a when a result case is not mentioned, e.g. 'let (|A|B|) (x:int) = A x'. This can be fixed with a type constraint, e.g. 'let (|A|B|) (x:int) : Choice = A x'") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_Error_LetRec01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 5, Col 9, Line 5, Col 30, "This expression was expected to have type + 'Choice<'a,'b>' +but here has type + 'string' ") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_Error_LetRec02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 827, Line 4, Col 9, Line 4, Col 34, "This is not a valid name for an active pattern") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_Error_LetRec03_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 827, Line 4, Col 10, Line 4, Col 43, "This is not a valid name for an active pattern") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_Error_LetRec04_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 4, Col 9, Line 4, Col 29, "This expression was expected to have type + ''a option' +but here has type + 'string' ") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_Error_NonParam01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 4, Col 5, Line 4, Col 18, "This expression was expected to have type + 'Choice<'a,'b>' +but here has type + 'string' ") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_Error_NonParam02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 827, Line 4, Col 5, Line 4, Col 22, "This is not a valid name for an active pattern") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_Error_NonParam03_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 827, Line 4, Col 5, Line 4, Col 30, "This is not a valid name for an active pattern") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_Error_NonParam04_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 4, Col 5, Line 4, Col 17, "This expression was expected to have type + ''a option' +but here has type + 'string' ") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_Error_Param01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 4, Col 5, Line 4, Col 26, "This expression was expected to have type + 'Choice<'a,'b>' +but here has type + 'string' ") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_Error_Param02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 827, Line 4, Col 5, Line 4, Col 31, "This is not a valid name for an active pattern") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_Error_Param03_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 827, Line 4, Col 5, Line 4, Col 38, "This is not a valid name for an active pattern") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_Error_Param04_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1, Line 4, Col 5, Line 4, Col 25, "This expression was expected to have type + ''a option' +but here has type + 'string' ") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_LargeActivePat01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 265, Line 6, Col 53, Line 6, Col 56, "Active patterns cannot return more than 7 possibilities") + + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_MulticasePartialNotAllowed01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 827, Line 8, Col 5, Line 8, Col 64, "This is not a valid name for an active pattern") + (Error 39, Line 20, Col 7, Line 20, Col 15, "The pattern discriminator 'Sentence' is not defined.") + (Error 72, Line 20, Col 25, Line 20, Col 37, "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.") + (Error 39, Line 21, Col 7, Line 21, Col 11, "The pattern discriminator 'Word' is not defined.") + (Error 72, Line 21, Col 20, Line 21, Col 31, "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.") + (Warning 49, Line 22, Col 7, Line 22, Col 17, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Error 39, Line 23, Col 7, Line 23, Col 18, "The pattern discriminator 'Punctuation' is not defined.") + (Warning 26, Line 23, Col 7, Line 23, Col 26, "This rule will never be matched") + (Warning 26, Line 24, Col 7, Line 24, Col 40, "This rule will never be matched") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_ParameterRestrictions01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 722, Line 15, Col 23, Line 15, Col 34, "Only active patterns returning exactly one result may accept arguments") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - E_PatternMatchRegressions02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 25, Line 23, Col 11, Line 23, Col 12, "Incomplete pattern matches on this expression.") + (Warning 25, Line 30, Col 11, Line 30, Col 12, "Incomplete pattern matches on this expression.") + (Error 1210, Line 22, Col 6, Line 22, Col 38, "Active pattern '|ClientExternalTypeUse|WillFail|' has a result type containing type variables that are not determined by the input. The common cause is a when a result case is not mentioned, e.g. 'let (|A|B|) (x:int) = A x'. This can be fixed with a type constraint, e.g. 'let (|A|B|) (x:int) : Choice = A x'") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - MultiActivePatterns01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - NamedLiteral01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - NamedLiteral02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - ParamertizedPartialActivePattern01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - PatternMatchRegressions01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 25, Line 22, Col 11, Line 22, Col 12, "Incomplete pattern matches on this expression.") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - PatternMatchRegressions02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 25, Line 20, Col 11, Line 20, Col 12, "Incomplete pattern matches on this expression.") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) + [] + let ``Named - RecursiveActivePats_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/NamedLiteral01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/NamedLiteral01.fs new file mode 100644 index 00000000000..8b3f85e2f21 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/NamedLiteral01.fs @@ -0,0 +1,21 @@ +// #Conformance #PatternMatching #ActivePatterns +#light + +// Match against an enum const defined in another assembly +open System + +let isWeekend day = + match day with + | DayOfWeek.Sunday | DayOfWeek.Saturday -> true + | DayOfWeek.Monday | DayOfWeek.Tuesday + | DayOfWeek.Wednesday | DayOfWeek.Thursday + -> false + | DayOfWeek.Friday -> false + | _ -> failwith "Invalid value" + + +if isWeekend DayOfWeek.Saturday <> true then exit 1 + +exit 0 + + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/NamedLiteral02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/NamedLiteral02.fs new file mode 100644 index 00000000000..beb5f434d00 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/NamedLiteral02.fs @@ -0,0 +1,58 @@ +// #Conformance #PatternMatching #ActivePatterns +#light + +// Verify [] values can be used with active patterns + +[] +let OneHundred = 100 + +let (|ToInt|) (input : string) = System.Int32.Parse(input) + +// Match the result of the active pattern against a literal value. +let test1() = + match " 101 " with + | ToInt OneHundred + -> // If it didn't match the literal, this would capture new + // value 'OneHundred' and this would fire. + exit 1 + | _ -> () + + match " 100 " with + | ToInt OneHundred + -> () + | _ -> exit 1 + + () + +// Run the test +test1() + + +// Verify literals (and norma values) can be specified as parameters +let (|ConcatedWith|) (x : string) (y : string) (input : string) = + input + x + y + +[] +let BarLiteral = "bar" + +[] +let BazLiteral = "baz" + +let test2() = + let barValue = "bar" + let bazValue = "baz" + + match "foo" with + | ConcatedWith barValue BazLiteral "foobarbaz" -> () + | ConcatedWith barValue BazLiteral result -> printfn "%s" result; exit 1 + + match "foo" with + | ConcatedWith BarLiteral bazValue "foobarbaz" -> () + | ConcatedWith barValue BazLiteral result -> printfn "%s" result; exit 1 + + () + +// Run the etest +test2() + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/ParamertizedPartialActivePattern01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/ParamertizedPartialActivePattern01.fs new file mode 100644 index 00000000000..896e6dbae8a --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/ParamertizedPartialActivePattern01.fs @@ -0,0 +1,33 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// Verify parameterized partial active patterns which return unit don't force you to +// bind the result. +// FSB 3502 + + +let (|DivisbleByTwo|_|) x = + if x % 2 = 0 + then Some() + else None + +let (|DivisibleByX|_|) x y = + if y % x = 0 + then Some() + else None + +// Without this fix, you'd have to bind the result of 'DivisibleByX' so you'd write DivisibleByX 3 (), which is lame. +let divisibleBy x = + match x with + | DivisbleByTwo & DivisibleByX 3 & DivisibleByX 4 -> [2; 3; 4] + | DivisbleByTwo & DivisibleByX 4 -> [2; 4] + | DivisbleByTwo & DivisibleByX 3 -> [2; 3; ] + + | DivisibleByX 3 & DivisibleByX 4 -> [3; 4] + | DivisibleByX 4 -> [ 4] + | DivisibleByX 3 -> [3; ] + + | _ -> [] + +if divisibleBy 12 <> [2; 3; 4] then exit 1 +if divisibleBy 16 <> [2; 4] then exit 2 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/PatternMatchRegressions01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/PatternMatchRegressions01.fs new file mode 100644 index 00000000000..2d82c4c91f4 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/PatternMatchRegressions01.fs @@ -0,0 +1,29 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +#light + +// FSB 1103, bad code generation for active patterns from fswebtools example + + +#nowarn "57" + +open System +open System.Collections.Generic +open System.Reflection + +open Microsoft.FSharp.Reflection +open Microsoft.FSharp.Quotations + +let (|MapDeclaringType|_|) (mi:#MemberInfo) : Option = failwith "" +let (|CastToMemberInfo|_|) (mi:#MemberInfo) : Option<_> = Some(mi :> MemberInfo) +let (|MethodCall|_|) (e:Expr) : Option = failwith "" +let (|CtorCall|_|) (e:Expr) : Option = failwith "" + +let f e = + match e with + | (MethodCall(MapDeclaringType(_), _)) + | (CtorCall(CastToMemberInfo(_), _)) -> + failwith "" + + +// Origional bug was problem with PEVerify +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/PatternMatchRegressions02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/PatternMatchRegressions02.fs new file mode 100644 index 00000000000..3209496222f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/PatternMatchRegressions02.fs @@ -0,0 +1,27 @@ +// #Regression #Conformance #PatternMatching #ActivePatterns +// FSHARP1.0:1104 +// Bug's title: *** WARNING: basic block at end of method ends without a leave, branch, return or throw. Adding throw +// Note: repro was updated with type annotation after fix for FSHARP1.0:5590 +#nowarn "57" + +open System +open System.Collections.Generic +open System.Reflection + +open Microsoft.FSharp.Reflection +open Microsoft.FSharp.Quotations + +let (|MapDeclaringType|_|) (mi:#MemberInfo) : Option = failwith "" +let (|CastToMemberInfo|) (mi:#MemberInfo) = (mi :> MemberInfo) +let (|MethodCall|_|) (e:Expr) : Option = failwith "" +let (|CtorCall|_|) (e:Expr) : Option = failwith "" + +let (|ClientExternalTypeUse|_|) (e:Expr) : option= + match e with + | (MethodCall(MapDeclaringType(_, CastToMemberInfo(_)), _)) + | (CtorCall(MapDeclaringType(_, CastToMemberInfo(_)), _)) -> + failwith "" + +// Original bug was problem with PEVerify + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/RecursiveActivePats.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/RecursiveActivePats.fs new file mode 100644 index 00000000000..ec87e23c68f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/RecursiveActivePats.fs @@ -0,0 +1,40 @@ +// #Conformance #PatternMatching #ActivePatterns +#light + +// Single Case +let rec (|SCAP|) (x : obj) = + match x with + | :? string as sx -> sx + "-TERM" + | x -> (|SCAP|) (x.ToString() + "-AP") + +if (|SCAP|) 5 <> "5-AP-TERM" then exit 1 +let _ = + match "foo" with + | SCAP "foo-TERM" -> () + | _ -> exit 1 + +// Multi-Case +let rec (|MCAP|MCAP2|) (ip : string) = + match ip with + | "..." -> MCAP(ip) + | "!!!" -> MCAP2(ip, ip) + | "test1" -> (|MCAP|MCAP2|) "..." + | "test2" -> (|MCAP|MCAP2|) "!!!" + | _ -> failwith "" + +let _ = match "test1" with MCAP "..." -> () | _ -> exit 1 +let _ = match "test2" with MCAP2 ("!!!", "!!!") -> () | _ -> exit 1 + +// Partial +let rec (|MultOf3|_|) x = + match x with + | _ when x < 0 -> None + | 0 -> Some() + | x -> (|MultOf3|_|) (x - 3) + +let _ = match 3 with MultOf3 -> () | _ -> exit 1 +let _ = match 4 with MultOf3 -> exit 1 | _ -> () +let _ = match 5 with MultOf3 -> exit 1 | _ -> () +let _ = match 6 with MultOf3 -> () | _ -> exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns01.fs new file mode 100644 index 00000000000..e68fa05ba1f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns01.fs @@ -0,0 +1,15 @@ +// #Conformance #PatternMatching #ActivePatterns +#light + +// Single case active pattern +let (|Double|) x = (x, x) + +let test x = match x with Double y -> y + +if test (1) <> (1,1) then exit 1 +if test (1,1) <> ((1,1), (1,1)) then exit 1 +if test ((1,1), (1,1)) <> (((1,1), (1,1)), ((1,1), (1,1))) then exit 1 + +exit 0 + + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns02.fs new file mode 100644 index 00000000000..dbc68717040 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns02.fs @@ -0,0 +1,13 @@ +// #Conformance #PatternMatching #ActivePatterns +#light + +// Multi-case active pattern + +let (|Even|Odd|) x = if x % 2 = 0 then Even else Odd + +let isEven x = match x with Even -> true | Odd -> false + +if isEven 1 <> false then exit 1 +if isEven 2 <> true then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns03.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns03.fs new file mode 100644 index 00000000000..45978a3c9c5 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns03.fs @@ -0,0 +1,18 @@ +// #Conformance #PatternMatching #ActivePatterns +#light + +// Single case partial active pattern + +let dayOfWeek = new System.Collections.Generic.List(["Sun"; "Mon"; "Tue"; "Wed"; "Thu"; "Fri"; "Sat"]) + +let (|DayOfWeek|_|) string = if dayOfWeek.IndexOf(string) <> -1 then Some() else None + +let isDayOfWeek x = + match x with + | DayOfWeek -> true + | _ -> false + +if isDayOfWeek("red") <> false then exit 1 +if isDayOfWeek("Fri") <> true then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns05.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns05.fs new file mode 100644 index 00000000000..57c698742b1 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns05.fs @@ -0,0 +1,16 @@ +// #Conformance #PatternMatching #ActivePatterns +#light + +open System + +let (|ExceptionMessageLen|) (ex : #Exception) = ex.Message.Length + +let mutable exnLength = 0 + +try + raise (NotImplementedException "1234567890") +with + ExceptionMessageLen len -> exnLength <- len + +if exnLength <> 10 then exit 1 +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns06.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns06.fs new file mode 100644 index 00000000000..70ec818da27 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns06.fs @@ -0,0 +1,3 @@ +// #Conformance #PatternMatching #ActivePatterns +#light + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns07.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns07.fs new file mode 100644 index 00000000000..1047c3e02c1 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns07.fs @@ -0,0 +1,48 @@ +// #Conformance #PatternMatching #ActivePatterns +#light + +// Verify parameters into active patterns can be anything (as constrained by the pat-param grammar production) +module OtherModule = + type Foo = A of int | B of int + let identifier = 42 + +module ActivePatternTests = + + // Null + let (|StrLen1|) (param : obj) (input : string) = input.Length + let test1 = match "foo" with StrLen1 null 3 -> true | _ -> false + + // Const + let (|StrLen2|) (param : string) (input : string) = input.Length + param.Length + let test2 = match "foo" with StrLen2 "bar" 6 -> true | _ -> false + + let (|StrLen3|) (param : int) (input : string) = input.Length + param + let test3 = match "foo" with StrLen3 7 10 -> true | _ -> false + + // Long-ident + let (|StrLen4|) (param : OtherModule.Foo) (input : string) = let OtherModule.A(value)|OtherModule.B(value) = param in input.Length + value + let test4 = match "foo" with StrLen4 (OtherModule.A(10)) 13 -> true | _ -> false + + // List type + let (|StringLen5|) param (input : string) = (List.length param) + input.Length + let test5 = match "foo" with StringLen5 [(1,1);(2,2)] 5 -> true | _ -> false + + // Tuple type + let (|StringLen6|) (ip1,ip2,ip3) (input : string) = input.Length + ip1 + ip2 + ip3 + let test6 = match "foo" with StringLen6 (1,2,3) 9 -> true | _ -> false + + // Type constraint + // Not valid code + //let (|StringLen7|) (param : obj) (input : string) = input.Length + param.ToString().Length + //let test7 = match "foo" with StringLen7 ("bar" :> obj) 6 -> true | _ -> false + + let (|StringLen8|) (param : 'a list) (input : string) = input.Length + List.length param + let test8 = match "foo" with StringLen8 ([] : int list) 3 -> true | _ -> false + + +// Actual test +open ActivePatternTests + +if not (test1 && test2 && test3 && test4 && test5 && test6 && (*test7 &&*) test8) then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns08.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns08.fs new file mode 100644 index 00000000000..6119dabb2da --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/activePatterns08.fs @@ -0,0 +1,40 @@ +// #Conformance #PatternMatching #ActivePatterns +#light + +// Verify able to mix active patterns with 'regular' patterns. + +let (|Odd|Even|) x = if x % 2 = 0 then Even else Odd +let (|MultipleOf2|_|) x = if x % 2 = 0 then Some () else None +let (|MultipleOfN|_|) (n:int) (x:int) = if x % n = 0 then Some () else None + +let test x = + match x with + | MultipleOfN 33 () -> 0 + | Odd & MultipleOfN 5 () -> 1 + | Odd & 3 -> 2 + | MultipleOfN 4 _ | MultipleOfN 8 _ | MultipleOfN 16 _ + -> 3 + | 46 -> 5 + | MultipleOf2 & Even -> 4 + | Odd -> 6 + | Even -> 7 + +if test 33 <> 0 then exit 1 + +if test 5 <> 1 then exit 1 +if test 15 <> 1 then exit 1 + +if test 3 <> 2 then exit 1 + +if test 4 <> 3 then exit 1 +if test 8 <> 3 then exit 1 +if test 16 <> 3 then exit 1 + +if test 262 <> 4 then exit 1 + +if test 46 <> 5 then exit 1 + +if test 101 <> 6 then exit 1 +if test 102 <> 4 then exit 1 // MulOf2 & Even dominates just Even, since it comes first + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/discUnion01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/discUnion01.fs new file mode 100644 index 00000000000..c1a896978cb --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/discUnion01.fs @@ -0,0 +1,27 @@ +// #Conformance #PatternMatching #ActivePatterns +#light + +// Verify ability to use wildcards when matching discriminated unions + +type Foo = + | A of int + | B of string * int + +let test x = + match x with + | A(1) | B(_,1) -> 1 + | A(2) | B(_,2) -> 2 + | B(_, _) -> -1 + | A(_) -> -2 + +if test (A(1)) <> 1 then exit 1 +if test (B("",1)) <> 1 then exit 1 + +if test (A(2)) <> 2 then exit 1 +if test (B("",2)) <> 2 then exit 1 + +if test (A(42)) <> -2 then exit 1 +if test (B("",42)) <> -1 then exit 1 + +exit 0 + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/discUnion02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/discUnion02.fs new file mode 100644 index 00000000000..424e7e8146f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/discUnion02.fs @@ -0,0 +1,24 @@ +// #Conformance #PatternMatching #ActivePatterns +#light + +// Verify ability to use a constant when matching discriminated unions + +type Foo = + | A of int + | B of string * int + +let test x = + match x with + | A(42) -> -42 + | A(x) -> x + | B("FSharp", _) -> "FSharp".Length * -1 + | B(str, _) -> str.Length + +if test (A(10)) <> 10 then exit 1 +if test (B("aaa",1)) <> 3 then exit 1 + +if test (A(42)) <> -42 then exit 1 +if test (B("FSharp",2)) <> -6 then exit 1 + +exit 0 + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Null/E_notNullCompatible01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Null/E_notNullCompatible01.fs new file mode 100644 index 00000000000..58b30660d1c --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Null/E_notNullCompatible01.fs @@ -0,0 +1,18 @@ +// #Regression #Conformance #PatternMatching +#light + +// Verify error when trying to match type against null if it doesn't support that +//The type 'Foo' does not have 'null' as a proper value + +type Foo() = + member this.Value = 42 + + + +let isNull2 (x : Foo) = + match x with + | null -> true + | _ -> false + + +exit 1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Null/Null.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Null/Null.fs new file mode 100644 index 00000000000..3faeae07f26 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Null/Null.fs @@ -0,0 +1,27 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Conformance.PatternMatching + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module Null = + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Null) + [] + let ``Null - E_notNullCompatible01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 43, Line 14, Col 7, Line 14, Col 11, "The type 'Foo' does not have 'null' as a proper value") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Null) + [] + let ``Null - matchNull01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Null/matchNull01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Null/matchNull01.fs new file mode 100644 index 00000000000..e1d6a986b97 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Null/matchNull01.fs @@ -0,0 +1,16 @@ +// #Conformance #PatternMatching +#light + +// Verify ability to match against null + +let isNull x = + match x with + | null -> true + | _ -> false + +if isNull ("abc" :> obj) <> false then exit 1 +if isNull (12345 :> obj) <> false then exit 1 + +if isNull null <> true then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/E_RecTypesNotMatch01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/E_RecTypesNotMatch01.fs new file mode 100644 index 00000000000..9297cb34285 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/E_RecTypesNotMatch01.fs @@ -0,0 +1,12 @@ +// #Regression #Conformance #PatternMatching #Records +// Verify error if two record types in a pattern match don't match +// Verify error if type of a record field is incorrect. +//The record type 'R1' does not contain a label 'A'\. + +type R1 = { X : int; Y : int } + +let testMatch x = + match x with + | { X = 0; Y = 0} -> true + | { A = 0; B = 0} -> true + | _ -> false diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/E_RecordFieldNotDefined01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/E_RecordFieldNotDefined01.fs new file mode 100644 index 00000000000..fa8ce23bce2 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/E_RecordFieldNotDefined01.fs @@ -0,0 +1,12 @@ +// #Regression #Conformance #PatternMatching #Records +#light + +// Verify error if type of a record field is incorrect. +//The record label 'X' is not defined + +let testMatch x = + match x with + | { X = 0; Y = 0} -> true + | _ -> false + +exit 1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/E_SyntaxError01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/E_SyntaxError01.fs new file mode 100644 index 00000000000..55931311be6 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/E_SyntaxError01.fs @@ -0,0 +1,12 @@ +// #Regression #Conformance #PatternMatching #Records +// Verify syntax error +//Unexpected symbol '}' in pattern\. Expected '\.', '=' or other token\.$ + +type RecordType = { Value : int } + +let test x = + match x with + | { Value} -> true + | _ -> false + +exit 1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/Record.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/Record.fs new file mode 100644 index 00000000000..a75f8910e5e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/Record.fs @@ -0,0 +1,83 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Conformance.PatternMatching + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module Record = + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Record) + [] + let ``Record - E_RecordFieldNotDefined01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 39, Line 9, Col 13, Line 9, Col 14, "The record label 'X' is not defined.") + (Error 39, Line 9, Col 20, Line 9, Col 21, "The record label 'Y' is not defined.") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Record) + [] + let ``Record - E_RecTypesNotMatch01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 1129, Line 11, Col 13, Line 11, Col 14, "The record type 'R1' does not contain a label 'A'.") + (Error 1129, Line 11, Col 20, Line 11, Col 21, "The record type 'R1' does not contain a label 'B'.") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Record) + [] + let ``Record - E_SyntaxError01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 10, Line 9, Col 14, Line 9, Col 15, "Unexpected symbol '}' in pattern. Expected '.', '=' or other token.") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Record) + [] + let ``Record - recordPatterns01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Record) + [] + let ``Record - recordPatterns02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Record) + [] + let ``Record - structRecordPatterns01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Record) + [] + let ``Record - structRecordPatterns02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/recordPatterns01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/recordPatterns01.fs new file mode 100644 index 00000000000..68e648f054f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/recordPatterns01.fs @@ -0,0 +1,32 @@ +// #Conformance #PatternMatching #Records +#light + +// Test ability to match records even if a subset of tags are specified. + +type Type = Plant | Animal | Mineral +type Thing = {Name : string; Age : int; Type : Type} + +// Single part +let isAnimal thing = + match thing with + | {Type=Animal} -> true + | _ -> false + +// Multi part +let isSteve thing = + match thing with + | {Name = "Steve"; Age = 2} -> true + | _ -> false + + +let animal = {Name = "Steve"; Age = 2; Type = Animal} +let plant = {Name = "Sunflower"; Age = 5; Type = Plant} +let rock = {Name = "Gold"; Age = 500000; Type = Mineral} + +if isAnimal animal <> true then exit 1 +if isAnimal rock <> false then exit 1 + +if isSteve animal <> true then exit 1 +if isSteve plant <> false then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/recordPatterns02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/recordPatterns02.fs new file mode 100644 index 00000000000..e73937878bf --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/recordPatterns02.fs @@ -0,0 +1,39 @@ +// #Conformance #PatternMatching #Records +#light + +// Verify ability to have nested patterns in record types + +type Type = Plant | Animal | Mineral +type Thing = {Name : string; Age : int; Type : Type} + +let isYoung thing = + match thing with + | {Age = x; Type = (Plant|Animal|Mineral)} when x < 10 -> true + | _ -> false + +let isMatch thing (thingName : string option) (thingAge : int option) = + // We can't extract the option value in a match and use it in the same statement, + // so we first break open the optional values. + let name = match thingName with Some(name) -> name | None -> "" + let age = match thingAge with Some(age) -> age | None -> 0 + // Finally match it all + match thingName, thingAge, thing with + | None, None, _ -> false + | Some(_), None, {Name=itsName} when itsName = name -> true + | None, Some(_), {Age=itsAge} when itsAge = age -> true + | Some(_), Some(_), {Name=name; Age=age} -> true + | _ -> false + +let animal = {Name = "Steve"; Age = 2; Type = Animal} +let plant = {Name = "Sunflower"; Age = 5; Type = Plant} +let rock = {Name = "Gold"; Age = 500000; Type = Mineral} + +if isYoung animal <> true then exit 1 +if isYoung rock <> false then exit 1 + +if isMatch animal (Some("Steve")) (Some(2)) <> true then exit 1 +if isMatch animal (Some("Steve")) None <> true then exit 1 + +if isMatch animal (Some("NotSteve")) None <> false then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/structRecordPatterns01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/structRecordPatterns01.fs new file mode 100644 index 00000000000..007aac6c23a --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/structRecordPatterns01.fs @@ -0,0 +1,32 @@ +// #Conformance #PatternMatching #Records +#light + +// Test ability to match records even if a subset of tags are specified. + +type Type = Plant | Animal | Mineral +[] type Thing = {Name : string; Age : int; Type : Type} + +// Single part +let isAnimal thing = + match thing with + | {Type=Animal} -> true + | _ -> false + +// Multi part +let isSteve thing = + match thing with + | {Name = "Steve"; Age = 2} -> true + | _ -> false + + +let animal = {Name = "Steve"; Age = 2; Type = Animal} +let plant = {Name = "Sunflower"; Age = 5; Type = Plant} +let rock = {Name = "Gold"; Age = 500000; Type = Mineral} + +if isAnimal animal <> true then exit 1 +if isAnimal rock <> false then exit 1 + +if isSteve animal <> true then exit 1 +if isSteve plant <> false then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/structRecordPatterns02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/structRecordPatterns02.fs new file mode 100644 index 00000000000..0d34aaadc7f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Record/structRecordPatterns02.fs @@ -0,0 +1,39 @@ +// #Conformance #PatternMatching #Records +#light + +// Verify ability to have nested patterns in record types + +type Type = Plant | Animal | Mineral +[] type Thing = {Name : string; Age : int; Type : Type} + +let isYoung thing = + match thing with + | {Age = x; Type = (Plant|Animal|Mineral)} when x < 10 -> true + | _ -> false + +let isMatch thing (thingName : string option) (thingAge : int option) = + // We can't extract the option value in a match and use it in the same statement, + // so we first break open the optional values. + let name = match thingName with Some(name) -> name | None -> "" + let age = match thingAge with Some(age) -> age | None -> 0 + // Finally match it all + match thingName, thingAge, thing with + | None, None, _ -> false + | Some(_), None, {Name=itsName} when itsName = name -> true + | None, Some(_), {Age=itsAge} when itsAge = age -> true + | Some(_), Some(_), {Name=name; Age=age} -> true + | _ -> false + +let animal = {Name = "Steve"; Age = 2; Type = Animal} +let plant = {Name = "Sunflower"; Age = 5; Type = Plant} +let rock = {Name = "Gold"; Age = 500000; Type = Mineral} + +if isYoung animal <> true then exit 1 +if isYoung rock <> false then exit 1 + +if isMatch animal (Some("Steve")) (Some(2)) <> true then exit 1 +if isMatch animal (Some("Steve")) None <> true then exit 1 + +if isMatch animal (Some("NotSteve")) None <> false then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple.fs deleted file mode 100644 index 810fb2cc85b..00000000000 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple.fs +++ /dev/null @@ -1,129 +0,0 @@ -// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. - -namespace Conformance.PatternMatching - -open Xunit -open FSharp.Test -open FSharp.Test.Compiler - -module Simple = - - // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) - //Incomplete pattern matches on this expression. For example, the value 'Result \(_\)' may indicate a case not covered by the pattern\(s\) - [] - let ``Simple - W_Incomplete01_fs - --test:ErrorRanges`` compilation = - compilation - |> asFs - |> withOptions ["--test:ErrorRanges"] - |> typecheck - |> shouldFail - |> withWarningCode 0025 - |> withDiagnosticMessageMatches "Incomplete pattern matches on this expression. For example, the value 'Result \(_\)' may indicate a case not covered by the pattern\(s\)" - |> ignore - - // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) - //This rule will never be matched - [] - let ``Simple - W_Incomplete02_fs - --test:ErrorRanges`` compilation = - compilation - |> asFsx - |> withOptions ["--test:ErrorRanges"] - |> compile - |> shouldFail - |> withWarningCode 0026 - |> withDiagnosticMessageMatches "This rule will never be matched" - |> ignore - - // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) - //Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name - [] - let ``Simple - W_BindCaptialIdent_fs - --test:ErrorRanges`` compilation = - compilation - |> asFsx - |> withOptions ["--test:ErrorRanges"] - |> compile - |> shouldFail - |> withWarningCode 0049 - |> withDiagnosticMessageMatches "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name" - |> ignore - - [] - let ``As patterns``() = - Fsx """ - let (|Id|) = id - let a = [1..4] - match a with - | 1 | 1 as b::(Id 2 as c as c2)::[d as 3; Id e & Id _ as Id 4] as Id f when b = 1 && c = 2 && c2 = 2 && d = 3 && e = 4 && a = f -> () - | _ -> failwith "Match failed" - """ - |> asExe - |> withLangVersion60 - |> compileExeAndRun - |> shouldSucceed - - - [] - [] - [] - [] - [] - [] - let ``Test type matching for subtypes and interfaces`` typ value = - Fsx $""" -open System -let classify (o: obj) = - match o with - | :? {typ} as d when d = Unchecked.defaultof<_> -> "default" - | :? IFormattable -> "formattable" - | _ -> "not a {typ}" - -let res = classify {value} -if res <> "formattable" then - failwith $"Unexpected result: {{res}}" - """ - |> asExe - |> compileAndRun - |> shouldSucceed - - - [] - let ``Enum incompleteness check should not hide an issue with outer DU pattern matching with nowarn:104 `` () = - Fsx """ -type E = A = 0 - -type Ex = - | ExA of int * E - | ExB of int - -let flub ex = - match ex with - | ExA(_, E.A) -> () - -flub (ExB 3) - """ - |> withNoWarn 104 - |> typecheck - |> shouldFail - |> withDiagnostics [Warning 25, Line 9, Col 11, Line 9, Col 13, "Incomplete pattern matches on this expression. For example, the value 'ExB (_)' may indicate a case not covered by the pattern(s)."] - - [] - let ``Enum incompleteness check in nested scenarios should report all warnings`` () = - Fsx """ -type E = - | FieldA = 1 - | FieldB = 2 - -type U = - | CaseA - | CaseB of E - -match CaseA with -| CaseB E.FieldA -> () -| CaseB E.FieldB -> () - """ - |> typecheck - |> shouldFail - |> withDiagnostics [ - Warning 104, Line 10, Col 7, Line 10, Col 12, "Enums may take values outside known cases. For example, the value 'CaseB (enum (0))' may indicate a case not covered by the pattern(s)." - Warning 25, Line 10, Col 7, Line 10, Col 12, "Incomplete pattern matches on this expression. For example, the value 'CaseA' may indicate a case not covered by the pattern(s)."] - \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/CodeGenReg01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/CodeGenReg01.fs new file mode 100644 index 00000000000..cd9e19888df --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/CodeGenReg01.fs @@ -0,0 +1,49 @@ +// #Regression #Conformance #PatternMatching +#light + +// FSB 1750, Bad codegen in Pattern Matching + +let f p x = + match + match x with + | 1 when try p x finally () + -> 0 + | _ -> 1 + with + | 1 -> 0 + | _ -> 1 + +let rec loop x = if x = 0 then 1 else loop (x - 1) + +let g p x = + let test = + match x with + | 1 when (try p x finally ()) -> 3 + | _ -> 5 + loop test + +let h p x = + let test = + match x with + | 1 when (for x = 1 to 100 do printf "" done; true) -> 3 + | _ -> 5 + loop test + +let (|E|O|) x = if x % 2 = 0 then E else O + +let i p x = + let test = + match x with + | E when match x with + | E -> true + | O -> false + -> 3 + | O when match x with + | E -> false + | O -> true + -> 3 + | _ -> 5 + loop test + +// This test should just compile and PEVerify +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/E_SyntaxError01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/E_SyntaxError01.fs new file mode 100644 index 00000000000..b3b2c41d32d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/E_SyntaxError01.fs @@ -0,0 +1,11 @@ +// #Regression #Conformance #PatternMatching +#light + +//Unexpected symbol'\[' in pattern matching. Expected '->' or other token + +let isIntArray (o: obj) = + match o with + | :? int[] -> true + | _ -> false + +exit 1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/E_ValueCapture01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/E_ValueCapture01.fs new file mode 100644 index 00000000000..eb1cc0594dd --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/E_ValueCapture01.fs @@ -0,0 +1,17 @@ +// #Regression #Conformance #PatternMatching +#light + +//The value or constructor 'ident1' is not defined +//The value or constructor 'ident2' is not defined + +// Verifing scoping of value captures +let test1() = + let x = 1 + let _ = + match x with + | ident1 as ident2 -> () + + if ident1 <> 1 then failwith "ident1 shouldn't be in scope!" + if ident2 <> 2 then failwith "ident2 shouldn't be in scope!" + +exit 1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/E_constPattern01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/E_constPattern01.fs new file mode 100644 index 00000000000..64ca9c6eaa5 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/E_constPattern01.fs @@ -0,0 +1,16 @@ +// #Regression #Conformance #PatternMatching +#light + +//FS0025: Incomplete pattern matches on this expression. The value '7' will not be matched + +open System + +let isWeekend day = + match day with + | DayOfWeek.Monday | DayOfWeek.Tuesday | DayOfWeek.Wednesday + | DayOfWeek.Thursday | DayOfWeek.Friday + -> false + | DayOfWeek.Saturday | DayOfWeek.Sunday + -> true + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/E_namedLiberal01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/E_namedLiberal01.fs new file mode 100644 index 00000000000..2f3ba740856 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/E_namedLiberal01.fs @@ -0,0 +1,23 @@ +// #Regression #Conformance #PatternMatching +// Match warning when covering all defined values of an enum + +//Enums may take values outside known cases. + + +open System + +let isWeekend day = + match day with + | DayOfWeek.Sunday | DayOfWeek.Saturday + -> true + | DayOfWeek.Monday | DayOfWeek.Tuesday + | DayOfWeek.Wednesday | DayOfWeek.Thursday + | DayOfWeek.Friday + -> false + + +if isWeekend DayOfWeek.Saturday <> true then exit 1 + +exit 0 + + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/MatchFailureExn01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/MatchFailureExn01.fs new file mode 100644 index 00000000000..808d04f5fc6 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/MatchFailureExn01.fs @@ -0,0 +1,26 @@ +// #Conformance #PatternMatching +#light + +// Verify a match failure exception is thrown if a match is not found. + +let VerifyThrows f x = + let result = + try + let _ = f x + false + with + | :? MatchFailureException -> true + | _ -> false + + if result = true + then () + else exit 1 + +// Test 1 +let test1 = (fun () -> let 1 = 2 in let x = 1 in x) +VerifyThrows test1 () + +// Test 2 +VerifyThrows (function x when x <> 0 -> true) 0 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs new file mode 100644 index 00000000000..8200b019881 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs @@ -0,0 +1,380 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Conformance.PatternMatching + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module Simple = + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + //Incomplete pattern matches on this expression. For example, the value 'Result \(_\)' may indicate a case not covered by the pattern\(s\) + [] + let ``Simple - W_Incomplete01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withWarningCode 0025 + |> withDiagnosticMessageMatches "Incomplete pattern matches on this expression. For example, the value 'Result \(_\)' may indicate a case not covered by the pattern\(s\)" + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + //This rule will never be matched + [] + let ``Simple - W_Incomplete02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldFail + |> withWarningCode 0026 + |> withDiagnosticMessageMatches "This rule will never be matched" + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + //Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name + [] + let ``Simple - W_BindCaptialIdent_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldFail + |> withWarningCode 0049 + |> withDiagnosticMessageMatches "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name" + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - CodeGenReg01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - E_constPattern01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldFail + |> withSingleDiagnostic (Warning 104, Line 9, Col 11, Line 9, Col 14, "Enums may take values outside known cases. For example, the value 'enum (7)' may indicate a case not covered by the pattern(s).") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - E_namedLiberal01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldFail + |> withSingleDiagnostic (Warning 104, Line 10, Col 11, Line 10, Col 14, "Enums may take values outside known cases. For example, the value 'enum (7)' may indicate a case not covered by the pattern(s).") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - E_SyntaxError01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldFail + |> withSingleDiagnostic (Error 10, Line 8, Col 14, Line 8, Col 15, "Unexpected symbol'[' in pattern matching. Expected '->' or other token.") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - E_ValueCapture01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldFail + |> withDiagnostics [ + (Error 39, Line 14, Col 8, Line 14, Col 14, "The value or constructor 'ident1' is not defined. Maybe you want one of the following: + int8 + int"); + (Error 39, Line 15, Col 8, Line 15, Col 14, "The value or constructor 'ident2' is not defined. Maybe you want one of the following: + int8 + int") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - MatchFailureExn01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldFail + |> withDiagnostics [ + (Warning 25, Line 20, Col 28, Line 20, Col 29, "Incomplete pattern matches on this expression. For example, the value '0' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 24, Col 15, Line 24, Col 23, "Incomplete pattern matches on this expression.") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns03_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns04_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns05_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns06_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns07_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns08_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns09_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns10_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns11_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldFail + |> withSingleDiagnostic (Warning 26, Line 10, Col 7, Line 10, Col 13, "This rule will never be matched") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns12_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns13_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns14_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns15_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges"] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns16_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges";] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) + [] + let ``Simple - simplePatterns17_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges";] + |> compile + |> shouldFail + |> withSingleDiagnostic (Warning 25, Line 16, Col 13, Line 16, Col 17, "Incomplete pattern matches on this expression. For example, the value '``some-non-null-value``' may indicate a case not covered by the pattern(s).") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/AsPatterns) + [] + let ``Simple - simplePatterns18_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges";] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/AsPatterns) + [] + let ``Simple - simplePatterns19_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges";] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/AsPatterns) + [] + let ``Simple - simplePatterns20_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges";] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/AsPatterns) + [] + let ``Simple - ValueCapture01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges";] + |> compile + |> shouldSucceed + |> ignore + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/AsPatterns) + [] + let ``Simple - ValueCapture02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFsx + |> withOptions ["--test:ErrorRanges";] + |> compile + |> shouldSucceed + |> ignore + + [] + let ``Enum incompleteness check should not hide an issue with outer DU pattern matching with nowarn:104 `` () = + Fsx """ +type E = A = 0 + +type Ex = + | ExA of int * E + | ExB of int + +let flub ex = + match ex with + | ExA(_, E.A) -> () + +flub (ExB 3) + """ + |> withNoWarn 104 + |> typecheck + |> shouldFail + |> withDiagnostics [Warning 25, Line 9, Col 11, Line 9, Col 13, "Incomplete pattern matches on this expression. For example, the value 'ExB (_)' may indicate a case not covered by the pattern(s)."] + + [] + let ``Enum incompleteness check in nested scenarios should report all warnings`` () = + Fsx """ +type E = + | FieldA = 1 + | FieldB = 2 + +type U = + | CaseA + | CaseB of E + +match CaseA with +| CaseB E.FieldA -> () +| CaseB E.FieldB -> () + """ + |> typecheck + |> shouldFail + |> withDiagnostics [ + Warning 104, Line 10, Col 7, Line 10, Col 12, "Enums may take values outside known cases. For example, the value 'CaseB (enum (0))' may indicate a case not covered by the pattern(s)." + Warning 25, Line 10, Col 7, Line 10, Col 12, "Incomplete pattern matches on this expression. For example, the value 'CaseA' may indicate a case not covered by the pattern(s)."] + \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/ValueCapture01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/ValueCapture01.fs new file mode 100644 index 00000000000..a7f55dd8899 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/ValueCapture01.fs @@ -0,0 +1,19 @@ +// #Conformance #PatternMatching +#light + +// Test some of the semantics of value capture + +// Note that pattern matching doesn't execute all pats in order, rather +// it builds a tree, so when it chooses '0' over '1', it won't reconsider +// '1'. + +let test1() = + let mutable i = 0 + match i with + | 0 when (i <- 1; false) -> 0 + | 1 -> 1 + | _ -> -i + +if test1() <> -1 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/ValueCapture02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/ValueCapture02.fs new file mode 100644 index 00000000000..2d6927b4611 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/ValueCapture02.fs @@ -0,0 +1,35 @@ +// #Conformance #PatternMatching +#light + +open System.Collections.Generic + +// Captured values for refence types +let test1() = + // Need to use List since F# overrides + // reference semantics for most other types + let x = new List() + x.Add(1) + x.RemoveAt(0) + if x.Count <> 0 then exit 1 + + match x with + | _ as newBoundValue + -> if newBoundValue <> x then exit 1 + if not <| newBoundValue.Equals(x) then exit 1 + () + +// Captured values for value types +let test2() = + let mutable i = 0 + match i with + | _ as newBoundValue -> if i <> newBoundValue then exit 1 + i <- 1 + if i = newBoundValue then exit 1 + () + + + +test1() +test2() + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/PatternMatching/Simple/W_BindCaptialIdent.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/W_BindCaptialIdent.fs similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/PatternMatching/Simple/W_BindCaptialIdent.fs rename to tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/W_BindCaptialIdent.fs diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/PatternMatching/Simple/W_Incomplete01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/W_Incomplete01.fs similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/PatternMatching/Simple/W_Incomplete01.fs rename to tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/W_Incomplete01.fs diff --git a/tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/PatternMatching/Simple/W_Incomplete02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/W_Incomplete02.fs similarity index 100% rename from tests/FSharp.Compiler.ComponentTests/resources/tests/Conformance/PatternMatching/Simple/W_Incomplete02.fs rename to tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/W_Incomplete02.fs diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns01.fs new file mode 100644 index 00000000000..72b063c7b41 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns01.fs @@ -0,0 +1,15 @@ +// #Conformance #PatternMatching +#light + +// Test guarded patterns +let success = + let x = 42 + match x with + | x when x < 40 -> exit 1 + | _ when x > 42 -> exit 1 + | x when x = 42 -> true + | _ -> exit 1 + +if success then exit 0 +exit 1 + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns02.fs new file mode 100644 index 00000000000..ef72f1c539d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns02.fs @@ -0,0 +1,13 @@ +// #Conformance #PatternMatching +#light + +// Test constant pattern matches +let x = 42 +let _ = + match x with + | 41 -> exit 1 + | 43 -> exit 1 + | 42 -> exit 0 + | _ -> exit 1 + +exit 1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns03.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns03.fs new file mode 100644 index 00000000000..7490e2247b9 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns03.fs @@ -0,0 +1,22 @@ +// #Conformance #PatternMatching +#light + +// Match pattern with 'named pattern' +type Foo() = + static member StaticProperty = 42 + +let testNamedPattern x = + match x with + | x as someNewIdentifier when x = 42 + -> if (someNewIdentifier <> x) || (someNewIdentifier <> 42) then + false + else + true + | _ as someNewIdentifier when someNewIdentifier = 0 -> true + | _ -> false + +if testNamedPattern 42 <> true then exit 1 +if testNamedPattern 0 <> true then exit 1 +if testNamedPattern (-1) <> false then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns04.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns04.fs new file mode 100644 index 00000000000..284b8160f70 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns04.fs @@ -0,0 +1,14 @@ +// #Conformance #PatternMatching +#light + +// Test guarded patterns +let success = + let x = -1 + match x with + | even when x % 2 = 0 && x > 0 -> exit 1 + | odd when x % 2= 1 && x > 0 -> exit 1 + | lessThanZero -> true + +if success then exit 0 +exit 1 + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns05.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns05.fs new file mode 100644 index 00000000000..8b86c15d7c0 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns05.fs @@ -0,0 +1,28 @@ +// #Conformance #PatternMatching +#light + +type Alphabet = + | A | B | C | D | E + | F | G | H | I | J + | K | L | M | N | O + | P | Q | R | S | T + | U | V | W | X | Y + | Z + +let isVowel letter = + match letter with + | A | E | I + | O | U + -> true + | Y -> true // Only sometimes + | _ -> false + +if isVowel A <> true then exit 1 +if isVowel E <> true then exit 1 +if isVowel I <> true then exit 1 +if isVowel O <> true then exit 1 +if isVowel U <> true then exit 1 +if isVowel Y <> true then exit 1 +if isVowel C <> false then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns06.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns06.fs new file mode 100644 index 00000000000..aede484e41c --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns06.fs @@ -0,0 +1,26 @@ +// #Conformance #PatternMatching +#light + +let (|MulTwo|_|) x = if x % 2 = 0 then Some() else None +let (|MulThree|_|) x = if x % 3 = 0 then Some() else None +let (|MulFour|_|) x = if x % 4 = 0 then Some() else None + +let mulOf234 x = + match x with + | MulTwo & MulThree & MulFour -> (true, true, true) + | MulTwo & MulThree -> (true, true, false) + | MulThree & MulFour -> (false, true, true) + | MulTwo & MulFour -> (true, false, true) + | MulTwo -> (true, false, false) + | MulThree -> (false, true, false) + | MulFour -> (false, false, true) + | _ -> (false,false,false) + + +for i = 1 to 100 do + let m2,m3,m4 = mulOf234 i + if m2 <> (i % 2 = 0) then exit 1 + if m3 <> (i % 3 = 0) then exit 1 + if m4 <> (i % 4 = 0) then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns07.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns07.fs new file mode 100644 index 00000000000..b4d4d3646f7 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns07.fs @@ -0,0 +1,20 @@ +// #Conformance #PatternMatching +#light + +// Contains sequence [6; 20; 82] +let rec containsSeq list = + match list with + // Base cases + | [] -> false + | _ :: [] -> false + | _ :: _ :: [] -> false + // Check + | 6 :: 20 :: 82 :: tl -> true + // Recurse + | _ :: tail -> containsSeq tail + +if containsSeq [1 .. 100] = true then exit 1 +if containsSeq [1; 2; 3; 6; 20; 82; 1; 1] = false then exit 1 + +exit 0 + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns08.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns08.fs new file mode 100644 index 00000000000..8a37dc96877 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns08.fs @@ -0,0 +1,17 @@ +// #Conformance #PatternMatching +#light + +let rec listLength list = + match list with + | [] -> 0 + | [_] -> 1 + | [_; _] -> 2 + | [_; _; _] -> 3 + | hd :: tl -> 1 + listLength tl + +if listLength [] <> 0 then exit 1 +if listLength [1] <> 1 then exit 1 +if listLength [1..2] <> 2 then exit 1 +if listLength [1..5] <> 5 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns09.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns09.fs new file mode 100644 index 00000000000..24ee7926832 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns09.fs @@ -0,0 +1,19 @@ +// #Conformance #PatternMatching +#light + +let sumArray array = + match array with + | [| |] -> 0 + | [|x|] -> x + | [|x; y|] -> x + y + | [|x; y; z|] -> x + y + z + | [|w; x; y; z|] -> w + x + y + z + | _ -> failwith "too large" + +if sumArray [| |] <> 0 then exit 1 +if sumArray [|1|] <> 1 then exit 1 +if sumArray [|1;2|] <> 3 then exit 1 +if sumArray [|1;2;3|] <> 6 then exit 1 +if sumArray [|1;2;3;4|] <> 10 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns10.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns10.fs new file mode 100644 index 00000000000..9fd840d2d32 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns10.fs @@ -0,0 +1,18 @@ +// #Conformance #PatternMatching +#light + +let f x y = + match x, y with + | (0), (0) -> false + | (1), (0) -> true + | _, _ -> false + +let r1 = f 0 0 +let r2 = f 1 0 +let r3 = f 0 1 + +if r1 <> false then exit 1 +if r2 <> true then exit 1 +if r3 <> false then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns11.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns11.fs new file mode 100644 index 00000000000..503cb88b8e3 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns11.fs @@ -0,0 +1,15 @@ +// #Conformance #PatternMatching +#light + +let sumEvenValues (tupel:int*int) = + match tupel with + | x, y when x % 2 = 0 && y % 2 = 0 -> x + y + | x, _ when x % 2 = 0 -> x + | _, y when y % 2 = 0 -> y + | _, _ -> 0 + | _ -> 0 + +if sumEvenValues (2, 2) <> 4 then exit 1 +if sumEvenValues (1, 5) <> 0 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns12.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns12.fs new file mode 100644 index 00000000000..7e79990292b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns12.fs @@ -0,0 +1,21 @@ +// #Conformance #PatternMatching +#light + +type Person = { Name : string; Age : int } + +type Classification = + | Child + | Adult + | Senior + +let getClass person = + match person with + | { Name = _; Age = age} when age < 12 -> Child + | { Name = _; Age = age} when age > 55 -> Senior + | { Name=_; Age=_} -> Adult + +if getClass {Name="Uncle Simpson"; Age=70} <> Senior then exit 1 +if getClass {Name="Homer"; Age=40} <> Adult then exit 1 +if getClass {Name="Lisa"; Age=11} <> Child then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns13.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns13.fs new file mode 100644 index 00000000000..1bfad47a21f --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns13.fs @@ -0,0 +1,20 @@ +// #Conformance #PatternMatching +#light + +module SomeModule = + type DU = + | A of int + | B of string + | C + +module MainModule = + let getCount thingey = + match thingey with + | SomeModule.DU.A x -> x + | SomeModule.DU.B x -> x.Length + | SomeModule.DU.C -> 0 + + if getCount (SomeModule.DU.A(42)) <> 42 then exit 1 + if getCount (SomeModule.DU.B("cat")) <> 3 then exit 1 + + exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns14.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns14.fs new file mode 100644 index 00000000000..355afa9c673 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns14.fs @@ -0,0 +1,10 @@ +// #Conformance #PatternMatching +#light + +let result = + match 42 with + | _ -> true + +if result <> true then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns15.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns15.fs new file mode 100644 index 00000000000..c30590dc0e8 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns15.fs @@ -0,0 +1,18 @@ +// #Conformance #PatternMatching +#light + +open System + +let abbreviate (ex:#obj) = + match box ex with + | :? NotImplementedException -> "nyi" + | :? ArgumentException -> "ae" + | :? Exception -> "e" + | _ -> "" + +if abbreviate (new NotImplementedException "") <> "nyi" then exit 1 +if abbreviate (new ArgumentException "") <> "ae" then exit 1 +if abbreviate (new Exception "") <> "e" then exit 1 +if abbreviate ("foo") <> "" then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns16.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns16.fs new file mode 100644 index 00000000000..a6c308b4a20 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns16.fs @@ -0,0 +1,27 @@ +// #Conformance #PatternMatching +#light + +open System + +let abbreviate (ex:#obj) = + match box ex with + | :? NotImplementedException as e + -> if e.GetType() <> typeof then + exit 1 + "nyi" + | :? ArgumentException as e + -> if e.GetType() <> typeof then + exit 1 + "ae" + | :? Exception as e + -> if e.GetType() <> typeof then + exit 1 + "e" + | _ -> "" + +if abbreviate (new NotImplementedException "") <> "nyi" then exit 1 +if abbreviate (new ArgumentException "") <> "ae" then exit 1 +if abbreviate (new Exception "") <> "e" then exit 1 +if abbreviate ("foo") <> "" then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns17.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns17.fs new file mode 100644 index 00000000000..e35cc2e1e9e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns17.fs @@ -0,0 +1,19 @@ +// #Conformance #PatternMatching +#light + +open System + +let nullValue = Type.GetType("this type does not exist") +let result = + match nullValue with + | null -> true + | _ -> false + +if nullValue <> null then exit 1 +if null <> nullValue then exit 1 // This actually is a pattern match +if result <> true then exit 1 + +let f = fun null -> true +if f nullValue <> true then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns18.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns18.fs new file mode 100644 index 00000000000..49f5a099c9e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns18.fs @@ -0,0 +1,30 @@ +// #Conformance #PatternMatching +#light + +// Pattern match a short unicode literal + +type Suit = + | Spade + | Club + | Heart + | Diamond + +let spade, club, heart, diamond = '\u2660', '\u2663', '\u2665', '\u2666' + +let getSuit c = + match c with + | '\u2660' -> Some(Spade) + | '\u2663' -> Some(Club) + | '\u2665' -> Some(Heart) + | '\u2666' -> Some(Diamond) + | _ -> None + +if getSuit 'a' <> None then exit 1 +if getSuit 'z' <> None then exit 1 + +if getSuit spade <> Some(Spade) then exit 1 +if getSuit club <> Some(Club) then exit 1 +if getSuit heart <> Some(Heart) then exit 1 +if getSuit diamond <> Some(Diamond) then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns19.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns19.fs new file mode 100644 index 00000000000..fcc0f9e5f69 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns19.fs @@ -0,0 +1,26 @@ +// #Conformance #PatternMatching +#light + +// Pattern match long unicode literals + +[] +let UnicodeString1 = "\U00000000\U0002FFFF" + +[] +let UnicodeString2 = "\U00101111\U000F2222" + +let testStr x = + match x with + | UnicodeString1 -> 1 + | UnicodeString2 -> 2 + | _ -> 0 + +if testStr "foo" <> 0 then exit 1 + +if testStr UnicodeString1 <> 1 then exit 1 +if testStr "\U00000000\U0002FFFF" <> 1 then exit 1 + +if testStr UnicodeString2 <> 2 then exit 1 +if testStr "\U00101111\U000F2222" <> 2 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns20.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns20.fs new file mode 100644 index 00000000000..9295135f6c8 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/simplePatterns20.fs @@ -0,0 +1,26 @@ +// #Conformance #PatternMatching +#light + +// Pattern match short unicode literals in strings + +[] +let UnicodeString1 = "\u0000\uFFFF" + +[] +let UnicodeString2 = "\u1111\u2222" + +let testStr x = + match x with + | UnicodeString1 -> 1 + | UnicodeString2 -> 2 + | _ -> 0 + +if testStr "foo" <> 0 then exit 1 + +if testStr UnicodeString1 <> 1 then exit 1 +if testStr "\u0000\uFFFF" <> 1 then exit 1 + +if testStr UnicodeString2 <> 2 then exit 1 +if testStr "\u1111\u2222" <> 2 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/DiffAssembly.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/DiffAssembly.fs new file mode 100644 index 00000000000..ebc545abc33 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/DiffAssembly.fs @@ -0,0 +1,16 @@ +// #Conformance #PatternMatching #Constants +#light + + + +// Verify pattern matching against constants defined in a different assembly. + +let testMatch x = + match x with + | System.Math.PI -> 1 + | _ -> 2 + +if testMatch System.Math.PI <> 1 then exit 1 +if testMatch 0.0 <> 2 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/E_NoRangeConst01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/E_NoRangeConst01.fs new file mode 100644 index 00000000000..b88f36e32b9 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/E_NoRangeConst01.fs @@ -0,0 +1,25 @@ +// #Regression #Conformance #PatternMatching #Constants +#light + +// Verify error when trying to use range constants +//Unexpected symbol '..' in pattern matching. Expected '->' or other token + +let areKnownLists l = + match l with + | 1 .. 2 .. 10 -> "odds" + | 2 .. 2 .. 10 -> "evens" + | 1 .. 10 -> "all" + | _ -> "?" + + +if areKnownLists [2; 4; 6; 8; 10] <> "evens" then exit 1 + +let odds = 1 :: 3 :: 5 :: 7 :: 9 :: [] +if areKnownLists odds <> "odds" then exit 1 + +let all = [10 .. -1 .. 1] |> List.rev +if areKnownLists all <> "all" then exit 1 + +if areKnownLists [] <> "?" then exit 1 + +exit 1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/E_type_bigint.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/E_type_bigint.fs new file mode 100644 index 00000000000..da3a23ef76b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/E_type_bigint.fs @@ -0,0 +1,13 @@ +// #Regression #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: BigInt +//Non-primitive numeric literal constants.+ +#light + +let isZero x = + match x with + | 0I -> true + | 99I -> false + | _ -> false + +exit (if isZero 0I then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/E_type_bignum40.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/E_type_bignum40.fs new file mode 100644 index 00000000000..430712651ab --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/E_type_bignum40.fs @@ -0,0 +1,14 @@ +// #Regression #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: BigNum +//Non-primitive numeric literal constants.+ +// On NetFx4.0/Dev10, we don't give the deprecation error: this is ok (FSHARP1.0:4599) +#light + +let isZero x = + match x with + | 99999N -> false + | 0N -> true + | _ -> false + +exit (if isZero 0N then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/FullyQualify01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/FullyQualify01.fs new file mode 100644 index 00000000000..7759c8cfa21 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/FullyQualify01.fs @@ -0,0 +1,33 @@ +// #Conformance #PatternMatching #Constants +#light + +// Verify ability to pattern match against a fully qualified constant or literal + +module Test = + + module A = + module B = + module C = + module D = + type DU = + | A of int + | B of string + | C + + [] + let literalValue = "AString" + + + let test x = + match x with + | A.B.C.D.A(x) -> 1 + | A.B.C.D.B(x) when x = A.B.C.D.literalValue -> 2 + | A.B.C.D.B(x) -> 3 + | _ -> 0 + + + if test (A.B.C.D.A(5)) <> 1 then exit 1 + if test (A.B.C.D.B(A.B.C.D.literalValue)) <> 2 then exit 1 + if test (A.B.C.D.C) <> 0 then exit 1 + + exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/MatchLiteral01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/MatchLiteral01.fs new file mode 100644 index 00000000000..a3aaa24faf6 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/MatchLiteral01.fs @@ -0,0 +1,30 @@ +// #Regression #Conformance #PatternMatching #Constants +#light + +// Test ability to match a const literal value +//This rule will never be matched +//This rule will never be matched +//This rule will never be matched + +[] +let intLiteral = 42 + +if (match 42 with + | intLiteral -> true + | _ -> false) <> true then exit 1 + +[] +let strLiteral = "foobaz" + +if (match "foobaz" with + | strLiteral -> true + | _ -> false) <> true then exit 1 + +[] +let boolLiteral = false + +if (match false with + | boolLiteral -> true + | true -> false) <> true then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/MatchNaN.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/MatchNaN.fs new file mode 100644 index 00000000000..9812451d83a --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/MatchNaN.fs @@ -0,0 +1,29 @@ +// #Conformance #PatternMatching #Constants +#light + +// Verify the ability to match against NaN. Note that +// this should + +let rec TestIsNaN x = + match box x with + | :? float as fx -> isNaNFloat fx + | :? float32 as f32x -> isNaNFloat32 f32x + +and isNaNFloat x = + match x with + | System.Double.NaN -> failwith "Should never match" + | 0.0 -> failwith "Should never match" + | _ -> () + +and isNaNFloat32 x = + match x with + | System.Single.NaN -> failwith "Should never match" + | 0.0f -> failwith "Should never match" + | _ -> () + +// This seems strange, but accoring to the IEEE spec +// NaN <> NaN +TestIsNaN System.Single.NaN +TestIsNaN System.Double.NaN + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/SimpleConstant.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/SimpleConstant.fs new file mode 100644 index 00000000000..be57aa8eb9b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/SimpleConstant.fs @@ -0,0 +1,295 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Conformance.PatternMatching + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module SimpleConstant = + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - DiffAssembly_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - E_NoRangeConst01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 10, Line 9, Col 9, Line 9, Col 11, "Unexpected symbol '..' in pattern matching. Expected '->' or other token.") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - E_type_bigint_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 720, Line 9, Col 7, Line 9, Col 9, "Non-primitive numeric literal constants cannot be used in pattern matches because they can be mapped to multiple different types through the use of a NumericLiteral module. Consider using replacing with a variable, and use 'when = ' at the end of the match clause.") + (Error 720, Line 10, Col 7, Line 10, Col 10, "Non-primitive numeric literal constants cannot be used in pattern matches because they can be mapped to multiple different types through the use of a NumericLiteral module. Consider using replacing with a variable, and use 'when = ' at the end of the match clause.") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - E_type_bignum40_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 720, Line 10, Col 7, Line 10, Col 13, "Non-primitive numeric literal constants cannot be used in pattern matches because they can be mapped to multiple different types through the use of a NumericLiteral module. Consider using replacing with a variable, and use 'when = ' at the end of the match clause.") + (Error 720, Line 11, Col 7, Line 11, Col 9, "Non-primitive numeric literal constants cannot be used in pattern matches because they can be mapped to multiple different types through the use of a NumericLiteral module. Consider using replacing with a variable, and use 'when = ' at the end of the match clause.") + (Error 784, Line 14, Col 17, Line 14, Col 19, "This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - FullyQualify01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - matchConst01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - matchConst02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - matchConst03_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - matchConst04_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - MatchLiteral01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 3190, Line 13, Col 7, Line 13, Col 17, "Lowercase literal 'intLiteral' is being shadowed by a new pattern with the same name. Only uppercase and module-prefixed literals can be used as named patterns.") + (Warning 26, Line 14, Col 7, Line 14, Col 26, "This rule will never be matched") + (Warning 3190, Line 20, Col 7, Line 20, Col 17, "Lowercase literal 'strLiteral' is being shadowed by a new pattern with the same name. Only uppercase and module-prefixed literals can be used as named patterns.") + (Warning 26, Line 21, Col 7, Line 21, Col 26, "This rule will never be matched") + (Warning 3190, Line 27, Col 7, Line 27, Col 18, "Lowercase literal 'boolLiteral' is being shadowed by a new pattern with the same name. Only uppercase and module-prefixed literals can be used as named patterns.") + (Warning 26, Line 28, Col 7, Line 28, Col 27, "This rule will never be matched") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - MatchNaN_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 25, Line 8, Col 11, Line 8, Col 16, "Incomplete pattern matches on this expression. For example, the value '``some-other-subtype``' may indicate a case not covered by the pattern(s).") + (Warning 26, Line 14, Col 7, Line 14, Col 57, "This rule will never be matched") + (Warning 26, Line 20, Col 7, Line 20, Col 57, "This rule will never be matched") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_bigint_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_bool_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 26, Line 10, Col 7, Line 10, Col 28, "This rule will never be matched") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_byte_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_byteArr_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_char_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_double_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_float32_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_int_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_int16_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_int64_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_nativenint_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_sbyte_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_string_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 26, Line 10, Col 7, Line 10, Col 26, "This rule will never be matched") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_uint16_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_uint32_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_uint64_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_unativenint_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/SimpleConstant) + [] + let ``SimpleConstant - type_unit_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 26, Line 9, Col 7, Line 9, Col 17, "This rule will never be matched") \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/matchConst01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/matchConst01.fs new file mode 100644 index 00000000000..9977f89e3cb --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/matchConst01.fs @@ -0,0 +1,15 @@ +// #Conformance #PatternMatching #Constants +#light + +let isZero x = + match x with + | 0 -> true + | x when x < 0 -> false + | x when x > 0 -> false + | _ -> failwith "Shouldn't ever happen" + +if isZero (-1) <> false then exit 1 +if isZero 0 <> true then exit 1 +if isZero 1 <> false then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/matchConst02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/matchConst02.fs new file mode 100644 index 00000000000..4c763420234 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/matchConst02.fs @@ -0,0 +1,15 @@ +// #Conformance #PatternMatching #Constants +#light + +let isBob x = + match x with + | "Bob" -> true + | s when s < "Bob" -> false + | t when t > "Bob" -> false + | _ -> failwith "Shouldn't ever happen" + +if isBob "Alan" <> false then exit 1 +if isBob "Bob" <> true then exit 1 +if isBob "Carl" <> false then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/matchConst03.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/matchConst03.fs new file mode 100644 index 00000000000..1fbe3d72a52 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/matchConst03.fs @@ -0,0 +1,26 @@ +// #Conformance #PatternMatching #Constants +#light + +// Match floating point numbers +type Number = NotPI | SortOfPI | CloseToPI | CloseEnoughToPI + +let piCheck x = + match x with + | 3.1 -> NotPI + | 3.14 -> SortOfPI + | 3.141 -> CloseToPI + | 3.1415 -> CloseEnoughToPI + | _ when System.Math.Abs((x - 3.1415)) < 0.0001 -> CloseEnoughToPI + | _ -> NotPI + +if piCheck 3.1 <> NotPI then exit 1 +if piCheck 3.14 <> SortOfPI then exit 1 +if piCheck 3.141 <> CloseToPI then exit 1 +if piCheck 3.1415 <> CloseEnoughToPI then exit 1 +if piCheck 3.14159 <> CloseEnoughToPI then exit 1 +if piCheck 3.141592 <> CloseEnoughToPI then exit 1 + +if piCheck 3.0 <> NotPI then exit 1 +if piCheck -42.0 <> NotPI then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/matchConst04.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/matchConst04.fs new file mode 100644 index 00000000000..d3a26b58ec7 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/matchConst04.fs @@ -0,0 +1,24 @@ +// #Conformance #PatternMatching #Constants +#light + +// Match against an enum + +open System + +let isWeekend day = + match day with + | DayOfWeek.Sunday | DayOfWeek.Saturday + -> true + | DayOfWeek.Monday | DayOfWeek.Tuesday + | DayOfWeek.Wednesday | DayOfWeek.Thursday + | DayOfWeek.Friday + -> false + | _ -> false + + +if isWeekend DayOfWeek.Saturday <> true then exit 1 + +// This is why a catch all pattern must be there... +if isWeekend (enum -42) <> false then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_bigint.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_bigint.fs new file mode 100644 index 00000000000..19bbde72111 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_bigint.fs @@ -0,0 +1,12 @@ +// #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: BigInt +#light + +let isZero x = + match x with + | y when y = 0I -> true // notice: 0I -> true would yield an error + | y when y = 99I -> false // notice: 99I -> false would yield an error + | _ -> false + +exit (if isZero 0I then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_bool.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_bool.fs new file mode 100644 index 00000000000..0713270aaa6 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_bool.fs @@ -0,0 +1,12 @@ +// #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: Bool +#light + +let isZero x = + match x with + | true -> true + | false -> false + | _ -> failwith "What?" + +exit (if (isZero true) && (not (isZero false)) then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_byte.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_byte.fs new file mode 100644 index 00000000000..33270b0c448 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_byte.fs @@ -0,0 +1,12 @@ +// #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: byte +#light + +let isZero x = + match x with + | 0uy -> true + | 99uy -> false + | _ -> false + +exit (if isZero 0uy then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_byteArr.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_byteArr.fs new file mode 100644 index 00000000000..9dcd87e5c7d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_byteArr.fs @@ -0,0 +1,14 @@ +// #Regression #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: byte[] +// This is a regression test for FSHARP1.0:2036 +#light + +let isZero x = + match x with + | ""B -> true + | @"\"B -> false + | "ASCII"B -> false + | _ -> false + +exit (if isZero ""B then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_char.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_char.fs new file mode 100644 index 00000000000..338658c5162 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_char.fs @@ -0,0 +1,12 @@ +// #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: char +#light + +let isZero x = + match x with + | 'a' -> true + | '\\' -> false + | _ -> false + +exit (if isZero 'a' then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_double.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_double.fs new file mode 100644 index 00000000000..f2659f21048 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_double.fs @@ -0,0 +1,13 @@ +// #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: double +#light + +let isZero x = + match x with + | 1. -> false + | 1.01 -> false + | 1.01e10 -> true + | _ -> false + +exit (if isZero 1.01e10 then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_float32.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_float32.fs new file mode 100644 index 00000000000..860dd9b21d1 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_float32.fs @@ -0,0 +1,13 @@ +// #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: double +#light + +let isZero x = + match x with + | 1.f -> true + | 1.01f -> false + | 1.01e10f -> false + | _ -> false + +exit (if isZero 1.f then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_int.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_int.fs new file mode 100644 index 00000000000..36e24c95194 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_int.fs @@ -0,0 +1,12 @@ +// #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: int +#light + +let isZero x = + match x with + | 0 -> true + | 99 -> false + | _ -> false + +exit (if isZero 0 then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_int16.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_int16.fs new file mode 100644 index 00000000000..fbcbcb2ccb6 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_int16.fs @@ -0,0 +1,12 @@ +// #Conformance #PatternMatching #Constants +// Constant expressions +// This is the example quoted from the specs +// Verification: +// - all the different types work +// - the type we get is what we meant it to be +#light + +let v = 17s // int16 +let check(x:int16) = true + +exit (if check(v) then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_int64.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_int64.fs new file mode 100644 index 00000000000..d8d3b993078 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_int64.fs @@ -0,0 +1,14 @@ +// #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: int64 +#light + +let isZero x = + match x with + | 0L -> false + | 99L -> true + | -99L -> false + | _ -> false + +exit (if isZero 99L then 0 else 1) + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_nativenint.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_nativenint.fs new file mode 100644 index 00000000000..49dac8802dc --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_nativenint.fs @@ -0,0 +1,12 @@ +// #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: nativeint +#light + +let isZero x = + match x with + | 0n -> false + | 99999999n -> true + | _ -> false + +exit (if isZero 99999999n then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_sbyte.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_sbyte.fs new file mode 100644 index 00000000000..76ac6ad324e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_sbyte.fs @@ -0,0 +1,12 @@ +// #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: sbyte +#light + +let isZero x = + match x with + | -20y -> true + | 99y -> false + | _ -> false + +exit (if isZero -20y then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_string.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_string.fs new file mode 100644 index 00000000000..8c6f124ab9c --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_string.fs @@ -0,0 +1,14 @@ +// #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: string +#light + +let isZero x = + match x with + | "3" -> false + | "c:\\home" -> false + | @"c:\home" -> false + | @"@" -> true + | _ -> false + +exit (if isZero @"@" then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_uint16.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_uint16.fs new file mode 100644 index 00000000000..66c11053695 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_uint16.fs @@ -0,0 +1,12 @@ +// #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: uint16 +#light + +let isZero x = + match x with + | 0us -> true + | 99us -> false + | _ -> false + +exit (if isZero 0us then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_uint32.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_uint32.fs new file mode 100644 index 00000000000..8f8b2d0c6c8 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_uint32.fs @@ -0,0 +1,12 @@ +// #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: uint32 +#light + +let isZero x = + match x with + | 0u -> true + | 99u -> false + | _ -> false + +exit (if isZero 0u then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_uint64.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_uint64.fs new file mode 100644 index 00000000000..221d4009bd9 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_uint64.fs @@ -0,0 +1,12 @@ +// #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: uint64 +#light + +let isZero x = + match x with + | 0UL -> false + | 9999999999999UL -> true + | _ -> false + +exit (if isZero 9999999999999UL then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_unativenint.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_unativenint.fs new file mode 100644 index 00000000000..a3447af87b7 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_unativenint.fs @@ -0,0 +1,12 @@ +// #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: unativeint +#light + +let isZero x = + match x with + | 0un -> true + | 99un -> false + | _ -> false + +exit (if isZero 0un then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_unit.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_unit.fs new file mode 100644 index 00000000000..a9535e5d106 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/SimpleConstant/type_unit.fs @@ -0,0 +1,11 @@ +// #Conformance #PatternMatching #Constants +// Pattern Matching - Simple Constants +// Type: unit +#light + +let isZero x = + match x with + | () -> true + | _ -> false + +exit (if isZero () then 0 else 1) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/SimpleTuples01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/SimpleTuples01.fs new file mode 100644 index 00000000000..036b2d45094 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/SimpleTuples01.fs @@ -0,0 +1,12 @@ +// #Conformance #PatternMatching #Tuples +#light + +let tupleStartsWithOne x = + match x with + | 1, _ -> true + | _, _ -> false + +if tupleStartsWithOne (1, 0) <> true then exit 1 +if tupleStartsWithOne (0, 1) <> false then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/Tuple.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/Tuple.fs new file mode 100644 index 00000000000..03398abebe6 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/Tuple.fs @@ -0,0 +1,57 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Conformance.PatternMatching + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module Tuple = + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Tuple) + [] + let ``Tuple - SimpleTuples01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Tuple) + [] + let ``Tuple - tuples01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Tuple) + [] + let ``Tuple - W_IncompleteMatches01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 25, Line 8, Col 5, Line 8, Col 13, "Incomplete pattern matches on this expression. For example, the value '(0,1)' may indicate a case not covered by the pattern(s).") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Tuple) + [] + let ``Tuple - W_RedundantPattern01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 26, Line 11, Col 7, Line 12, Col 16, "This rule will never be matched") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Tuple) + [] + let ``Tuple - W_RedundantPattern02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Warning 26, Line 12, Col 28, Line 12, Col 50, "This rule will never be matched") + \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/W_IncompleteMatches01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/W_IncompleteMatches01.fs new file mode 100644 index 00000000000..9efcf49e8b8 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/W_IncompleteMatches01.fs @@ -0,0 +1,14 @@ +// #Regression #Conformance #PatternMatching #Tuples + + +// Verify warnings for incomplete pattern matches +//Incomplete pattern matches on this expression. + +let test() = + function + | 1, _ + | 2, _ + | 3, _ -> 'a' + | _, 0 -> 'b' + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/W_RedundantPattern01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/W_RedundantPattern01.fs new file mode 100644 index 00000000000..f8e38f3ce21 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/W_RedundantPattern01.fs @@ -0,0 +1,15 @@ +// #Regression #Conformance #PatternMatching #Tuples +#light + +// Verify warning with redundant pattern +//This rule will never be matched + +let redPat () = + function + | 1, _, _ + -> true + | 1, _, _ + -> true + | _ -> false + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/W_RedundantPattern02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/W_RedundantPattern02.fs new file mode 100644 index 00000000000..3015210ce04 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/W_RedundantPattern02.fs @@ -0,0 +1,19 @@ +// #Regression #Conformance #PatternMatching #Tuples +#light + +// Verify warning if all DU tags are matched with and +// a wildcard is included. +//This rule will never be matched + +type DU = A | B | C of int + +let test = + function | A -> 1 | B -> 2 | C(0) -> 3 + | C(x) -> x | _ -> failwith "Bummer" + +let _ = test A +let _ = test B +let _ = test <| C(0) +let _ = test <| C(4) + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/tuples01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/tuples01.fs new file mode 100644 index 00000000000..72d5e59165e --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Tuple/tuples01.fs @@ -0,0 +1,19 @@ +// #Conformance #PatternMatching #Tuples +#light + +// Match nested tuples + +let monsterTuple = ("0", "1", ("2", "2.1", "2.2"), "3", ("4", ("4.1", "4.1.1"), "4.2")) + +let result = + match monsterTuple with + | (_, _, (_, _, _), _, (_, (_, _), _)) -> true + +// Possible compile time error: +// MonsterTuple doesn't match signature (...) from type inference + +// Possible runtime error: +// MatchNotFoundException +if result <> true then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/TypeConstraint/E_typecontraint01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/TypeConstraint/E_typecontraint01.fs new file mode 100644 index 00000000000..4ce19c52666 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/TypeConstraint/E_typecontraint01.fs @@ -0,0 +1,21 @@ +// #Regression #Conformance #PatternMatching #TypeConstraints +// Regression test for FSHARP1.0:1525 +// type constraints on pattern matching are deprecated and are now errors (used to be warnings) +// As of Beta2, we are not even giving the deprecation error. +//Unexpected symbol ':>' in pattern. Expected '\)' or other token. +//Unmatched '\('$ +//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. +type A() = class + end + +type B() = class + inherit A() + end + +type C() = class + inherit B() + end + +let test1 (x:#A) = + match x with + | (o :> B) -> o.GetHashCode() diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/TypeConstraint/TypeConstraint.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/TypeConstraint/TypeConstraint.fs new file mode 100644 index 00000000000..d2d190f135d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/TypeConstraint/TypeConstraint.fs @@ -0,0 +1,22 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Conformance.PatternMatching + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module TypeConstraint = + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/TypeConstraint) + [] + let ``TypeConstraint - E_typecontraint01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 10, Line 21, Col 8, Line 21, Col 10, "Unexpected symbol ':>' in pattern. Expected ')' or other token.") + (Error 583, Line 21, Col 5, Line 21, Col 6, "Unmatched '('") + ] + \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_CapturesDiffVal01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_CapturesDiffVal01.fs new file mode 100644 index 00000000000..363ab3c29a0 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_CapturesDiffVal01.fs @@ -0,0 +1,13 @@ +// #Regression #Conformance #PatternMatching #Unions +#light + +// Verify error if two pattern match clauses match +// different values +//The two sides of this 'or' pattern bind different sets of variables + +let testMatch x = + match x with + | (x, 0, 0) | (0, y, 0) | (0, 0, z) -> true + | _ -> false + +exit 1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_NotAllCaptureSameVal01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_NotAllCaptureSameVal01.fs new file mode 100644 index 00000000000..af9e457cd93 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_NotAllCaptureSameVal01.fs @@ -0,0 +1,13 @@ +// #Regression #Conformance #PatternMatching #Unions +#light + +// Verify error if not all union pattern rules capture the +// same set of values +//The two sides of this 'or' pattern bind different sets of variables + +let tupeMatch x = + match x with + | (x, 0) | (0, x) | (0, 0) -> true + | _ -> false + +exit 1 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionCapturesDiffType01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionCapturesDiffType01.fs new file mode 100644 index 00000000000..def92d6297b --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/E_UnionCapturesDiffType01.fs @@ -0,0 +1,11 @@ +// #Regression #Conformance #PatternMatching #Unions +// Verify error if two union rules capture values with different types +//This expression was expected to have type. 'int' .but here has type. 'float' + +let testMatch x = + match x with + | 0, 0.0 -> true + | x, 0.0 + | 0, x -> false + | _, _ -> false + diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs new file mode 100644 index 00000000000..24f4fcbb8c9 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/Union.fs @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Conformance.PatternMatching + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module Union = + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Union) + [] + let ``Union - E_CapturesDiffVal01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Error 18, Line 10, Col 7, Line 10, Col 28, "The two sides of this 'or' pattern bind different sets of variables") + (Error 18, Line 10, Col 7, Line 10, Col 40, "The two sides of this 'or' pattern bind different sets of variables") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Union) + [] + let ``Union - E_NotAllCaptureSameVal01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 18, Line 10, Col 7, Line 10, Col 31, "The two sides of this 'or' pattern bind different sets of variables") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Union) + [] + let ``Union - E_UnionCapturesDiffType01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withSingleDiagnostic (Error 1, Line 9, Col 10, Line 9, Col 11, "This expression was expected to have type + 'int' +but here has type + 'float' ") + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Union) + [] + let ``Union - unionPattern01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Union) + [] + let ``Union - unionPattern02_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Union) + [] + let ``Union - unionPattern03_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldFail + |> withDiagnostics [ + (Warning 26, Line 12, Col 7, Line 12, Col 17, "This rule will never be matched") + (Warning 26, Line 21, Col 7, Line 21, Col 17, "This rule will never be matched") + ] + + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Union) + [] + let ``Union - unionPattern04_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/unionPattern01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/unionPattern01.fs new file mode 100644 index 00000000000..065c374776d --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/unionPattern01.fs @@ -0,0 +1,21 @@ +// #Conformance #PatternMatching #Unions +#light + +type Foo = + | A of int * string + | B of string * int + +let test x = + match x with + | A (x, "cheese") + | B (_, x) when x > 0 + -> x + | _ -> 0 + +if test (A(100, "")) <> 0 then exit 1 +if test (A(100, "cheese")) <> 100 then exit 1 + +if test (B("", -100)) <> 0 then exit 1 +if test (B("", 42)) <> 42 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/unionPattern02.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/unionPattern02.fs new file mode 100644 index 00000000000..c06ef31ab0a --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/unionPattern02.fs @@ -0,0 +1,18 @@ +// #Conformance #PatternMatching #Unions +#light + +// Test a match statement with just one 'match thingey' +type Foo = A | B of string | C of int + +let test x = + match x with + | A + | B _ + | C (_) + -> true + +if (test (A)) <> true then exit 1 +if (test (B(""))) <> true then exit 1 +if (test (C(0))) <> true then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/unionPattern03.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/unionPattern03.fs new file mode 100644 index 00000000000..95f9bcb6925 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/unionPattern03.fs @@ -0,0 +1,33 @@ +// #Conformance #PatternMatching #Unions +#light + +// Test that when there are two potential matches, they are matched in the order they are defined. +type Foo = A | B | C | D + +let test1 x = + match x with + | A | B -> 1 + | B | C -> 2 + | C | D -> 3 + | D | A -> 4 + +// The union of patterns should be considered a single entity, and thus +// their relative ordering shoudln't matter. +let test2 x = + match x with + | B | A -> 1 + | C | B -> 2 + | D | C -> 3 + | A | D -> 4 + +if test1 A <> 1 then exit 1 +if test1 B <> 1 then exit 1 +if test1 C <> 2 then exit 1 +if test1 D <> 3 then exit 1 + +if test2 A <> 1 then exit 1 +if test2 B <> 1 then exit 1 +if test2 C <> 2 then exit 1 +if test2 D <> 3 then exit 1 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/unionPattern04.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/unionPattern04.fs new file mode 100644 index 00000000000..fe58732f913 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Union/unionPattern04.fs @@ -0,0 +1,12 @@ +// #Regression #Conformance #PatternMatching #Unions +#light + +// Regression test for FSHARP1.0:3914 - Invalid value when returning a pattern match-bound parameter in the enclosure of a lambda (does that make sense?) + +type XDuTag = XDuTag + +let foo XDuTag = fun y -> XDuTag + +let bar = foo XDuTag 0.0 + +exit 0 diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Wildcard/Wildcard.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Wildcard/Wildcard.fs new file mode 100644 index 00000000000..2831e485b84 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Wildcard/Wildcard.fs @@ -0,0 +1,17 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace Conformance.PatternMatching + +open Xunit +open FSharp.Test +open FSharp.Test.Compiler + +module Wildcard = + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Wildcard) + [] + let ``Wildcard - wildCardPatterns01_fs - --test:ErrorRanges`` compilation = + compilation + |> asFs + |> withOptions ["--test:ErrorRanges"] + |> typecheck + |> shouldSucceed \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Wildcard/wildCardPatterns01.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Wildcard/wildCardPatterns01.fs new file mode 100644 index 00000000000..a3bca207911 --- /dev/null +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Wildcard/wildCardPatterns01.fs @@ -0,0 +1,17 @@ +// #Conformance #PatternMatching +#light + +// Verify that the shape of data matched against a wildcard +// doesn't have to match. + +let matchList x = + match x with + | fsd :: second :: tail -> false + | last :: [] -> false + | _ -> true + +let matchTuple x = + match x with + | (1,2,3) | (3,4,5) -> false + | (x,_,9) -> false + | _ -> true diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index af09e1f3879..78affdc1c20 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -87,7 +87,22 @@ - + + + + + + + + + + + + + + + + From fa04738d6e719ea662761cff083f2250445abfb8 Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Mon, 7 Aug 2023 17:53:56 +0200 Subject: [PATCH 2/4] update tests --- .../Conformance/PatternMatching/And/And.fs | 2 - .../PatternMatching/Array/Array.fs | 4 -- .../PatternMatching/ConsList/ConsList.fs | 1 - .../DynamicTypeTest/DynamicTypeTest.fs | 8 ---- .../PatternMatching/Expression/Expression.fs | 6 --- .../PatternMatching/Named/Named.fs | 13 ------ .../PatternMatching/Simple/Simple.fs | 45 ++++++------------- .../FSharp.Compiler.ComponentTests.fsproj | 1 - 8 files changed, 13 insertions(+), 67 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/And.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/And.fs index 73ccde330e9..537cae7cad5 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/And.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/And.fs @@ -15,7 +15,6 @@ module And = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/And) [] @@ -25,7 +24,6 @@ module And = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/And) [] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/Array.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/Array.fs index 423453ff445..5d686020f22 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/Array.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Array/Array.fs @@ -15,7 +15,6 @@ module Array = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Array) [] @@ -25,7 +24,6 @@ module Array = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Array) [] @@ -35,7 +33,6 @@ module Array = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Array) [] @@ -45,4 +42,3 @@ module Array = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore \ No newline at end of file diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/ConsList.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/ConsList.fs index 574036ad9a2..2bae41654a8 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/ConsList.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/ConsList/ConsList.fs @@ -15,7 +15,6 @@ module ConsList = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/ConsList) [] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/DynamicTypeTest.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/DynamicTypeTest.fs index 24d0b08e67d..c2999b14ad9 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/DynamicTypeTest.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/DynamicTypeTest/DynamicTypeTest.fs @@ -15,7 +15,6 @@ module DynamicTypeTest = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) [] @@ -25,7 +24,6 @@ module DynamicTypeTest = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) [] @@ -48,7 +46,6 @@ module DynamicTypeTest = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) [] @@ -68,7 +65,6 @@ module DynamicTypeTest = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) [] @@ -102,7 +98,6 @@ involves an indeterminate type based on information prior to this program point. |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) [] @@ -112,7 +107,6 @@ involves an indeterminate type based on information prior to this program point. |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) [] @@ -122,7 +116,6 @@ involves an indeterminate type based on information prior to this program point. |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) [] @@ -132,7 +125,6 @@ involves an indeterminate type based on information prior to this program point. |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/DynamicTypeTest) [] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/Expression.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/Expression.fs index de69758f748..2c82340ad76 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/Expression.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Expression/Expression.fs @@ -25,7 +25,6 @@ module Expression = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Expression) [] @@ -35,7 +34,6 @@ module Expression = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Expression) [] @@ -105,7 +103,6 @@ module Expression = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Expression) [] @@ -115,7 +112,6 @@ module Expression = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Expression) [] @@ -125,7 +121,6 @@ module Expression = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Expression) [] @@ -135,4 +130,3 @@ module Expression = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/Named.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/Named.fs index 96c5fe773f2..66157b9837a 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/Named.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Named/Named.fs @@ -15,7 +15,6 @@ module Named = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) [] @@ -25,7 +24,6 @@ module Named = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) [] @@ -35,7 +33,6 @@ module Named = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) [] @@ -45,7 +42,6 @@ module Named = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) [] @@ -55,7 +51,6 @@ module Named = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) [] @@ -65,7 +60,6 @@ module Named = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) [] @@ -75,7 +69,6 @@ module Named = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) [] @@ -85,7 +78,6 @@ module Named = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) [] @@ -95,7 +87,6 @@ module Named = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) [] @@ -106,7 +97,6 @@ module Named = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) [] @@ -116,7 +106,6 @@ module Named = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) [] @@ -126,7 +115,6 @@ module Named = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) [] @@ -136,7 +124,6 @@ module Named = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Named) [] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs index 8200b019881..7a6f40b4c6a 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/Simple/Simple.fs @@ -17,10 +17,8 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> typecheck |> shouldFail - |> withWarningCode 0025 - |> withDiagnosticMessageMatches "Incomplete pattern matches on this expression. For example, the value 'Result \(_\)' may indicate a case not covered by the pattern\(s\)" - |> ignore - + |> withSingleDiagnostic (Warning 25, Line 92, Col 13, Line 92, Col 14, "Incomplete pattern matches on this expression. For example, the value 'Result (_)' may indicate a case not covered by the pattern(s).") + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) //This rule will never be matched [] @@ -30,9 +28,12 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldFail - |> withWarningCode 0026 - |> withDiagnosticMessageMatches "This rule will never be matched" - |> ignore + |> withDiagnostics [ + (Warning 25, Line 14, Col 15, Line 14, Col 16, "Incomplete pattern matches on this expression. For example, the value '0' may indicate a case not covered by the pattern(s).") + (Warning 25, Line 21, Col 31, Line 21, Col 39, "Incomplete pattern matches on this expression. For example, the value '0' may indicate a case not covered by the pattern(s).") + (Warning 26, Line 31, Col 11, Line 31, Col 18, "This rule will never be matched") + (Warning 26, Line 32, Col 11, Line 32, Col 19, "This rule will never be matched") + ] // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) //Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name @@ -43,10 +44,11 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldFail - |> withWarningCode 0049 - |> withDiagnosticMessageMatches "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name" - |> ignore - + |> withDiagnostics [ + (Warning 49, Line 9, Col 16, Line 9, Col 19, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + (Warning 49, Line 10, Col 16, Line 10, Col 19, "Uppercase variable identifiers should not generally be used in patterns, and may indicate a missing open declaration or a misspelt pattern name.") + ] + // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] let ``Simple - CodeGenReg01_fs - --test:ErrorRanges`` compilation = @@ -55,7 +57,6 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] @@ -125,7 +126,6 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] @@ -135,7 +135,6 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] @@ -145,7 +144,6 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] @@ -155,7 +153,6 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] @@ -165,7 +162,6 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] @@ -175,7 +171,6 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] @@ -185,7 +180,6 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] @@ -195,7 +189,6 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] @@ -205,7 +198,6 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] @@ -215,7 +207,6 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] @@ -235,7 +226,6 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] @@ -245,7 +235,6 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] @@ -255,7 +244,6 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] @@ -265,7 +253,6 @@ module Simple = |> withOptions ["--test:ErrorRanges"] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] @@ -275,7 +262,6 @@ module Simple = |> withOptions ["--test:ErrorRanges";] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/Simple) [] @@ -295,7 +281,6 @@ module Simple = |> withOptions ["--test:ErrorRanges";] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/AsPatterns) [] @@ -305,7 +290,6 @@ module Simple = |> withOptions ["--test:ErrorRanges";] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/AsPatterns) [] @@ -315,7 +299,6 @@ module Simple = |> withOptions ["--test:ErrorRanges";] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/AsPatterns) [] @@ -325,7 +308,6 @@ module Simple = |> withOptions ["--test:ErrorRanges";] |> compile |> shouldSucceed - |> ignore // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/AsPatterns) [] @@ -335,7 +317,6 @@ module Simple = |> withOptions ["--test:ErrorRanges";] |> compile |> shouldSucceed - |> ignore [] let ``Enum incompleteness check should not hide an issue with outer DU pattern matching with nowarn:104 `` () = diff --git a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj index 78affdc1c20..20fd78fec08 100644 --- a/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj +++ b/tests/FSharp.Compiler.ComponentTests/FSharp.Compiler.ComponentTests.fsproj @@ -90,7 +90,6 @@ - From 16b1983ed36efca1bda3cd4a7d19106c868da4ec Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 8 Aug 2023 06:56:39 +0200 Subject: [PATCH 3/4] update andPattern03 test --- .../Conformance/PatternMatching/And/And.fs | 11 +---------- .../Conformance/PatternMatching/And/andPattern03.fs | 2 +- 2 files changed, 2 insertions(+), 11 deletions(-) diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/And.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/And.fs index 537cae7cad5..596de0187b1 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/And.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/And.fs @@ -32,16 +32,7 @@ module And = |> asFs |> withOptions ["--test:ErrorRanges"] |> typecheck - |> shouldFail - |> withDiagnostics [ - (Error 41, Line 7, Col 28, Line 7, Col 45, "A unique overload for method 'TryParse' could not be determined based on type information prior to this program point. A type annotation may be needed. - -Known type of argument: 'a - -Candidates: - - Int32.TryParse(s: ReadOnlySpan, result: byref) : bool - - Int32.TryParse(s: string, result: byref) : bool") - ] + |> shouldSucceed // This test was automatically generated (moved from FSharpQA suite - Conformance/PatternMatching/And) [] diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern03.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern03.fs index b7dcac145ca..2b9938c209b 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern03.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/PatternMatching/And/andPattern03.fs @@ -3,7 +3,7 @@ open System -let (|ToInt|) x = +let (|ToInt|) (x: string) = let (parsed, result) = Int32.TryParse(x) if parsed then result else -1 From f8d93b0ef6e5e1ff761a5b060ed80b6d6e37975f Mon Sep 17 00:00:00 2001 From: Edgar Gonzalez Date: Tue, 8 Aug 2023 13:15:16 +0200 Subject: [PATCH 4/4] Remove old tests --- .../PatternMatching/And/E_IdentBoundTwice.fs | 11 -- .../PatternMatching/And/andPattern01.fs | 29 ----- .../PatternMatching/And/andPattern02.fs | 23 ---- .../PatternMatching/And/andPattern03.fs | 28 ----- .../Conformance/PatternMatching/And/env.lst | 5 - .../PatternMatching/Array/TrailingSemi01.fs | 102 ---------------- .../PatternMatching/Array/arrayMatch01.fs | 18 --- .../PatternMatching/Array/arrayMatch02.fs | 13 --- .../PatternMatching/Array/arrayMatch03.fs | 16 --- .../Conformance/PatternMatching/Array/env.lst | 5 - .../PatternMatching/As/asPattern01.fs | 11 -- .../PatternMatching/As/asPattern02.fs | 20 ---- .../Conformance/PatternMatching/As/env.lst | 2 - .../ConsList/E_consOnNonList.fs | 7 -- .../ConsList/E_consPattern01.fs | 17 --- .../ConsList/OutsideMatch01.fs | 12 -- .../PatternMatching/ConsList/consPattern01.fs | 17 --- .../PatternMatching/ConsList/env.lst | 6 - .../DynamicTypeTest/ArrayTypeTest01.fs | 16 --- .../DynamicTypeTest/E_DynamTyTestVarType01.fs | 15 --- .../E_DynamicTestPrimType01.fs | 14 --- .../DynamicTypeTest/Regression01.fs | 27 ----- .../DynamicTypeTest/Regression02.fs | 18 --- .../DynamicTypeTest/TwoAtOnce01.fs | 33 ------ .../DynamicTypeTest/W_RedundantPattern01.fs | 21 ---- .../W_TypeTestWillAlwaysHold01.fs | 17 --- .../DynamicTypeTest/dynTestSealedType01.fs | 27 ----- .../DynamicTypeTest/dynamicTypeTest01.fs | 27 ----- .../DynamicTypeTest/dynamicTypeTest02.fs | 45 -------- .../DynamicTypeTest/dynamicTypeTest03.fs | 63 ---------- .../DynamicTypeTest/dynamicTypeTest04.fs | 12 -- .../PatternMatching/DynamicTypeTest/env.lst | 19 --- .../DynamicTypeTest/genericType01.fs | 16 --- .../Expression/E_CounterExample01.fs | 9 -- .../Expression/NoCounterExampleTryWith01.fs | 25 ---- .../Expression/W_CounterExampleWithEnum01.fs | 36 ------ .../Expression/W_CounterExampleWithEnum02.fs | 32 ----- .../Expression/W_whenGuards01.fs | 16 --- .../PatternMatching/Expression/env.lst | 14 --- .../PatternMatching/Expression/patterns01.fs | 18 --- .../PatternMatching/Expression/patterns02.fs | 16 --- .../Expression/whenGuards01.fs | 37 ------ .../Expression/whenGuards02.fs | 20 ---- .../Expression/whenGuardss01.fs | 37 ------ .../Expression/whenGuardss02.fs | 20 ---- .../Named/ActivePatternOutsideMatch01.fs | 20 ---- .../Named/ActivePatternOutsideMatch02.fs | 13 --- .../Named/ActivePatternUnconstrained01.fs | 13 --- .../Named/AsHighOrderFunc01.fs | 34 ------ .../Named/E_ActivePatternHasNoFields.fs | 13 --- .../Named/E_ActivePatternNotAFuncion.fs | 5 - .../Named/E_ActivePatternUnconstrained01.fs | 14 --- .../Named/E_ActivePatterns01.fs | 20 ---- .../Named/E_ActivePatterns02.fs | 8 -- .../PatternMatching/Named/E_Error_LetRec01.fs | 8 -- .../PatternMatching/Named/E_Error_LetRec02.fs | 4 - .../PatternMatching/Named/E_Error_LetRec03.fs | 4 - .../PatternMatching/Named/E_Error_LetRec04.fs | 5 - .../Named/E_Error_NonParam01.fs | 5 - .../Named/E_Error_NonParam02.fs | 4 - .../Named/E_Error_NonParam03.fs | 4 - .../Named/E_Error_NonParam04.fs | 5 - .../PatternMatching/Named/E_Error_Param01.fs | 5 - .../PatternMatching/Named/E_Error_Param02.fs | 4 - .../PatternMatching/Named/E_Error_Param03.fs | 4 - .../PatternMatching/Named/E_Error_Param04.fs | 5 - .../Named/E_LargeActivePat01.fs | 7 -- .../Named/E_MulticasePartialNotAllowed01.fs | 24 ---- .../Named/E_ParameterRestrictions01.fs | 17 --- .../Named/E_PatternMatchRegressions02.fs | 33 ------ .../Named/MultiActivePatterns01.fs | 49 -------- .../PatternMatching/Named/NamedLiteral01.fs | 21 ---- .../PatternMatching/Named/NamedLiteral02.fs | 58 ---------- .../ParamertizedPartialActivePattern01.fs | 33 ------ .../Named/PatternMatchRegressions01.fs | 29 ----- .../Named/PatternMatchRegressions02.fs | 27 ----- .../Named/RecursiveActivePats.fs | 40 ------- .../PatternMatching/Named/activePatterns01.fs | 15 --- .../PatternMatching/Named/activePatterns02.fs | 13 --- .../PatternMatching/Named/activePatterns03.fs | 18 --- .../PatternMatching/Named/activePatterns05.fs | 16 --- .../PatternMatching/Named/activePatterns06.fs | 3 - .../PatternMatching/Named/activePatterns07.fs | 48 -------- .../PatternMatching/Named/activePatterns08.fs | 40 ------- .../PatternMatching/Named/discUnion01.fs | 27 ----- .../PatternMatching/Named/discUnion02.fs | 24 ---- .../Conformance/PatternMatching/Named/env.lst | 52 --------- .../Null/E_notNullCompatible01.fs | 18 --- .../Conformance/PatternMatching/Null/env.lst | 3 - .../PatternMatching/Null/matchNull01.fs | 16 --- .../Record/E_RecTypesNotMatch01.fs | 12 -- .../Record/E_RecordFieldNotDefined01.fs | 12 -- .../PatternMatching/Record/E_SyntaxError01.fs | 12 -- .../PatternMatching/Record/env.lst | 9 -- .../Record/recordPatterns01.fs | 32 ----- .../Record/recordPatterns02.fs | 39 ------- .../Record/structRecordPatterns01.fs | 32 ----- .../Record/structRecordPatterns02.fs | 39 ------- .../PatternMatching/Simple/CodeGenReg01.fs | 49 -------- .../PatternMatching/Simple/E_SyntaxError01.fs | 11 -- .../Simple/E_ValueCapture01.fs | 17 --- .../Simple/E_constPattern01.fs | 16 --- .../Simple/E_namedLiberal01.fs | 23 ---- .../Simple/MatchFailureExn01.fs | 26 ----- .../PatternMatching/Simple/ValueCapture01.fs | 19 --- .../PatternMatching/Simple/ValueCapture02.fs | 35 ------ .../PatternMatching/Simple/W_Incomplete01.fs | 109 ------------------ .../PatternMatching/Simple/W_Incomplete02.fs | 35 ------ .../PatternMatching/Simple/env.lst | 35 ------ .../Simple/simplePatterns01.fs | 15 --- .../Simple/simplePatterns02.fs | 13 --- .../Simple/simplePatterns03.fs | 22 ---- .../Simple/simplePatterns04.fs | 14 --- .../Simple/simplePatterns05.fs | 28 ----- .../Simple/simplePatterns06.fs | 26 ----- .../Simple/simplePatterns07.fs | 20 ---- .../Simple/simplePatterns08.fs | 17 --- .../Simple/simplePatterns09.fs | 19 --- .../Simple/simplePatterns10.fs | 18 --- .../Simple/simplePatterns11.fs | 15 --- .../Simple/simplePatterns12.fs | 21 ---- .../Simple/simplePatterns13.fs | 20 ---- .../Simple/simplePatterns14.fs | 10 -- .../Simple/simplePatterns15.fs | 18 --- .../Simple/simplePatterns16.fs | 27 ----- .../Simple/simplePatterns17.fs | 19 --- .../Simple/simplePatterns18.fs | 30 ----- .../Simple/simplePatterns19.fs | 26 ----- .../Simple/simplePatterns20.fs | 26 ----- .../SimpleConstant/DiffAssembly.fs | 16 --- .../SimpleConstant/E_NoRangeConst01.fs | 25 ---- .../SimpleConstant/E_type_bigint.fs | 13 --- .../SimpleConstant/E_type_bignum40.fs | 14 --- .../SimpleConstant/FullyQualify01.fs | 33 ------ .../SimpleConstant/MatchLiteral01.fs | 30 ----- .../SimpleConstant/MatchNaN.fs | 29 ----- .../PatternMatching/SimpleConstant/env.lst | 35 ------ .../SimpleConstant/matchConst01.fs | 15 --- .../SimpleConstant/matchConst02.fs | 15 --- .../SimpleConstant/matchConst03.fs | 26 ----- .../SimpleConstant/matchConst04.fs | 24 ---- .../SimpleConstant/type_bigint.fs | 12 -- .../SimpleConstant/type_bool.fs | 12 -- .../SimpleConstant/type_byte.fs | 12 -- .../SimpleConstant/type_byteArr.fs | 14 --- .../SimpleConstant/type_char.fs | 12 -- .../SimpleConstant/type_double.fs | 13 --- .../SimpleConstant/type_float32.fs | 13 --- .../SimpleConstant/type_int.fs | 12 -- .../SimpleConstant/type_int16.fs | 12 -- .../SimpleConstant/type_int64.fs | 14 --- .../SimpleConstant/type_nativenint.fs | 12 -- .../SimpleConstant/type_sbyte.fs | 12 -- .../SimpleConstant/type_string.fs | 14 --- .../SimpleConstant/type_uint16.fs | 12 -- .../SimpleConstant/type_uint32.fs | 12 -- .../SimpleConstant/type_uint64.fs | 12 -- .../SimpleConstant/type_unativenint.fs | 12 -- .../SimpleConstant/type_unit.fs | 11 -- .../PatternMatching/Tuple/SimpleTuples01.fs | 12 -- .../Tuple/W_IncompleteMatches01.fs | 14 --- .../Tuple/W_RedundantPattern01.fs | 15 --- .../Tuple/W_RedundantPattern02.fs | 19 --- .../Conformance/PatternMatching/Tuple/env.lst | 5 - .../PatternMatching/Tuple/tuples01.fs | 19 --- .../PatternMatching/TypeAnnotated/env.lst | 1 - .../TypeConstraint/E_typecontraint01.fs | 21 ---- .../PatternMatching/TypeConstraint/env.lst | 1 - .../Union/E_CapturesDiffVal01.fs | 13 --- .../Union/E_NotAllCaptureSameVal01.fs | 13 --- .../Union/E_UnionCapturesDiffType01.fs | 11 -- .../Conformance/PatternMatching/Union/env.lst | 8 -- .../PatternMatching/Union/unionPattern01.fs | 21 ---- .../PatternMatching/Union/unionPattern02.fs | 18 --- .../PatternMatching/Union/unionPattern03.fs | 33 ------ .../PatternMatching/Union/unionPattern04.fs | 12 -- .../PatternMatching/Wildcard/env.lst | 1 - .../Wildcard/wildCardPatterns01.fs | 17 --- tests/fsharpqa/Source/test.lst | 17 --- 179 files changed, 3555 deletions(-) delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/And/E_IdentBoundTwice.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/And/andPattern01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/And/andPattern02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/And/andPattern03.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/And/env.lst delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Array/TrailingSemi01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Array/arrayMatch01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Array/arrayMatch02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Array/arrayMatch03.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Array/env.lst delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/As/asPattern01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/As/asPattern02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/As/env.lst delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/E_consOnNonList.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/E_consPattern01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/OutsideMatch01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/consPattern01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/env.lst delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/ArrayTypeTest01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/E_DynamTyTestVarType01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/E_DynamicTestPrimType01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/Regression01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/Regression02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/TwoAtOnce01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/W_RedundantPattern01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/W_TypeTestWillAlwaysHold01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynTestSealedType01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest03.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest04.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/env.lst delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/genericType01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Expression/E_CounterExample01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Expression/NoCounterExampleTryWith01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Expression/W_CounterExampleWithEnum01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Expression/W_CounterExampleWithEnum02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Expression/W_whenGuards01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Expression/env.lst delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Expression/patterns01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Expression/patterns02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Expression/whenGuards01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Expression/whenGuards02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Expression/whenGuardss01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Expression/whenGuardss02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/ActivePatternOutsideMatch01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/ActivePatternOutsideMatch02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/ActivePatternUnconstrained01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/AsHighOrderFunc01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatternHasNoFields.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatternNotAFuncion.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatternUnconstrained01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatterns01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatterns02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_LetRec01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_LetRec02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_LetRec03.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_LetRec04.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_NonParam01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_NonParam02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_NonParam03.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_NonParam04.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_Param01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_Param02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_Param03.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_Param04.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_LargeActivePat01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_MulticasePartialNotAllowed01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ParameterRestrictions01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_PatternMatchRegressions02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/MultiActivePatterns01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/NamedLiteral01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/NamedLiteral02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/ParamertizedPartialActivePattern01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/PatternMatchRegressions01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/PatternMatchRegressions02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/RecursiveActivePats.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns03.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns05.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns06.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns07.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns08.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/discUnion01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/discUnion02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Named/env.lst delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Null/E_notNullCompatible01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Null/env.lst delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Null/matchNull01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Record/E_RecTypesNotMatch01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Record/E_RecordFieldNotDefined01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Record/E_SyntaxError01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Record/env.lst delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Record/recordPatterns01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Record/recordPatterns02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Record/structRecordPatterns01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Record/structRecordPatterns02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/CodeGenReg01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/E_SyntaxError01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/E_ValueCapture01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/E_constPattern01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/E_namedLiberal01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/MatchFailureExn01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/ValueCapture01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/ValueCapture02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/W_Incomplete01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/W_Incomplete02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/env.lst delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns03.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns04.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns05.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns06.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns07.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns08.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns09.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns10.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns11.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns12.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns13.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns14.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns15.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns16.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns17.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns18.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns19.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns20.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/DiffAssembly.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/E_NoRangeConst01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/E_type_bigint.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/E_type_bignum40.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/FullyQualify01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/MatchLiteral01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/MatchNaN.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/env.lst delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/matchConst01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/matchConst02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/matchConst03.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/matchConst04.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_bigint.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_bool.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_byte.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_byteArr.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_char.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_double.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_float32.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_int.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_int16.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_int64.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_nativenint.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_sbyte.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_string.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_uint16.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_uint32.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_uint64.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_unativenint.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_unit.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/SimpleTuples01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/W_IncompleteMatches01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/W_RedundantPattern01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/W_RedundantPattern02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/env.lst delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/tuples01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/TypeAnnotated/env.lst delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/TypeConstraint/E_typecontraint01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/TypeConstraint/env.lst delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Union/E_CapturesDiffVal01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Union/E_NotAllCaptureSameVal01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Union/E_UnionCapturesDiffType01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Union/env.lst delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Union/unionPattern01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Union/unionPattern02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Union/unionPattern03.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Union/unionPattern04.fs delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Wildcard/env.lst delete mode 100644 tests/fsharpqa/Source/Conformance/PatternMatching/Wildcard/wildCardPatterns01.fs diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/And/E_IdentBoundTwice.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/And/E_IdentBoundTwice.fs deleted file mode 100644 index ae14b063a73..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/And/E_IdentBoundTwice.fs +++ /dev/null @@ -1,11 +0,0 @@ -// #Regression #Conformance #PatternMatching #PatternMatchingGuards -#light - -//'x' is bound twice in this pattern - -let test input = - match input with - | (1, _) & (_, 1) -> 1 - | (x, _) & (_, x) -> 2 - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/And/andPattern01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/And/andPattern01.fs deleted file mode 100644 index 7bc37f0613e..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/And/andPattern01.fs +++ /dev/null @@ -1,29 +0,0 @@ -// #Conformance #PatternMatching #PatternMatchingGuards -#light - -// Verify that and patterns must match both sides - -// And patterns are pretty much only useful with active patterns... -let (|MulTwo|_|) x = if x % 2 = 0 then Some() else None -let (|MulThree|_|) x = if x % 3 = 0 then Some() else None -let (|MulFour|_|) x = if x % 4 = 0 then Some() else None - -let mulOf234 x = - match x with - | MulTwo & MulThree & MulFour -> (true, true, true) - | MulTwo & MulThree -> (true, true, false) - | MulThree & MulFour -> (false, true, true) - | MulTwo & MulFour -> (true, false, true) - | MulTwo -> (true, false, false) - | MulThree -> (false, true, false) - | MulFour -> (false, false, true) - | _ -> (false,false,false) - - -for i = 1 to 100 do - let m2,m3,m4 = mulOf234 i - if m2 <> (i % 2 = 0) then exit 1 - if m3 <> (i % 3 = 0) then exit 1 - if m4 <> (i % 4 = 0) then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/And/andPattern02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/And/andPattern02.fs deleted file mode 100644 index 312fef3d201..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/And/andPattern02.fs +++ /dev/null @@ -1,23 +0,0 @@ -// #Conformance #PatternMatching #PatternMatchingGuards -#light - -// Verify multiple pattern parts can introduce new identifiers -type Foo = - | A of int - | B of string * int - -let (|ToString|) x = match x with A x | B(_,x) -> x.ToString() - -let test v = - match v with - | A(x) & ToString (vToStr) when x = vToStr.Length -> true - | B(str, value) & ToString (vToStr) when str = vToStr -> true - | _ -> false - -if test (A(1)) <> true then exit 1 -if test (B("123", 123)) <> true then exit 1 - -if test (A(2)) <> false then exit 1 -if test (B("100", 10)) <> false then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/And/andPattern03.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/And/andPattern03.fs deleted file mode 100644 index b7dcac145ca..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/And/andPattern03.fs +++ /dev/null @@ -1,28 +0,0 @@ -// #Conformance #PatternMatching #PatternMatchingGuards -#light - -open System - -let (|ToInt|) x = - let (parsed, result) = Int32.TryParse(x) - if parsed then result - else -1 - -let (|ToStr|) (x : int) = x.ToString() - -let test input = - match input with - | ToInt (ToStr "1") -> 1 - | ToInt 2 & ToInt (ToStr "2") -> 2 - | ToInt (ToStr "3") & ToInt (ToStr (ToInt (ToStr "3"))) -> 3 - | _ -> -1 - -if test "1" <> 1 then exit 1 -if test "2" <> 2 then exit 2 -if test "3" <> 3 then exit 3 - -exit 0 - - - - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/And/env.lst b/tests/fsharpqa/Source/Conformance/PatternMatching/And/env.lst deleted file mode 100644 index 7fdf3c254a1..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/And/env.lst +++ /dev/null @@ -1,5 +0,0 @@ - SOURCE=andPattern01.fs # andPattern01.fs - SOURCE=andPattern02.fs # andPattern02.fs - SOURCE=andPattern03.fs # andPattern03.fs - - SOURCE=E_IdentBoundTwice.fs # E_IdentBoundTwice.fs diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Array/TrailingSemi01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Array/TrailingSemi01.fs deleted file mode 100644 index 62db9992e8e..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Array/TrailingSemi01.fs +++ /dev/null @@ -1,102 +0,0 @@ -// #Regression #Conformance #PatternMatching #Arrays -#light - -// Verify ability to match a list, array, or record with trailing semicolon -// (Regression for bug 1190 - minor glitch in record pattern) - -let list1 = [1;2;3;4;] -let list2 = [ - 5; - 6; - 7; - 8; - ] - -if List.length list1 <> 4 then exit 1 -if List.length list2 <> 4 then exit 1 - -// ---------------------------------------- - -let array1 = [| 1;2;3;4; |] -let array2 = [| - 5; - 6; - 7; - 8; - |] - -if Array.length array1 <> 4 then exit 1 -if Array.length array2 <> 4 then exit 1 - -// ---------------------------------------- - -type recordType1 = { - label1 : int; - label2 : int; -} -type recordType2 = { label1B : int; label2B : int; } - -let record1 = { label1 = 0; label2 = 1; } -let record2 = { - label1 = 2; - label2 = 3; - } - -// ------------------------------------------------------------------------- - -let isList1 x = - match x with - | [ - 1; - 2; - 3; - 4; ] -> true - | _ -> false - -let isList2 x = - match x with - | [5; 6; 7; 8;] -> true - | _ -> false - -if not (isList1 list1) then exit 1 -if not (isList2 list2) then exit 1 - -// ---------------------------------------- - -let isArray1 x = - match x with - | [| - 1; - 2; - 3; - 4; |] -> true - | _ -> false - -let isArray2 x = - match x with - | [| 5; 6; 7; 8; |] -> true - | _ -> false - -if not (isArray1 array1) then exit 1 -if not (isArray2 array2) then exit 1 - -// ---------------------------------------- - -let isRecord1 x = - match x with - | { - label1 = 0; - label2 = 1; - } -> true - | _ -> false - -let isRecord2 x = - match x with - | { label1 = 2; label2 = 3; } -> true - | _ -> false - - -if not (isRecord1 record1) then exit 1 -if not (isRecord2 record2) then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Array/arrayMatch01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Array/arrayMatch01.fs deleted file mode 100644 index 3aa935b7a70..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Array/arrayMatch01.fs +++ /dev/null @@ -1,18 +0,0 @@ -// #Conformance #PatternMatching #Arrays -#light - -// Verify ability to match against arrays - -let test x = - match x with - | [| 1 |] -> 1 - | [| 1; 2 |] -> 2 - | [| 1; 2; 3 |] -> 3 - | _ -> -1 - - -if test [| 1 |] <> 1 then exit 1 -if test [| 1; 2 |] <> 2 then exit 1 -if test [| 1; 2; 3 |] <> 3 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Array/arrayMatch02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Array/arrayMatch02.fs deleted file mode 100644 index f41bfa698d4..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Array/arrayMatch02.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #Conformance #PatternMatching #Arrays -#light - -// Verify ability to match against empty arrays -let isEmpty x = - match x with - | [| |] -> true - | _ -> false - -if isEmpty [| |] <> true then exit 1 -if isEmpty [| 1 .. 10 |] <> false then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Array/arrayMatch03.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Array/arrayMatch03.fs deleted file mode 100644 index b22696f27ee..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Array/arrayMatch03.fs +++ /dev/null @@ -1,16 +0,0 @@ -// #Conformance #PatternMatching #Arrays -#light - -// Verify ability to match against null arrays - -let isNull x = - match x with - | [| |] -> false - | null -> true - | _ -> false - -if isNull [| |] <> false then exit 1 -if isNull [| 1 .. 10 |] <> false then exit 1 -if isNull null <> true then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Array/env.lst b/tests/fsharpqa/Source/Conformance/PatternMatching/Array/env.lst deleted file mode 100644 index af0497ed76f..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Array/env.lst +++ /dev/null @@ -1,5 +0,0 @@ - SOURCE="arrayMatch01.fs" # ArrayMatch01 - SOURCE="arrayMatch02.fs" # ArrayMatch02 - SOURCE="arrayMatch03.fs" # ArrayMatch03 - - SOURCE="TrailingSemi01.fs" # TrailingSemi01 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/As/asPattern01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/As/asPattern01.fs deleted file mode 100644 index a21ff5850b5..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/As/asPattern01.fs +++ /dev/null @@ -1,11 +0,0 @@ -// #Conformance #PatternMatching -#light - -let t1 = (1, 2) -let (x, y) as asPatResult = t1 - -if x <> 1 then exit 1 -if y <> 2 then exit 1 -if asPatResult <> (1, 2) then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/As/asPattern02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/As/asPattern02.fs deleted file mode 100644 index 6ed1a381e52..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/As/asPattern02.fs +++ /dev/null @@ -1,20 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Verify 'as pattern' construct - -let test x = - match x with - | (1, _) | (_, 2) as result - -> if fst result <> 1 && - snd result <> 2 then - false - else - true - | _ -> false - -if test (1, 0) <> true then exit 1 -if test (0, 2) <> true then exit 1 -if test (3, 3) <> false then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/As/env.lst b/tests/fsharpqa/Source/Conformance/PatternMatching/As/env.lst deleted file mode 100644 index 3e158fa9c48..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/As/env.lst +++ /dev/null @@ -1,2 +0,0 @@ - SOURCE="asPattern01.fs" # AsPattern01 - SOURCE="asPattern02.fs" # AsPattern02 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/E_consOnNonList.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/E_consOnNonList.fs deleted file mode 100644 index b7ce650ebd6..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/E_consOnNonList.fs +++ /dev/null @@ -1,7 +0,0 @@ -// #Regression #Conformance #PatternMatching -//This expression was expected to have type. 'int' .but here has type. ''a list' -let f (x : int) = match x with - | _ :: [] -> 1 - | _ :: _ :: [] -> 2 - | _ -> 0 - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/E_consPattern01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/E_consPattern01.fs deleted file mode 100644 index 26e6aff27b4..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/E_consPattern01.fs +++ /dev/null @@ -1,17 +0,0 @@ -// #Regression #Conformance #PatternMatching -//This expression was expected to have type. 'int' .but here has type. ''a list' -// Verify that a '[]' is only valid at the end of a list in a cons pattern -// This is OK. Type inference will pick up that this x is a generic list of lists. - -let test x = - match x with - | firstele :: secondele :: thirdele :: fourthele -> 0//firstele + secondele - | firstele :: [] :: thirdele -> 0//first + thirdele - | _ -> 0 - -let test2 (x : int list) = - match x with - | fst :: snd :: tail -> fst + snd - | lastElement :: [] :: [] -> 0 - | fst :: [] :: tail -> failwith "Shouldn't get here." - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/OutsideMatch01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/OutsideMatch01.fs deleted file mode 100644 index bff09153aa7..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/OutsideMatch01.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Verify pattern matching on lists outside of a patch statement - -let a :: b :: c = [1; 2; 3] - -if a <> 1 then exit 1 -if b <> 2 then exit 1 -if c <> [3] then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/consPattern01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/consPattern01.fs deleted file mode 100644 index c752b680855..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/consPattern01.fs +++ /dev/null @@ -1,17 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Verify that [] works at the end of a list -let rec lengthOf x = - match x with - | [] -> 0 - | _ :: [] -> 1 - | _ :: _ :: [] -> 2 - | hd :: tail -> 1 + lengthOf tail - -if lengthOf [] <> 0 then exit 1 -if lengthOf [1] <> 1 then exit 1 -if lengthOf [1;2] <> 2 then exit 1 -if lengthOf [1..10] <> 10 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/env.lst b/tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/env.lst deleted file mode 100644 index a5920b6ae4f..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/ConsList/env.lst +++ /dev/null @@ -1,6 +0,0 @@ - SOURCE=consPattern01.fs # consPattern01.fs - - SOURCE=E_consPattern01.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_consPattern01.fs - SOURCE=E_consOnNonList.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_consOnNonList.fs - - SOURCE=OutsideMatch01.fs # OutsideMatch01.fs diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/ArrayTypeTest01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/ArrayTypeTest01.fs deleted file mode 100644 index aac4071fbc9..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/ArrayTypeTest01.fs +++ /dev/null @@ -1,16 +0,0 @@ -// #Conformance #PatternMatching #TypeTests -#light - -// Verify ability to specify an integer array in a dynamic type test - -let isIntArray (o: obj) = - match o with - | :? (int[]) -> 1 - | :? (string array) -> 2 - | _ -> 3 - -if isIntArray (box [| 0; 1 |]) <> 1 then exit 1 -if isIntArray (box [| "xx" |]) <> 2 then exit 1 -if isIntArray (box [1 .. 100]) <> 3 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/E_DynamTyTestVarType01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/E_DynamTyTestVarType01.fs deleted file mode 100644 index bb9698f08c5..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/E_DynamTyTestVarType01.fs +++ /dev/null @@ -1,15 +0,0 @@ -// #Regression #Conformance #PatternMatching #TypeTests -#light - -// Verify error associated with doing a dynamic type -// test on a variable type. - -//This runtime coercion or type test from type - -// Error, x has type 'a and cannot be used in a dynamic type test. -let f x = - match x with - | :? obj as o -> true - | _ -> false - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/E_DynamicTestPrimType01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/E_DynamicTestPrimType01.fs deleted file mode 100644 index 08240f6da0e..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/E_DynamicTestPrimType01.fs +++ /dev/null @@ -1,14 +0,0 @@ -// #Regression #Conformance #PatternMatching #TypeTests -#light - -// Verify error when using a dynamic type test on -// type without any proper sub types. - -//The type 'int' does not have any proper subtypes and cannot be used as the source of a type test or runtime coercion - -let test (x : int) = - match x with - | :? float -> false - | _ -> false - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/Regression01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/Regression01.fs deleted file mode 100644 index 7c3c7bc0d8e..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/Regression01.fs +++ /dev/null @@ -1,27 +0,0 @@ -// #Conformance #PatternMatching #TypeTests -// - -type Foo () = class end - -type Bar () = - inherit Foo() - -let instOfBox = box <| Bar() - -let test1() = - match true, instOfBox with - | false, :? Bar -> 1 // Shouldn't match, true <> false - | _, :? Foo -> 2 // Should return 2 - | _ -> 3 // Unexplored - -let test2() = - match instOfBox, true with - | :? Bar, false -> 1 // Shouldn't match, false <> true - | :? Foo, _ -> 2 // Should return 2 - | _ -> 3 // Unexplored - - -if test1() <> 2 then exit 1 -if test2() <> 2 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/Regression02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/Regression02.fs deleted file mode 100644 index 25d35db2165..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/Regression02.fs +++ /dev/null @@ -1,18 +0,0 @@ -// #Conformance #PatternMatching #TypeTests -#light - -// Verify you can use a dynamic type test against unit - -let isUnit (x : obj) = - match x with - | :? unit -> true - | _ -> false - - -let test1 = isUnit (box ()) -let test2 = isUnit (box 42) - -if test1 <> true then exit 1 -if test2 <> false then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/TwoAtOnce01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/TwoAtOnce01.fs deleted file mode 100644 index 5c8e984ee7e..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/TwoAtOnce01.fs +++ /dev/null @@ -1,33 +0,0 @@ -// #Conformance #PatternMatching #TypeTests -#light - -// Perform multiple dynamic type tests at once - -let printCode x y = - match box x, box y with - | (:? int as ix), (:? int as iy) - -> sprintf "%d-%d" ix iy - | (:? string as sx), (:? string as sy) - -> sprintf "%s-%s" sx sy - | (:? int as ix), (:? string as sy) - -> sprintf "%d-%s" ix sy - | (:? string as sx), (:? int as iy) - -> sprintf "%s-%d" sx iy - | _ -> "" - -let test1 = printCode 1 2 -if test1 <> "1-2" then exit 1 - -let test2 = printCode "foo" "baz" -if test2 <> "foo-baz" then exit 1 - -let test3 = printCode 4 "aire" -if test3 <> "4-aire" then exit 1 - -let test4 = printCode "Z" 26 -if test4 <> "Z-26" then exit 1 - -let test5 = printCode 'a' 1 -if test5 <> "" then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/W_RedundantPattern01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/W_RedundantPattern01.fs deleted file mode 100644 index 5b31ed91546..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/W_RedundantPattern01.fs +++ /dev/null @@ -1,21 +0,0 @@ -// #Regression #Conformance #PatternMatching #TypeTests -#light - -// FSB 1488, Implement redundancy checking for dynamic type test patterns - -//This rule will never be matched -//This rule will never be matched - -let _ = - match box "3" with - | :? string -> 1 - | :? string -> 1 // check this rule is marked as 'never be matched' - | _ -> 2 - -let _ = - match box "3" with - | :? System.IComparable -> 1 - | :? string -> 1 // check this rule is marked as 'never be matched' - | _ -> 2 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/W_TypeTestWillAlwaysHold01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/W_TypeTestWillAlwaysHold01.fs deleted file mode 100644 index b4e8e83a785..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/W_TypeTestWillAlwaysHold01.fs +++ /dev/null @@ -1,17 +0,0 @@ -// #Regression #Conformance #PatternMatching #TypeTests -#light - -// Verify warning for when dynamic type test will always hold. -//This type test or downcast will always hold - - -type Foo() = - member this.Value = 42 - -let test (x : Foo) = - match x with - | :? Foo as xAsInt -> false - | _ -> false - - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynTestSealedType01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynTestSealedType01.fs deleted file mode 100644 index 1128961fc6c..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynTestSealedType01.fs +++ /dev/null @@ -1,27 +0,0 @@ -// #Conformance #PatternMatching #TypeTests -#light - -// Verify result of dynamic type test on sealed type. - -type Foo() = - member this.FooValue = 42 - -[] -type Bar() = - inherit Foo() - member this.BarValue = 42 - - -let test (x : obj) = - match x with - | :? Bar -> 2 - | :? Foo -> 1 - | _ -> 3 - -let foo = new Foo() -let bar = new Bar() - -if test (foo :> obj) <> 1 then exit 1 -if test (bar :> obj) <> 2 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest01.fs deleted file mode 100644 index e618196f7a4..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest01.fs +++ /dev/null @@ -1,27 +0,0 @@ -// #Conformance #PatternMatching #TypeTests -#light - -open System - -// Verify "If present the identifier after as is bound to the value coerced to the given type." -let testException (ex : obj) = - let orgType = ex.GetType().ToString() - match ex with - | :? System.NotSupportedException as dynamicType -> - let typeStr = dynamicType.GetType().ToString() - if typeStr <> orgType then - false - else - true - | :? System.Exception as dynamicType -> - let typeStr = dynamicType.GetType().ToString() - if typeStr <> orgType then - false - else - true - | _ -> false - -if testException (new ArgumentException("") :> obj) <> true then exit 1 -if testException (new NotSupportedException("") :> obj) <> true then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest02.fs deleted file mode 100644 index 1566b387920..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest02.fs +++ /dev/null @@ -1,45 +0,0 @@ -// #Conformance #PatternMatching #TypeTests -#light - -open System - -type Shape() = - abstract VirtMember : unit -> string - default this.VirtMember () = "shape" - member this.StaticMember() = "shape" - -type Ellipse() = - inherit Shape() - override this.VirtMember() = "ellipse" - member this.StaticMember() = "ellipse" - -type Circle() = - inherit Shape() - override this.VirtMember() = "circle" - member this.StaticMember() = "circle" - -let test1 (x:obj) = - match x with - | :? Circle -> 1 - | :? Ellipse -> 2 - | :? Shape -> 3 - | _ -> 4 - -let test2 (x:obj) = - match x with - | :? Shape -> 1 - | :? Ellipse -> 2 - | :? Circle -> 3 - | _ -> 4 - -if test1 (new Circle() :> obj) <> 1 then exit 1 -if test1 (new Ellipse() :> obj) <> 2 then exit 1 -if test1 (new Shape() :> obj) <> 3 then exit 1 -if test1 ("foo" :> obj) <> 4 then exit 1 - -if test2 (new Circle() :> obj) <> 1 then exit 1 -if test2 (new Ellipse() :> obj) <> 1 then exit 1 -if test2 (new Shape() :> obj) <> 1 then exit 1 -if test2 ("foo" :> obj) <> 4 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest03.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest03.fs deleted file mode 100644 index 46cfe11da48..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest03.fs +++ /dev/null @@ -1,63 +0,0 @@ -// #Regression #Conformance #PatternMatching #TypeTests -// FSB 1034, Downcasting for interface types -// This test verifies that dynamic type test patterns work on objects which cannot -// statically be checked if they implement the interface. (For example, A implements IFoo and IBar -// dynamically checking if an instance of (A :> IFoo) implements IBar. - -// NB. Years hard coded to avoid introducing non-determinism -type IAge = interface - abstract Age : int - end - -type IAges = interface - abstract GrowOlder : int -> unit - end - -type Car(modelYear : int) = - let mutable m_miles = 0 - let Odometer = m_miles - - interface IAge with - member this.Age = 2008 - modelYear - interface IAges with - member this.GrowOlder x = m_miles <- m_miles + x - -type Person(yearBorn : int) = - let mutable m_yearsOld = 2008 - yearBorn - - interface IAge with - member this.Age = m_yearsOld - - interface IAges with - member this.GrowOlder x = m_yearsOld <- m_yearsOld + x - -type Wine(year : int) = - interface IAge with - member this.Age = year - -// Variables -let me = new Person(1982) -let myCar = new Car(2005) -let myWine = new Wine(1) - -let myStuff = [ (myWine :> IAge); (me :> IAge); (myCar :> IAge) ] - -// Functions -let totalAge (iAgeList : IAge list) = iAgeList |> List.map (fun iage -> iage.Age) |> List.sum - -let rec ageOneYear (l:IAge list) = - match l with - | (:? IAges as agingThing) :: tl -> agingThing.GrowOlder 1 - ageOneYear tl - | hd :: tl -> ageOneYear tl - | [] -> () - -// Tests -if totalAge myStuff <> 30 then exit 1 - -ageOneYear myStuff -// (In this test, wine doesn't age, and cars 'grow older' doesn't incement age') -if totalAge myStuff <> 31 then exit 2 - -exit 0 - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest04.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest04.fs deleted file mode 100644 index 9cc6748b093..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/dynamicTypeTest04.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Conformance #PatternMatching #TypeTests -#light - -let mutable testPassed = false -try - raise (System.Exception("")) -with - | :? _ -> testPassed <- true - -if testPassed <> true then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/env.lst b/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/env.lst deleted file mode 100644 index b16bb25ba59..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/env.lst +++ /dev/null @@ -1,19 +0,0 @@ - SOURCE=dynamicTypeTest01.fs # dynamicTypeTest01.fs - SOURCE=dynamicTypeTest02.fs # dynamicTypeTest02.fs - SOURCE=dynamicTypeTest03.fs # dynamicTypeTest03.fs - SOURCE=dynamicTypeTest04.fs # dynamicTypeTest04.fs - - SOURCE=W_RedundantPattern01.fs # W_RedundantPattern01.fs - SOURCE=W_TypeTestWillAlwaysHold01.fs # W_TypeTestWillAlwaysHold01.fs - - SOURCE=ArrayTypeTest01.fs # ArrayTypeTest01.fs - - SOURCE=dynTestSealedType01.fs # dynTestSealedType01.fs - SOURCE=E_DynamicTestPrimType01.fs # E_DynamicTestPrimType01.fs - - SOURCE=genericType01.fs # genericType01.fs - - SOURCE=E_DynamTyTestVarType01.fs # E_DynamTyTestVarType01.fs - - SOURCE=Regression01.fs # Regression01.fs - SOURCE=TwoAtOnce01.fs # TwoAtOnce01.fs diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/genericType01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/genericType01.fs deleted file mode 100644 index df44c954dd0..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/DynamicTypeTest/genericType01.fs +++ /dev/null @@ -1,16 +0,0 @@ -// #Conformance #PatternMatching #TypeTests -#light - -let listOfWhat (x : 'a list) = - match box x with - | :? List -> "int list" - | :? List -> "string list" - | :? List -> "obj list" - | _ -> "unknown" - -if listOfWhat ["foo"] <> "string list" then exit 1 -if listOfWhat [1 .. 10] <> "int list" then exit 2 -if listOfWhat [([]:>obj)] <> "obj list" then exit 3 -if listOfWhat [ ] <> "obj list" then exit 4 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/E_CounterExample01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/E_CounterExample01.fs deleted file mode 100644 index a21c10ff946..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/E_CounterExample01.fs +++ /dev/null @@ -1,9 +0,0 @@ -// #Regression #Conformance #PatternMatching - // Regression test for FSHARP1.0:2034 -//Incomplete pattern matches on this expression\. For example, the value '0' may indicate a case not covered by the pattern\(s\) - -module TestModule -let f x = - match x with // warning FS0025: Incomplete pattern matches on this expression. For example, the value '0' may indicate a case not covered by the pattern(s) - | 1 -> 7 - | 2 -> 49 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/NoCounterExampleTryWith01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/NoCounterExampleTryWith01.fs deleted file mode 100644 index 920200ca911..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/NoCounterExampleTryWith01.fs +++ /dev/null @@ -1,25 +0,0 @@ -// #Regression #Conformance #PatternMatching -// Regression test for DevDiv:198999 ("Warning messages for incomplete matches involving enum types are wrong") -// Not really regression tests for the bug, but these 2 cases cover code that was touched -// - -module M - -// Unterminated try-with -let h1 = - try - () - raise (new System.NotImplementedException()) - with - | :? System.NotFiniteNumberException -> () - -// Unterminated try-with in a computation expr -let a = - async { - try - () - raise (new System.NotImplementedException()) - with - | :? System.NotFiniteNumberException -> () - } - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/W_CounterExampleWithEnum01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/W_CounterExampleWithEnum01.fs deleted file mode 100644 index 0a9a8c17b4e..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/W_CounterExampleWithEnum01.fs +++ /dev/null @@ -1,36 +0,0 @@ -// #Regression #Conformance #PatternMatching -// Regression test for DevDiv:198999 ("Warning messages for incomplete matches involving enum types are wrong") -//Incomplete pattern matches on this expression\. For example, the value '"a"' may indicate a case not covered by the pattern\(s\)\.$ -//Incomplete pattern matches on this expression\. For example, the value '0\.0' may indicate a case not covered by the pattern\(s\)\.$ -//Incomplete pattern matches on this expression\. For example, the value '' '' may indicate a case not covered by the pattern\(s\)\.$ -//Incomplete pattern matches on this expression\. For example, the value '1y' may indicate a case not covered by the pattern\(s\)\.$ -//Incomplete pattern matches on this expression\. For example, the value '\[_;_;_\]' may indicate a case not covered by the pattern\(s\)\.$ -//Incomplete pattern matches on this expression\. For example, the value '\[|_; 1|\]' may indicate a case not covered by the pattern\(s\)\.$ - -module M - -type T = | X = 0 | Y = 1 - -let f1 = function - | "X" -> T.X - | "Y" -> T.Y - -let f2 = function - | 1. -> T.X - | 2. -> T.Y - -let f3 = function - | 'a' -> T.X - | 'b' -> T.Y - -let f4 = function - | 0y -> T.X - | 2y -> T.Y - -let f5 = function - | [1 ; 2] -> T.X - | [_] -> T.Y - -let f6 = function - | [|1 ; 2|] -> T.X - | [|_;0|] -> T.Y diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/W_CounterExampleWithEnum02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/W_CounterExampleWithEnum02.fs deleted file mode 100644 index f93dab37adb..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/W_CounterExampleWithEnum02.fs +++ /dev/null @@ -1,32 +0,0 @@ -// #Regression #Conformance #PatternMatching -// Regression test for DevDiv:198999 ("Warning messages for incomplete matches involving enum types are wrong") -//Enums may take values outside known cases\. For example, the value 'enum \(2\)' may indicate a case not covered by the pattern\(s\)\.$ -//Incomplete pattern matches on this expression\. For example, the value 'T.Y' may indicate a case not covered by the pattern\(s\)\.$ -//Incomplete pattern matches on this expression\. For example, the value 'T.Y' may indicate a case not covered by the pattern\(s\)\.$ -//Incomplete pattern matches on this expression\. For example, the value 'T.Y' may indicate a case not covered by the pattern\(s\)\.$ -//Incomplete pattern matches on this expression\. For example, the value 'T.Y' may indicate a case not covered by the pattern\(s\)\.$ -//Incomplete pattern matches on this expression\. For example, the value 'T.Y' may indicate a case not covered by the pattern\(s\)\.$ - -module M - -type T = | X = 0 | Y = 1 - -let g1 = function - | T.X -> "X" - | T.Y -> "y" - -let g2 = function - | T.X -> 1. - -let g3 = function - | T.X -> 'a' - -let g4 = function - | T.X -> 2y - -let g5 = function - | T.X -> [1 ; 2] - -let g6 = function - | T.X -> [|1 ; 2|] - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/W_whenGuards01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/W_whenGuards01.fs deleted file mode 100644 index bba3809ea50..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/W_whenGuards01.fs +++ /dev/null @@ -1,16 +0,0 @@ -// #Regression #Conformance #PatternMatching -module TestModule - -// Regression testcase for FSharp 1.0: 2070 -// Warn on incomplete match with when guard - -//Incomplete pattern matches on this expression\. For example, the value '1' may indicate a case not covered by the pattern\(s\)\. However, a pattern rule with a 'when' clause might successfully match this value - - -let matchWarning s = - match s with - | 0 -> true - | n when n>0 -> false - -exit 0 - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/env.lst b/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/env.lst deleted file mode 100644 index f47979b8793..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/env.lst +++ /dev/null @@ -1,14 +0,0 @@ - SOURCE=E_CounterExample01.fs SCFLAGS="--test:ErrorRanges -a" # E_CounterExample01.fs - SOURCE=W_whenGuards01.fs SCFLAGS="--test:ErrorRanges -a" # W_whenGuards01.fs - - SOURCE=NoCounterExampleTryWith01.fs SCFLAGS="--test:ErrorRanges -a" # NoCounterExampleTryWith01.fs - SOURCE=W_CounterExampleWithEnum01.fs SCFLAGS="--test:ErrorRanges -a" # W_CounterExampleWithEnum01.fs - SOURCE=W_CounterExampleWithEnum02.fs SCFLAGS="--test:ErrorRanges -a" # W_CounterExampleWithEnum02.fs - - SOURCE=patterns01.fs # patterns01.fs - SOURCE=patterns02.fs # patterns02.fs - SOURCE=whenGuards01.fs # whenGuards01.fs - SOURCE=whenGuards02.fs # whenGuards02.fs - SOURCE=whenGuardss01.fs # whenGuardss01.fs - SOURCE=whenGuardss02.fs # whenGuardss02.fs - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/patterns01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/patterns01.fs deleted file mode 100644 index 92e27717e82..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/patterns01.fs +++ /dev/null @@ -1,18 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Verify the first verticle bar in a pattern match is optinal. - -let test1 x = match x with "0" -> 0 | "1" -> 1 | _ -> -1 - -let test2 x = - match x with - "0" -> 0 - | "1" -> 1 - | _ -> -1 - -if (test1 "0") <> (test2 "0") then exit 1 -if (test1 "1") <> (test2 "1") then exit 1 -if (test1 "2") <> (test2 "2") then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/patterns02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/patterns02.fs deleted file mode 100644 index a8ebbe39689..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/patterns02.fs +++ /dev/null @@ -1,16 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Verify ability to match just a single identifier - -let testTrue x = match x with true -> true -let test42 x = match x with 42 -> true -let testEven (x : string) = match x with _ when x.Length % 2 = 0 -> true -let identity x = match x with y -> y - -if (testTrue true) <> true then exit 1 -if (test42 42) <> true then exit 1 -if (testEven "aabbcc") <> true then exit 1 -if (identity ("apple", "ORANGE")) <> ("apple", "ORANGE") then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/whenGuards01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/whenGuards01.fs deleted file mode 100644 index d14f4fa3b0b..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/whenGuards01.fs +++ /dev/null @@ -1,37 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Test that when guards only execute once the match value has -// matched the pattern associated with the rule. - -let mutable m_flag = 0 -let flagSet() = m_flag = 1 -let resetFlag() = m_flag <- 0 - -let testMatch x = - match x with - | 1 when (m_flag <- 1; true) -> 1 - | 2 when (m_flag <- 1; false) -> 2 - | _ -> 0 - - -// 0 should hit the wildcard, and testMatch should return 0 -resetFlag() -if testMatch 0 <> 0 then exit 1 -if flagSet() then exit 1 - -// 1 should have been matched, setting the flag to true -// and with the where guard succeeding, the match statement -// returned 1 as well. -resetFlag() -if testMatch 1 <> 1 then exit 1 -if not (flagSet()) then exit 1 - -// 2 should have been matched, setting the flat to true -// but, since the where guard failed, the match statement -// hit the wild card- returning 0 -resetFlag() -if testMatch 2 <> 0 then exit 1 -if not (flagSet()) then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/whenGuards02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/whenGuards02.fs deleted file mode 100644 index 530ed514f06..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/whenGuards02.fs +++ /dev/null @@ -1,20 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Verify that if the when guard fails, that pattern is not matched. - -let complexXOR x y = - match x with - | true when not y -> true - | false when y -> true - | true when y -> false - | false when not y -> false - | _ -> failwith "not possible" - -let simpleXOR x y = x <> y - -let runTest (x, y) = if complexXOR x y <> simpleXOR x y then exit 1 -let testSuite = [(true, true); (true, false); (false, true); (false, false)] -List.iter runTest testSuite - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/whenGuardss01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/whenGuardss01.fs deleted file mode 100644 index d14f4fa3b0b..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/whenGuardss01.fs +++ /dev/null @@ -1,37 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Test that when guards only execute once the match value has -// matched the pattern associated with the rule. - -let mutable m_flag = 0 -let flagSet() = m_flag = 1 -let resetFlag() = m_flag <- 0 - -let testMatch x = - match x with - | 1 when (m_flag <- 1; true) -> 1 - | 2 when (m_flag <- 1; false) -> 2 - | _ -> 0 - - -// 0 should hit the wildcard, and testMatch should return 0 -resetFlag() -if testMatch 0 <> 0 then exit 1 -if flagSet() then exit 1 - -// 1 should have been matched, setting the flag to true -// and with the where guard succeeding, the match statement -// returned 1 as well. -resetFlag() -if testMatch 1 <> 1 then exit 1 -if not (flagSet()) then exit 1 - -// 2 should have been matched, setting the flat to true -// but, since the where guard failed, the match statement -// hit the wild card- returning 0 -resetFlag() -if testMatch 2 <> 0 then exit 1 -if not (flagSet()) then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/whenGuardss02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/whenGuardss02.fs deleted file mode 100644 index 530ed514f06..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Expression/whenGuardss02.fs +++ /dev/null @@ -1,20 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Verify that if the when guard fails, that pattern is not matched. - -let complexXOR x y = - match x with - | true when not y -> true - | false when y -> true - | true when y -> false - | false when not y -> false - | _ -> failwith "not possible" - -let simpleXOR x y = x <> y - -let runTest (x, y) = if complexXOR x y <> simpleXOR x y then exit 1 -let testSuite = [(true, true); (true, false); (false, true); (false, false)] -List.iter runTest testSuite - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/ActivePatternOutsideMatch01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/ActivePatternOutsideMatch01.fs deleted file mode 100644 index a33f0d712b7..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/ActivePatternOutsideMatch01.fs +++ /dev/null @@ -1,20 +0,0 @@ -// #Conformance #PatternMatching #ActivePatterns -// Verify active patterns can be used outside of a match statement - -// This is really needed to make sure the test runs fine on non-ENU boxes! -// ToString() may use , or . or whatever symbols is defined for the floating point -System.Threading.Thread.CurrentThread.CurrentCulture <- System.Globalization.CultureInfo.InvariantCulture - -let (|ToString|) (x : decimal) = x.ToString() - -let (ToString test1) = 1234.56789M -if test1 <> "1234.56789" then exit 1 - -// Test nesting outside of match statements -let (|ToFloat|) (x : string) = System.Double.Parse(x) - -// decimal -> string -> float -let (ToString (ToFloat test2)) = 1234.56789M -if test2 <> 1234.56789 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/ActivePatternOutsideMatch02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/ActivePatternOutsideMatch02.fs deleted file mode 100644 index 3dd34ab58a0..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/ActivePatternOutsideMatch02.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #Conformance #PatternMatching #ActivePatterns -#light - -// Verify active patterns outside of match statement -// where active pattern defines a function. (Regression.) - -let (|ApplyTwice|) (x : int -> int) = x >> x - -let (ApplyTwice result) = fun x -> x * x - -if result 2 <> 2 * 2 * 2 * 2 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/ActivePatternUnconstrained01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/ActivePatternUnconstrained01.fs deleted file mode 100644 index 40d9a92b90d..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/ActivePatternUnconstrained01.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for FSHARP1.0:5590 -// Note that the real test is E_ActivePatternUnconstrained01.fs -// This ones shows just one way to make the code compile again - -let (|A1|A2|A3|) (inp:int) : Choice = - printfn "hello" - printfn "hello" - A1 - -let f2 x = match x with A1 -> 1 | A2 -> 2 | A3 -> 3 - -f2 3 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/AsHighOrderFunc01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/AsHighOrderFunc01.fs deleted file mode 100644 index a153b48a2f3..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/AsHighOrderFunc01.fs +++ /dev/null @@ -1,34 +0,0 @@ -// #Conformance #PatternMatching #ActivePatterns -#light - -// Verify ability to treat active patterns like higher-order functions - -// Single Case -let (|ToString|) (x : obj) = x.ToString() - -let sc = (|ToString|) -if sc 42 <> "42" then exit 1 - -// Multi Case -let rec (|Odd|Even|) x = - match x with - | 0 -> Even - | 1 -> Odd - | _ -> match x - 1 with - | Even -> Odd - | Odd -> Even - -let mc = (|Odd|Even|) - -let _ = match mc 3, mc 4 with - | Choice1Of2(_), Choice2Of2(_) -> () - | _ -> exit 1 - -// Partial -let (|IsThree|_|) x = if x = 3 then Some() else None - -let pap = (|IsThree|_|) -if pap 4 <> None then exit 1 -if pap 3 <> Some() then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatternHasNoFields.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatternHasNoFields.fs deleted file mode 100644 index 9d323f7b4e0..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatternHasNoFields.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for https://github.com/Microsoft/visualfsharp/issues/5745 -//Active patterns do not have fields. This syntax is invalid\. -open System.Text.RegularExpressions - -let (|USZipPlus4Code|_|) s = - let m = Regex.Match(s, @"^(\d{5})\-(\d{4})$") - if m.Success then - USZipPlus4Code(x=m.Groups.[1].Value, - y=m.Groups.[2].Value) - |> Some - else - None diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatternNotAFuncion.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatternNotAFuncion.fs deleted file mode 100644 index aa1ff9f0165..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatternNotAFuncion.fs +++ /dev/null @@ -1,5 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for FSHARP1.0:5590 -//Active pattern '|A|B|' is not a function$ - -let (|A|B|) = failwith "" : Choice diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatternUnconstrained01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatternUnconstrained01.fs deleted file mode 100644 index 86e8689d061..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatternUnconstrained01.fs +++ /dev/null @@ -1,14 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for FSHARP1.0:5590 -// This code used to compile, but fail peverification -// Now, it just does not compile anymore telling the user to annotated it a bit. -//The result of this expression has type 'int' and is implicitly ignored\. Consider using 'ignore' to discard this value explicitly, e\.g\. 'expr \|> ignore', or 'let' to bind the result to a name, e\.g\. 'let result = expr'.$ -//Active pattern '\|A1\|A2\|A3\|' has a result type containing type variables that are not determined by the input\. The common cause is a when a result case is not mentioned, e\.g\. 'let \(\|A\|B\|\) \(x:int\) = A x'\. This can be fixed with a type constraint, e\.g\. 'let \(\|A\|B\|\) \(x:int\) : Choice = A x'$ -let (|A1|A2|A3|) (inp:int) : Choice = - printfn "hello" - printfn "hello" - A1 - -let f2 x = match x with A1 -> 1 | A2 -> 2 | A3 -> 3 - -f2 3 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatterns01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatterns01.fs deleted file mode 100644 index 19bf8faee6c..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatterns01.fs +++ /dev/null @@ -1,20 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Verify error if Active Patterns do not start with an upper case letter -//Active pattern case identifiers must begin with an uppercase letter -//Active pattern case identifiers must begin with an uppercase letter -//Active pattern case identifiers must begin with an uppercase letter -//Active pattern case identifiers must begin with an uppercase letter -//Active pattern case identifiers must begin with an uppercase letter -//The '\|' character is not permitted in active pattern case identifiers -//The '\|' character is not permitted in active pattern case identifiers -//Active pattern case identifiers must begin with an uppercase letter - -let (|positive|negative|) n = if n < 0 then positive else negative -let (|`` A``|) (x:int) = x -let (|B1|``+B2``|) (x:int) = if x = 0 then OneA else ``+B2`` -let (|`` C``|_|) (x:int) = if x = 0 then Some(x) else None -let (|``D|E``|F|) (x:int) = if x = 0 then D elif x = 1 then E else F -let (|G|``H||I``|) (x:int) = if x = 0 then G elif x = 1 then H else ``|I`` -let (|_J|) (x:int) = _J - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatterns02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatterns02.fs deleted file mode 100644 index 50273c1058f..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ActivePatterns02.fs +++ /dev/null @@ -1,8 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Verify error if Active Patterns used with named parameters -//A is an active pattern and cannot be treated as a discriminated union case with named fields. - -let (|A|B|) n = if n%2 = 0 then A n else B n -match 10 with A(hoho=n) -> n | _ -> 0 - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_LetRec01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_LetRec01.fs deleted file mode 100644 index 7269796810b..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_LetRec01.fs +++ /dev/null @@ -1,8 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for FSHARP1.0:4621 -//This expression was expected to have type. 'Choice<'a,'b>' .but here has type. 'string' - -let rec (|Foo|Bar|) (a:int) x = "BAD DOG!" - -exit 1 - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_LetRec02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_LetRec02.fs deleted file mode 100644 index c135beefc1a..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_LetRec02.fs +++ /dev/null @@ -1,4 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for FSHARP1.0:4621 -//This is not a valid name for an active pattern -let rec (|Foo2|Bar2|_|) (a:int) x = "BAD DOG!" diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_LetRec03.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_LetRec03.fs deleted file mode 100644 index e39c8fb59bd..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_LetRec03.fs +++ /dev/null @@ -1,4 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for FSHARP1.0:4621 -//This is not a valid name for an active pattern -let rec (|Foo2b|Bar2b|Baz2b|_|) (a:int) x = "BAD DOG!" diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_LetRec04.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_LetRec04.fs deleted file mode 100644 index 5ed84d6a36e..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_LetRec04.fs +++ /dev/null @@ -1,5 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for FSHARP1.0:4621 -//This expression was expected to have type. ''a option' .but here has type. 'string' -let rec (|Foo3|_|) (a:int) x = "BAD DOG!" - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_NonParam01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_NonParam01.fs deleted file mode 100644 index 25f75485341..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_NonParam01.fs +++ /dev/null @@ -1,5 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for FSHARP1.0:4621 -//This expression was expected to have type. 'Choice<'a,'b>' .but here has type. 'string' -let (|Foo|Bar|) x = "BAD DOG!" - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_NonParam02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_NonParam02.fs deleted file mode 100644 index 1ed1e40e379..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_NonParam02.fs +++ /dev/null @@ -1,4 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for FSHARP1.0:4621 -//This is not a valid name for an active pattern -let (|Foo2|Bar2|_|) x = "BAD DOG!" // expect: invalid name for an active pattern diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_NonParam03.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_NonParam03.fs deleted file mode 100644 index 4387147760d..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_NonParam03.fs +++ /dev/null @@ -1,4 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for FSHARP1.0:4621 -//This is not a valid name for an active pattern -let (|Foo2b|Bar2b|Baz2b|_|) x = "BAD DOG!" // expect: type string doesn't match type 'choice' diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_NonParam04.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_NonParam04.fs deleted file mode 100644 index 0553d6f6892..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_NonParam04.fs +++ /dev/null @@ -1,5 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for FSHARP1.0:4621 -//This expression was expected to have type. ''a option' .but here has type. 'string' -let (|Foo3|_|) x = "BAD DOG!" // expect: type string doesn't match type 'option' - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_Param01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_Param01.fs deleted file mode 100644 index 067d07a46aa..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_Param01.fs +++ /dev/null @@ -1,5 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for FSHARP1.0:4621 -//This expression was expected to have type. 'Choice<'a,'b>' .but here has type. 'string' -let (|Foo|Bar|) (a:int) x = "BAD DOG!" - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_Param02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_Param02.fs deleted file mode 100644 index 74ced64a2ed..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_Param02.fs +++ /dev/null @@ -1,4 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for FSHARP1.0:4621 -//This is not a valid name for an active pattern -let (|Foo2|Bar2|_|) (a:int) x = "BAD DOG!" // expect: invalid name for an active pattern diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_Param03.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_Param03.fs deleted file mode 100644 index 372bde3ce8c..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_Param03.fs +++ /dev/null @@ -1,4 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for FSHARP1.0:4621 -//This is not a valid name for an active pattern -let (|Foo2b|Bar2b|Baz2b|_|) (a:int) x = "BAD DOG!" // expect: type string doesn't match type 'choice' diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_Param04.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_Param04.fs deleted file mode 100644 index 4467425d462..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_Error_Param04.fs +++ /dev/null @@ -1,5 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for FSHARP1.0:4621 -//This expression was expected to have type. ''a option' .but here has type. 'string' -let (|Foo3|_|) (a:int) x = "BAD DOG!" - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_LargeActivePat01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_LargeActivePat01.fs deleted file mode 100644 index d356af71baa..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_LargeActivePat01.fs +++ /dev/null @@ -1,7 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Verify error when defining an Active Pattern with more than seven 'values' -// This is regression test for FSHARP1.0:3562 -//Active patterns cannot return more than 7 possibilities$ - -let (|One|Two|Three|Four|Five|Six|Seven|Eight|) x = One - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_MulticasePartialNotAllowed01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_MulticasePartialNotAllowed01.fs deleted file mode 100644 index f1633373916..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_MulticasePartialNotAllowed01.fs +++ /dev/null @@ -1,24 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Regression test for FSHARP1.0:4621 -// Multi case partial active patterns are not allowed - -//This is not a valid name for an active pattern -//The pattern discriminator 'Sentence' is not defined - -let (|Sentence|Word|Punctuation|WhiteSpace|_|) (input : string) = - if input.Trim() = "" then - Some(WhiteSpace()) - elif input.IndexOf(" ") <> -1 then - Some(Sentence (input.Split([|" "|], System.StringSplitOptions.RemoveEmptyEntries))) - else - match input with - | "." | ";" | "," | ":" | "?" | "!" -> Some(Punctuation(input.ToCharArray().[0])) - | _ -> Some(Word (input)) - -let test str = - match str with - | Sentence words -> words.Length // All words in sentence - | Word word -> word.Length // Characters in word - | WhiteSpace -> 0 - | Punctuation _ -> -1 - | _ -> failwith "Should not happen" diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ParameterRestrictions01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ParameterRestrictions01.fs deleted file mode 100644 index c3e907519e3..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_ParameterRestrictions01.fs +++ /dev/null @@ -1,17 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -#light - -// Verify error cases for restrictions on active pattern parameters. -//Only active patterns returning exactly one result may accept arguments - - -// Multi-Case -let rec (|MCAP|MCAP2|) (times : int) (ip : string) = - match times with - | 0 -> MCAP (ip + "!") - | 1 -> MCAP2(ip + ".") - | x -> (|MCAP|MCAP2|) (times - 1) (ip + "-") - -let _ = match "" with MCAP 0 "!" -> () | _ -> exit 1 - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_PatternMatchRegressions02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_PatternMatchRegressions02.fs deleted file mode 100644 index a20ca0f6fd8..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/E_PatternMatchRegressions02.fs +++ /dev/null @@ -1,33 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// FSHARP1.0:5590 (see also FSHARP1.0:1104, which is where this source came from) -//Incomplete pattern matches on this expression\.$ -//Incomplete pattern matches on this expression\.$ -//Active pattern '\|ClientExternalTypeUse\|WillFail\|' has a result type containing type variables that are not determined by the input\. The common cause is a when a result case is not mentioned, e\.g\. 'let \(\|A\|B\|\) \(x:int\) = A x'\. This can be fixed with a type constraint, e\.g\. 'let \(\|A\|B\|\) \(x:int\) : Choice = A x'$ - -#nowarn "57" - -open System -open System.Collections.Generic -open System.Reflection - -open Microsoft.FSharp.Reflection -open Microsoft.FSharp.Quotations - -let (|MapDeclaringType|_|) (mi:#MemberInfo) : Option = failwith "" -let (|CastToMemberInfo|) (mi:#MemberInfo) = (mi :> MemberInfo) -let (|MethodCall|_|) (e:Expr) : Option = failwith "" -let (|CtorCall|_|) (e:Expr) : Option = failwith "" - -// Error when multicase active patterns result type doesn't correspond to input value -let (|ClientExternalTypeUse|WillFail|) e = - match e with - | (MethodCall(MapDeclaringType(_, CastToMemberInfo(_)), _)) - | (CtorCall(MapDeclaringType(_, CastToMemberInfo(_)), _)) -> - failwith "" - -// Error above doesn't apply for single case active patterns -let (|ClientExternalTypeUse|_|) e = - match e with - | (MethodCall(MapDeclaringType(_, CastToMemberInfo(_)), _)) - | (CtorCall(MapDeclaringType(_, CastToMemberInfo(_)), _)) -> - failwith "" diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/MultiActivePatterns01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/MultiActivePatterns01.fs deleted file mode 100644 index 59b209a258d..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/MultiActivePatterns01.fs +++ /dev/null @@ -1,49 +0,0 @@ -// #Conformance #PatternMatching #ActivePatterns -#light - -// Test ability to spedify multiple active patterns in the same pattern match - -let (|A|_|) x = if x = 'A' then Some() else None -let (|B|_|) x = if x = 'B' then Some() else None -let (|C|_|) x = if x = 'C' then Some() else None -let (|D|_|) x = if x = 'D' then Some() else None -let (|E|_|) x = if x = 'E' then Some() else None -let (|F|_|) x = if x = 'F' then Some() else None -let (|G|_|) x = if x = 'G' then Some() else None -let (|H|_|) x = if x = 'H' then Some() else None -let (|I|_|) x = if x = 'I' then Some() else None -let (|J|_|) x = if x = 'J' then Some() else None -let (|K|_|) x = if x = 'K' then Some() else None -let (|L|_|) x = if x = 'L' then Some() else None -let (|M|_|) x = if x = 'M' then Some() else None -let (|N|_|) x = if x = 'N' then Some() else None -let (|O|_|) x = if x = 'O' then Some() else None -let (|P|_|) x = if x = 'P' then Some() else None -let (|Q|_|) x = if x = 'Q' then Some() else None -let (|R|_|) x = if x = 'R' then Some() else None -let (|S|_|) x = if x = 'S' then Some() else None -let (|T|_|) x = if x = 'T' then Some() else None -let (|U|_|) x = if x = 'U' then Some() else None -let (|V|_|) x = if x = 'V' then Some() else None -let (|W|_|) x = if x = 'W' then Some() else None -let (|X|_|) x = if x = 'X' then Some() else None -let (|Y|_|) x = if x = 'Y' then Some() else None -let (|Z|_|) x = if x = 'Z' then Some() else None - -let isLetter x = - match x with - | A | B | C | D | E - | F | G | H | I | J - | K | L | M | N | O - | P | Q | R | S | T - | U | V | W | X | Y - | Z -> true - | _ -> false - -let nonLetters = ['.'; ';'; '<'; '>'] |> List.map isLetter -let letters = ['A' .. 'Z'] |> List.map isLetter - -nonLetters |> List.iter (fun r -> if r = true then exit 1) -letters |> List.iter (fun r -> if r = false then exit 1) - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/NamedLiteral01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/NamedLiteral01.fs deleted file mode 100644 index 8b3f85e2f21..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/NamedLiteral01.fs +++ /dev/null @@ -1,21 +0,0 @@ -// #Conformance #PatternMatching #ActivePatterns -#light - -// Match against an enum const defined in another assembly -open System - -let isWeekend day = - match day with - | DayOfWeek.Sunday | DayOfWeek.Saturday -> true - | DayOfWeek.Monday | DayOfWeek.Tuesday - | DayOfWeek.Wednesday | DayOfWeek.Thursday - -> false - | DayOfWeek.Friday -> false - | _ -> failwith "Invalid value" - - -if isWeekend DayOfWeek.Saturday <> true then exit 1 - -exit 0 - - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/NamedLiteral02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/NamedLiteral02.fs deleted file mode 100644 index beb5f434d00..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/NamedLiteral02.fs +++ /dev/null @@ -1,58 +0,0 @@ -// #Conformance #PatternMatching #ActivePatterns -#light - -// Verify [] values can be used with active patterns - -[] -let OneHundred = 100 - -let (|ToInt|) (input : string) = System.Int32.Parse(input) - -// Match the result of the active pattern against a literal value. -let test1() = - match " 101 " with - | ToInt OneHundred - -> // If it didn't match the literal, this would capture new - // value 'OneHundred' and this would fire. - exit 1 - | _ -> () - - match " 100 " with - | ToInt OneHundred - -> () - | _ -> exit 1 - - () - -// Run the test -test1() - - -// Verify literals (and norma values) can be specified as parameters -let (|ConcatedWith|) (x : string) (y : string) (input : string) = - input + x + y - -[] -let BarLiteral = "bar" - -[] -let BazLiteral = "baz" - -let test2() = - let barValue = "bar" - let bazValue = "baz" - - match "foo" with - | ConcatedWith barValue BazLiteral "foobarbaz" -> () - | ConcatedWith barValue BazLiteral result -> printfn "%s" result; exit 1 - - match "foo" with - | ConcatedWith BarLiteral bazValue "foobarbaz" -> () - | ConcatedWith barValue BazLiteral result -> printfn "%s" result; exit 1 - - () - -// Run the etest -test2() - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/ParamertizedPartialActivePattern01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/ParamertizedPartialActivePattern01.fs deleted file mode 100644 index 896e6dbae8a..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/ParamertizedPartialActivePattern01.fs +++ /dev/null @@ -1,33 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// Verify parameterized partial active patterns which return unit don't force you to -// bind the result. -// FSB 3502 - - -let (|DivisbleByTwo|_|) x = - if x % 2 = 0 - then Some() - else None - -let (|DivisibleByX|_|) x y = - if y % x = 0 - then Some() - else None - -// Without this fix, you'd have to bind the result of 'DivisibleByX' so you'd write DivisibleByX 3 (), which is lame. -let divisibleBy x = - match x with - | DivisbleByTwo & DivisibleByX 3 & DivisibleByX 4 -> [2; 3; 4] - | DivisbleByTwo & DivisibleByX 4 -> [2; 4] - | DivisbleByTwo & DivisibleByX 3 -> [2; 3; ] - - | DivisibleByX 3 & DivisibleByX 4 -> [3; 4] - | DivisibleByX 4 -> [ 4] - | DivisibleByX 3 -> [3; ] - - | _ -> [] - -if divisibleBy 12 <> [2; 3; 4] then exit 1 -if divisibleBy 16 <> [2; 4] then exit 2 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/PatternMatchRegressions01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/PatternMatchRegressions01.fs deleted file mode 100644 index 08c2cd44352..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/PatternMatchRegressions01.fs +++ /dev/null @@ -1,29 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -#light - -// FSB 1103, bad code generation for active patterns from fswebtools example - -#light -#nowarn "57" - -open System -open System.Collections.Generic -open System.Reflection - -open Microsoft.FSharp.Reflection -open Microsoft.FSharp.Quotations - -let (|MapDeclaringType|_|) (mi:#MemberInfo) : Option = failwith "" -let (|CastToMemberInfo|_|) (mi:#MemberInfo) : Option<_> = Some(mi :> MemberInfo) -let (|MethodCall|_|) (e:Expr) : Option = failwith "" -let (|CtorCall|_|) (e:Expr) : Option = failwith "" - -let f e = - match e with - | (MethodCall(MapDeclaringType(_), _)) - | (CtorCall(CastToMemberInfo(_), _)) -> - failwith "" - - -// Origional bug was problem with PEVerify -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/PatternMatchRegressions02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/PatternMatchRegressions02.fs deleted file mode 100644 index 3209496222f..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/PatternMatchRegressions02.fs +++ /dev/null @@ -1,27 +0,0 @@ -// #Regression #Conformance #PatternMatching #ActivePatterns -// FSHARP1.0:1104 -// Bug's title: *** WARNING: basic block at end of method ends without a leave, branch, return or throw. Adding throw -// Note: repro was updated with type annotation after fix for FSHARP1.0:5590 -#nowarn "57" - -open System -open System.Collections.Generic -open System.Reflection - -open Microsoft.FSharp.Reflection -open Microsoft.FSharp.Quotations - -let (|MapDeclaringType|_|) (mi:#MemberInfo) : Option = failwith "" -let (|CastToMemberInfo|) (mi:#MemberInfo) = (mi :> MemberInfo) -let (|MethodCall|_|) (e:Expr) : Option = failwith "" -let (|CtorCall|_|) (e:Expr) : Option = failwith "" - -let (|ClientExternalTypeUse|_|) (e:Expr) : option= - match e with - | (MethodCall(MapDeclaringType(_, CastToMemberInfo(_)), _)) - | (CtorCall(MapDeclaringType(_, CastToMemberInfo(_)), _)) -> - failwith "" - -// Original bug was problem with PEVerify - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/RecursiveActivePats.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/RecursiveActivePats.fs deleted file mode 100644 index ec87e23c68f..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/RecursiveActivePats.fs +++ /dev/null @@ -1,40 +0,0 @@ -// #Conformance #PatternMatching #ActivePatterns -#light - -// Single Case -let rec (|SCAP|) (x : obj) = - match x with - | :? string as sx -> sx + "-TERM" - | x -> (|SCAP|) (x.ToString() + "-AP") - -if (|SCAP|) 5 <> "5-AP-TERM" then exit 1 -let _ = - match "foo" with - | SCAP "foo-TERM" -> () - | _ -> exit 1 - -// Multi-Case -let rec (|MCAP|MCAP2|) (ip : string) = - match ip with - | "..." -> MCAP(ip) - | "!!!" -> MCAP2(ip, ip) - | "test1" -> (|MCAP|MCAP2|) "..." - | "test2" -> (|MCAP|MCAP2|) "!!!" - | _ -> failwith "" - -let _ = match "test1" with MCAP "..." -> () | _ -> exit 1 -let _ = match "test2" with MCAP2 ("!!!", "!!!") -> () | _ -> exit 1 - -// Partial -let rec (|MultOf3|_|) x = - match x with - | _ when x < 0 -> None - | 0 -> Some() - | x -> (|MultOf3|_|) (x - 3) - -let _ = match 3 with MultOf3 -> () | _ -> exit 1 -let _ = match 4 with MultOf3 -> exit 1 | _ -> () -let _ = match 5 with MultOf3 -> exit 1 | _ -> () -let _ = match 6 with MultOf3 -> () | _ -> exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns01.fs deleted file mode 100644 index e68fa05ba1f..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns01.fs +++ /dev/null @@ -1,15 +0,0 @@ -// #Conformance #PatternMatching #ActivePatterns -#light - -// Single case active pattern -let (|Double|) x = (x, x) - -let test x = match x with Double y -> y - -if test (1) <> (1,1) then exit 1 -if test (1,1) <> ((1,1), (1,1)) then exit 1 -if test ((1,1), (1,1)) <> (((1,1), (1,1)), ((1,1), (1,1))) then exit 1 - -exit 0 - - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns02.fs deleted file mode 100644 index dbc68717040..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns02.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #Conformance #PatternMatching #ActivePatterns -#light - -// Multi-case active pattern - -let (|Even|Odd|) x = if x % 2 = 0 then Even else Odd - -let isEven x = match x with Even -> true | Odd -> false - -if isEven 1 <> false then exit 1 -if isEven 2 <> true then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns03.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns03.fs deleted file mode 100644 index 45978a3c9c5..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns03.fs +++ /dev/null @@ -1,18 +0,0 @@ -// #Conformance #PatternMatching #ActivePatterns -#light - -// Single case partial active pattern - -let dayOfWeek = new System.Collections.Generic.List(["Sun"; "Mon"; "Tue"; "Wed"; "Thu"; "Fri"; "Sat"]) - -let (|DayOfWeek|_|) string = if dayOfWeek.IndexOf(string) <> -1 then Some() else None - -let isDayOfWeek x = - match x with - | DayOfWeek -> true - | _ -> false - -if isDayOfWeek("red") <> false then exit 1 -if isDayOfWeek("Fri") <> true then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns05.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns05.fs deleted file mode 100644 index 57c698742b1..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns05.fs +++ /dev/null @@ -1,16 +0,0 @@ -// #Conformance #PatternMatching #ActivePatterns -#light - -open System - -let (|ExceptionMessageLen|) (ex : #Exception) = ex.Message.Length - -let mutable exnLength = 0 - -try - raise (NotImplementedException "1234567890") -with - ExceptionMessageLen len -> exnLength <- len - -if exnLength <> 10 then exit 1 -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns06.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns06.fs deleted file mode 100644 index 70ec818da27..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns06.fs +++ /dev/null @@ -1,3 +0,0 @@ -// #Conformance #PatternMatching #ActivePatterns -#light - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns07.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns07.fs deleted file mode 100644 index 1047c3e02c1..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns07.fs +++ /dev/null @@ -1,48 +0,0 @@ -// #Conformance #PatternMatching #ActivePatterns -#light - -// Verify parameters into active patterns can be anything (as constrained by the pat-param grammar production) -module OtherModule = - type Foo = A of int | B of int - let identifier = 42 - -module ActivePatternTests = - - // Null - let (|StrLen1|) (param : obj) (input : string) = input.Length - let test1 = match "foo" with StrLen1 null 3 -> true | _ -> false - - // Const - let (|StrLen2|) (param : string) (input : string) = input.Length + param.Length - let test2 = match "foo" with StrLen2 "bar" 6 -> true | _ -> false - - let (|StrLen3|) (param : int) (input : string) = input.Length + param - let test3 = match "foo" with StrLen3 7 10 -> true | _ -> false - - // Long-ident - let (|StrLen4|) (param : OtherModule.Foo) (input : string) = let OtherModule.A(value)|OtherModule.B(value) = param in input.Length + value - let test4 = match "foo" with StrLen4 (OtherModule.A(10)) 13 -> true | _ -> false - - // List type - let (|StringLen5|) param (input : string) = (List.length param) + input.Length - let test5 = match "foo" with StringLen5 [(1,1);(2,2)] 5 -> true | _ -> false - - // Tuple type - let (|StringLen6|) (ip1,ip2,ip3) (input : string) = input.Length + ip1 + ip2 + ip3 - let test6 = match "foo" with StringLen6 (1,2,3) 9 -> true | _ -> false - - // Type constraint - // Not valid code - //let (|StringLen7|) (param : obj) (input : string) = input.Length + param.ToString().Length - //let test7 = match "foo" with StringLen7 ("bar" :> obj) 6 -> true | _ -> false - - let (|StringLen8|) (param : 'a list) (input : string) = input.Length + List.length param - let test8 = match "foo" with StringLen8 ([] : int list) 3 -> true | _ -> false - - -// Actual test -open ActivePatternTests - -if not (test1 && test2 && test3 && test4 && test5 && test6 && (*test7 &&*) test8) then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns08.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns08.fs deleted file mode 100644 index 6119dabb2da..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/activePatterns08.fs +++ /dev/null @@ -1,40 +0,0 @@ -// #Conformance #PatternMatching #ActivePatterns -#light - -// Verify able to mix active patterns with 'regular' patterns. - -let (|Odd|Even|) x = if x % 2 = 0 then Even else Odd -let (|MultipleOf2|_|) x = if x % 2 = 0 then Some () else None -let (|MultipleOfN|_|) (n:int) (x:int) = if x % n = 0 then Some () else None - -let test x = - match x with - | MultipleOfN 33 () -> 0 - | Odd & MultipleOfN 5 () -> 1 - | Odd & 3 -> 2 - | MultipleOfN 4 _ | MultipleOfN 8 _ | MultipleOfN 16 _ - -> 3 - | 46 -> 5 - | MultipleOf2 & Even -> 4 - | Odd -> 6 - | Even -> 7 - -if test 33 <> 0 then exit 1 - -if test 5 <> 1 then exit 1 -if test 15 <> 1 then exit 1 - -if test 3 <> 2 then exit 1 - -if test 4 <> 3 then exit 1 -if test 8 <> 3 then exit 1 -if test 16 <> 3 then exit 1 - -if test 262 <> 4 then exit 1 - -if test 46 <> 5 then exit 1 - -if test 101 <> 6 then exit 1 -if test 102 <> 4 then exit 1 // MulOf2 & Even dominates just Even, since it comes first - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/discUnion01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/discUnion01.fs deleted file mode 100644 index c1a896978cb..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/discUnion01.fs +++ /dev/null @@ -1,27 +0,0 @@ -// #Conformance #PatternMatching #ActivePatterns -#light - -// Verify ability to use wildcards when matching discriminated unions - -type Foo = - | A of int - | B of string * int - -let test x = - match x with - | A(1) | B(_,1) -> 1 - | A(2) | B(_,2) -> 2 - | B(_, _) -> -1 - | A(_) -> -2 - -if test (A(1)) <> 1 then exit 1 -if test (B("",1)) <> 1 then exit 1 - -if test (A(2)) <> 2 then exit 1 -if test (B("",2)) <> 2 then exit 1 - -if test (A(42)) <> -2 then exit 1 -if test (B("",42)) <> -1 then exit 1 - -exit 0 - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/discUnion02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/discUnion02.fs deleted file mode 100644 index 424e7e8146f..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/discUnion02.fs +++ /dev/null @@ -1,24 +0,0 @@ -// #Conformance #PatternMatching #ActivePatterns -#light - -// Verify ability to use a constant when matching discriminated unions - -type Foo = - | A of int - | B of string * int - -let test x = - match x with - | A(42) -> -42 - | A(x) -> x - | B("FSharp", _) -> "FSharp".Length * -1 - | B(str, _) -> str.Length - -if test (A(10)) <> 10 then exit 1 -if test (B("aaa",1)) <> 3 then exit 1 - -if test (A(42)) <> -42 then exit 1 -if test (B("FSharp",2)) <> -6 then exit 1 - -exit 0 - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/env.lst b/tests/fsharpqa/Source/Conformance/PatternMatching/Named/env.lst deleted file mode 100644 index 7c5f143e98e..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Named/env.lst +++ /dev/null @@ -1,52 +0,0 @@ - SOURCE=E_Error_LetRec01.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_Error_LetRec01.fs - SOURCE=E_Error_LetRec02.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_Error_LetRec02.fs - SOURCE=E_Error_LetRec03.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_Error_LetRec03.fs - SOURCE=E_Error_LetRec04.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_Error_LetRec04.fs - SOURCE=E_Error_NonParam01.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_Error_NonParam01.fs - SOURCE=E_Error_NonParam02.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_Error_NonParam02.fs - SOURCE=E_Error_NonParam03.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_Error_NonParam03.fs - SOURCE=E_Error_NonParam04.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_Error_NonParam04.fs - SOURCE=E_Error_Param01.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_Error_Param01.fs - SOURCE=E_Error_Param02.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_Error_Param02.fs - SOURCE=E_Error_Param03.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_Error_Param03.fs - SOURCE=E_Error_Param04.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_Error_Param04.fs - - SOURCE=activePatterns01.fs # activePatterns01.fs - SOURCE=activePatterns02.fs # activePatterns02.fs - SOURCE=activePatterns03.fs # activePatterns03.fs - SOURCE=E_MulticasePartialNotAllowed01.fs SCFLAGS=--test:ErrorRanges # E_MulticasePartialNotAllowed01.fs - - SOURCE=activePatterns05.fs # activePatterns05.fs - SOURCE=activePatterns06.fs # activePatterns06.fs - SOURCE=activePatterns07.fs # activePatterns07.fs - SOURCE=activePatterns08.fs # activePatterns08.fs - -# SOURCE=AsHighOrderFunc01.fs # AsHighOrderFunc01.fs ### FAils on coreclr 2.1.500 - SOURCE=RecursiveActivePats.fs # RecursiveActivePats.fs - - SOURCE=E_ActivePatterns01.fs # E_ActivePatterns01.fs - SOURCE=E_ActivePatterns02.fs # E_ActivePatterns02.fs - SOURCE=E_ActivePatternHasNoFields.fs # E_ActivePatternHasNoFields.fs - SOURCE=E_ParameterRestrictions01.fs # E_ParameterRestrictions01.fs - - SOURCE=MultiActivePatterns01.fs # MultiActivePatterns01.fs - - SOURCE=ActivePatternOutsideMatch01.fs # ActivePatternOutsideMatch01.fs - SOURCE=ActivePatternOutsideMatch02.fs # ActivePatternOutsideMatch02.fs - - SOURCE=discUnion01.fs # discUnion01.fs - SOURCE=discUnion02.fs # discUnion02.fs - - SOURCE=NamedLiteral01.fs # NamedLiteral01.fs - SOURCE=NamedLiteral02.fs # NamedLiteral02.fs - - SOURCE=PatternMatchRegressions01.fs # PatternMatchRegressions01.fs - SOURCE=PatternMatchRegressions02.fs # PatternMatchRegressions02.fs - SOURCE=E_PatternMatchRegressions02.fs SCFLAGS=--test:ErrorRanges # E_PatternMatchRegressions02.fs - - SOURCE=ActivePatternUnconstrained01.fs # ActivePatternUnconstrained01.fs - SOURCE=E_ActivePatternUnconstrained01.fs SCFLAGS=--test:ErrorRanges # E_ActivePatternUnconstrained01.fs - SOURCE=E_ActivePatternNotAFuncion.fs SCFLAGS=--test:ErrorRanges # E_ActivePatternNotAFuncion.fs - - SOURCE=E_LargeActivePat01.fs # E_LargeActivePat01.fs - SOURCE=ParamertizedPartialActivePattern01.fs # ParamertizedPartialActivePattern01.fs diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Null/E_notNullCompatible01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Null/E_notNullCompatible01.fs deleted file mode 100644 index 58b30660d1c..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Null/E_notNullCompatible01.fs +++ /dev/null @@ -1,18 +0,0 @@ -// #Regression #Conformance #PatternMatching -#light - -// Verify error when trying to match type against null if it doesn't support that -//The type 'Foo' does not have 'null' as a proper value - -type Foo() = - member this.Value = 42 - - - -let isNull2 (x : Foo) = - match x with - | null -> true - | _ -> false - - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Null/env.lst b/tests/fsharpqa/Source/Conformance/PatternMatching/Null/env.lst deleted file mode 100644 index 24c524049e1..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Null/env.lst +++ /dev/null @@ -1,3 +0,0 @@ - SOURCE=matchNull01.fs # MatchNull01.fs - - SOURCE=E_notNullCompatible01.fs # E_notNullCompatible01.fs diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Null/matchNull01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Null/matchNull01.fs deleted file mode 100644 index e1d6a986b97..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Null/matchNull01.fs +++ /dev/null @@ -1,16 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Verify ability to match against null - -let isNull x = - match x with - | null -> true - | _ -> false - -if isNull ("abc" :> obj) <> false then exit 1 -if isNull (12345 :> obj) <> false then exit 1 - -if isNull null <> true then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Record/E_RecTypesNotMatch01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Record/E_RecTypesNotMatch01.fs deleted file mode 100644 index 9297cb34285..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Record/E_RecTypesNotMatch01.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Regression #Conformance #PatternMatching #Records -// Verify error if two record types in a pattern match don't match -// Verify error if type of a record field is incorrect. -//The record type 'R1' does not contain a label 'A'\. - -type R1 = { X : int; Y : int } - -let testMatch x = - match x with - | { X = 0; Y = 0} -> true - | { A = 0; B = 0} -> true - | _ -> false diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Record/E_RecordFieldNotDefined01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Record/E_RecordFieldNotDefined01.fs deleted file mode 100644 index fa8ce23bce2..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Record/E_RecordFieldNotDefined01.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Regression #Conformance #PatternMatching #Records -#light - -// Verify error if type of a record field is incorrect. -//The record label 'X' is not defined - -let testMatch x = - match x with - | { X = 0; Y = 0} -> true - | _ -> false - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Record/E_SyntaxError01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Record/E_SyntaxError01.fs deleted file mode 100644 index 55931311be6..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Record/E_SyntaxError01.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Regression #Conformance #PatternMatching #Records -// Verify syntax error -//Unexpected symbol '}' in pattern\. Expected '\.', '=' or other token\.$ - -type RecordType = { Value : int } - -let test x = - match x with - | { Value} -> true - | _ -> false - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Record/env.lst b/tests/fsharpqa/Source/Conformance/PatternMatching/Record/env.lst deleted file mode 100644 index 34a172bf716..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Record/env.lst +++ /dev/null @@ -1,9 +0,0 @@ - SOURCE=recordPatterns01.fs # recordPatterns01.fs - SOURCE=recordPatterns02.fs # recordPatterns02.fs - - SOURCE=structRecordPatterns01.fs # structRecordPatterns01.fs - SOURCE=structRecordPatterns02.fs # structRecordPatterns02.fs - - SOURCE=E_SyntaxError01.fs # E_SyntaxError01.fs - SOURCE=E_RecordFieldNotDefined01.fs # E_RecordFieldNotDefined01.fs - SOURCE=E_RecTypesNotMatch01.fs # E_RecTypesNotMatch01.fs diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Record/recordPatterns01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Record/recordPatterns01.fs deleted file mode 100644 index 68e648f054f..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Record/recordPatterns01.fs +++ /dev/null @@ -1,32 +0,0 @@ -// #Conformance #PatternMatching #Records -#light - -// Test ability to match records even if a subset of tags are specified. - -type Type = Plant | Animal | Mineral -type Thing = {Name : string; Age : int; Type : Type} - -// Single part -let isAnimal thing = - match thing with - | {Type=Animal} -> true - | _ -> false - -// Multi part -let isSteve thing = - match thing with - | {Name = "Steve"; Age = 2} -> true - | _ -> false - - -let animal = {Name = "Steve"; Age = 2; Type = Animal} -let plant = {Name = "Sunflower"; Age = 5; Type = Plant} -let rock = {Name = "Gold"; Age = 500000; Type = Mineral} - -if isAnimal animal <> true then exit 1 -if isAnimal rock <> false then exit 1 - -if isSteve animal <> true then exit 1 -if isSteve plant <> false then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Record/recordPatterns02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Record/recordPatterns02.fs deleted file mode 100644 index e73937878bf..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Record/recordPatterns02.fs +++ /dev/null @@ -1,39 +0,0 @@ -// #Conformance #PatternMatching #Records -#light - -// Verify ability to have nested patterns in record types - -type Type = Plant | Animal | Mineral -type Thing = {Name : string; Age : int; Type : Type} - -let isYoung thing = - match thing with - | {Age = x; Type = (Plant|Animal|Mineral)} when x < 10 -> true - | _ -> false - -let isMatch thing (thingName : string option) (thingAge : int option) = - // We can't extract the option value in a match and use it in the same statement, - // so we first break open the optional values. - let name = match thingName with Some(name) -> name | None -> "" - let age = match thingAge with Some(age) -> age | None -> 0 - // Finally match it all - match thingName, thingAge, thing with - | None, None, _ -> false - | Some(_), None, {Name=itsName} when itsName = name -> true - | None, Some(_), {Age=itsAge} when itsAge = age -> true - | Some(_), Some(_), {Name=name; Age=age} -> true - | _ -> false - -let animal = {Name = "Steve"; Age = 2; Type = Animal} -let plant = {Name = "Sunflower"; Age = 5; Type = Plant} -let rock = {Name = "Gold"; Age = 500000; Type = Mineral} - -if isYoung animal <> true then exit 1 -if isYoung rock <> false then exit 1 - -if isMatch animal (Some("Steve")) (Some(2)) <> true then exit 1 -if isMatch animal (Some("Steve")) None <> true then exit 1 - -if isMatch animal (Some("NotSteve")) None <> false then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Record/structRecordPatterns01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Record/structRecordPatterns01.fs deleted file mode 100644 index 007aac6c23a..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Record/structRecordPatterns01.fs +++ /dev/null @@ -1,32 +0,0 @@ -// #Conformance #PatternMatching #Records -#light - -// Test ability to match records even if a subset of tags are specified. - -type Type = Plant | Animal | Mineral -[] type Thing = {Name : string; Age : int; Type : Type} - -// Single part -let isAnimal thing = - match thing with - | {Type=Animal} -> true - | _ -> false - -// Multi part -let isSteve thing = - match thing with - | {Name = "Steve"; Age = 2} -> true - | _ -> false - - -let animal = {Name = "Steve"; Age = 2; Type = Animal} -let plant = {Name = "Sunflower"; Age = 5; Type = Plant} -let rock = {Name = "Gold"; Age = 500000; Type = Mineral} - -if isAnimal animal <> true then exit 1 -if isAnimal rock <> false then exit 1 - -if isSteve animal <> true then exit 1 -if isSteve plant <> false then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Record/structRecordPatterns02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Record/structRecordPatterns02.fs deleted file mode 100644 index 0d34aaadc7f..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Record/structRecordPatterns02.fs +++ /dev/null @@ -1,39 +0,0 @@ -// #Conformance #PatternMatching #Records -#light - -// Verify ability to have nested patterns in record types - -type Type = Plant | Animal | Mineral -[] type Thing = {Name : string; Age : int; Type : Type} - -let isYoung thing = - match thing with - | {Age = x; Type = (Plant|Animal|Mineral)} when x < 10 -> true - | _ -> false - -let isMatch thing (thingName : string option) (thingAge : int option) = - // We can't extract the option value in a match and use it in the same statement, - // so we first break open the optional values. - let name = match thingName with Some(name) -> name | None -> "" - let age = match thingAge with Some(age) -> age | None -> 0 - // Finally match it all - match thingName, thingAge, thing with - | None, None, _ -> false - | Some(_), None, {Name=itsName} when itsName = name -> true - | None, Some(_), {Age=itsAge} when itsAge = age -> true - | Some(_), Some(_), {Name=name; Age=age} -> true - | _ -> false - -let animal = {Name = "Steve"; Age = 2; Type = Animal} -let plant = {Name = "Sunflower"; Age = 5; Type = Plant} -let rock = {Name = "Gold"; Age = 500000; Type = Mineral} - -if isYoung animal <> true then exit 1 -if isYoung rock <> false then exit 1 - -if isMatch animal (Some("Steve")) (Some(2)) <> true then exit 1 -if isMatch animal (Some("Steve")) None <> true then exit 1 - -if isMatch animal (Some("NotSteve")) None <> false then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/CodeGenReg01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/CodeGenReg01.fs deleted file mode 100644 index cd9e19888df..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/CodeGenReg01.fs +++ /dev/null @@ -1,49 +0,0 @@ -// #Regression #Conformance #PatternMatching -#light - -// FSB 1750, Bad codegen in Pattern Matching - -let f p x = - match - match x with - | 1 when try p x finally () - -> 0 - | _ -> 1 - with - | 1 -> 0 - | _ -> 1 - -let rec loop x = if x = 0 then 1 else loop (x - 1) - -let g p x = - let test = - match x with - | 1 when (try p x finally ()) -> 3 - | _ -> 5 - loop test - -let h p x = - let test = - match x with - | 1 when (for x = 1 to 100 do printf "" done; true) -> 3 - | _ -> 5 - loop test - -let (|E|O|) x = if x % 2 = 0 then E else O - -let i p x = - let test = - match x with - | E when match x with - | E -> true - | O -> false - -> 3 - | O when match x with - | E -> false - | O -> true - -> 3 - | _ -> 5 - loop test - -// This test should just compile and PEVerify -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/E_SyntaxError01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/E_SyntaxError01.fs deleted file mode 100644 index b3b2c41d32d..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/E_SyntaxError01.fs +++ /dev/null @@ -1,11 +0,0 @@ -// #Regression #Conformance #PatternMatching -#light - -//Unexpected symbol'\[' in pattern matching. Expected '->' or other token - -let isIntArray (o: obj) = - match o with - | :? int[] -> true - | _ -> false - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/E_ValueCapture01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/E_ValueCapture01.fs deleted file mode 100644 index eb1cc0594dd..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/E_ValueCapture01.fs +++ /dev/null @@ -1,17 +0,0 @@ -// #Regression #Conformance #PatternMatching -#light - -//The value or constructor 'ident1' is not defined -//The value or constructor 'ident2' is not defined - -// Verifing scoping of value captures -let test1() = - let x = 1 - let _ = - match x with - | ident1 as ident2 -> () - - if ident1 <> 1 then failwith "ident1 shouldn't be in scope!" - if ident2 <> 2 then failwith "ident2 shouldn't be in scope!" - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/E_constPattern01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/E_constPattern01.fs deleted file mode 100644 index 64ca9c6eaa5..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/E_constPattern01.fs +++ /dev/null @@ -1,16 +0,0 @@ -// #Regression #Conformance #PatternMatching -#light - -//FS0025: Incomplete pattern matches on this expression. The value '7' will not be matched - -open System - -let isWeekend day = - match day with - | DayOfWeek.Monday | DayOfWeek.Tuesday | DayOfWeek.Wednesday - | DayOfWeek.Thursday | DayOfWeek.Friday - -> false - | DayOfWeek.Saturday | DayOfWeek.Sunday - -> true - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/E_namedLiberal01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/E_namedLiberal01.fs deleted file mode 100644 index 2f3ba740856..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/E_namedLiberal01.fs +++ /dev/null @@ -1,23 +0,0 @@ -// #Regression #Conformance #PatternMatching -// Match warning when covering all defined values of an enum - -//Enums may take values outside known cases. - - -open System - -let isWeekend day = - match day with - | DayOfWeek.Sunday | DayOfWeek.Saturday - -> true - | DayOfWeek.Monday | DayOfWeek.Tuesday - | DayOfWeek.Wednesday | DayOfWeek.Thursday - | DayOfWeek.Friday - -> false - - -if isWeekend DayOfWeek.Saturday <> true then exit 1 - -exit 0 - - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/MatchFailureExn01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/MatchFailureExn01.fs deleted file mode 100644 index 808d04f5fc6..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/MatchFailureExn01.fs +++ /dev/null @@ -1,26 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Verify a match failure exception is thrown if a match is not found. - -let VerifyThrows f x = - let result = - try - let _ = f x - false - with - | :? MatchFailureException -> true - | _ -> false - - if result = true - then () - else exit 1 - -// Test 1 -let test1 = (fun () -> let 1 = 2 in let x = 1 in x) -VerifyThrows test1 () - -// Test 2 -VerifyThrows (function x when x <> 0 -> true) 0 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/ValueCapture01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/ValueCapture01.fs deleted file mode 100644 index a7f55dd8899..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/ValueCapture01.fs +++ /dev/null @@ -1,19 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Test some of the semantics of value capture - -// Note that pattern matching doesn't execute all pats in order, rather -// it builds a tree, so when it chooses '0' over '1', it won't reconsider -// '1'. - -let test1() = - let mutable i = 0 - match i with - | 0 when (i <- 1; false) -> 0 - | 1 -> 1 - | _ -> -i - -if test1() <> -1 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/ValueCapture02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/ValueCapture02.fs deleted file mode 100644 index 2d6927b4611..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/ValueCapture02.fs +++ /dev/null @@ -1,35 +0,0 @@ -// #Conformance #PatternMatching -#light - -open System.Collections.Generic - -// Captured values for refence types -let test1() = - // Need to use List since F# overrides - // reference semantics for most other types - let x = new List() - x.Add(1) - x.RemoveAt(0) - if x.Count <> 0 then exit 1 - - match x with - | _ as newBoundValue - -> if newBoundValue <> x then exit 1 - if not <| newBoundValue.Equals(x) then exit 1 - () - -// Captured values for value types -let test2() = - let mutable i = 0 - match i with - | _ as newBoundValue -> if i <> newBoundValue then exit 1 - i <- 1 - if i = newBoundValue then exit 1 - () - - - -test1() -test2() - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/W_Incomplete01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/W_Incomplete01.fs deleted file mode 100644 index 61db9b4e83c..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/W_Incomplete01.fs +++ /dev/null @@ -1,109 +0,0 @@ -// #Regression #Conformance #PatternMatching -#light - -// Regression testcase for FSharp 1.0:2070 -// Warning on incomplete match - -//Incomplete pattern matches on this expression. For example, the value 'Result \(_\)' may indicate a case not covered by the pattern\(s\) - -module M = - - type Id = string - - type Field = { - Name:string; - mutable Type:Type; - mutable Parent:TypeDecl; - IsSpec:bool; - } - - and TypeDecl = - | Struct of Id * list - | Union of Id * list - | MathType of Id - - and Type = - | Void - | Integer - | Bool - | Ptr of Type - | Ref of TypeDecl - | Array of Type * int - | TypeIdT - | Tptr - | Map of Type * Type - - - type VarKind = - | Parameter - | Local - | Global - | QuantBound - - type Variable = { - Name:Id; - Type:Type; - Kind:VarKind; - } - - type Token = { - File: string; - Line:int; - Column:int; - Remarks:string; - } - - type ExprCommon = { - Token:Token; - Type:Type; - } - - type Function = { - Token:Token; - IsSpec:bool; - RetType:Type; - Name:Id; - Parameters:list; - Requires:list; - Ensures:list; - Invariants:list; - Writes:list; - Reads:list; - } - - and Expr = - | Ref of ExprCommon * Variable - | Prim of ExprCommon * string * list - | Call of ExprCommon * Function * list - | IntLiteral of ExprCommon * string - | BoolLiteral of ExprCommon * bool - | Deref of ExprCommon * Expr - | Addr of ExprCommon * Variable - | Dot of ExprCommon * Expr * Field // computes address of the field - | Index of ExprCommon * Expr * Expr // computes address of an array element - | Cast of ExprCommon * Expr // take the type from ExprCommon - | Result of ExprCommon - | VolatileRead of ExprCommon * Expr * Expr - | Old of ExprCommon * Expr - | Macro of ExprCommon * string * list - - type Expr with - member x.Common = - match x with - | Ref (e, _) - | Prim (e, _, _) - | Call (e, _, _) - | IntLiteral (e, _) - | BoolLiteral (e, _) - | Deref (e, _) - | Addr (e, _) - | Dot (e, _, _) - | Index (e, _, _) - | Cast (e, _) - //| Result (e) - | VolatileRead (e, _, _) - | Old (e, _) - | Macro (e, _, _) - -> e - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/W_Incomplete02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/W_Incomplete02.fs deleted file mode 100644 index 32fec0c6c5d..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/W_Incomplete02.fs +++ /dev/null @@ -1,35 +0,0 @@ -// #Regression #Conformance #PatternMatching -// Regression test for FSharp1.0:4920 -// Title: Can't have a quotation with an incomplete pattern match -// Regression test for FSharp1.0:4904 -// Title: Incomplete pattern in quotation causes error. -// Descr: Make sure quotations compile (even with warning) when having incomplete pattern match inside - -//Incomplete pattern matches on this expression\. -//Incomplete pattern matches on this expression\. -//This rule will never be matched -//This rule will never be matched -let foo x = - <@@ - match x with - | 1 -> 1 - | 2 -> 2 - @@> - -let g = - <@ - let f ( int : int ) = function - | 1 -> 0 - | 2 -> 1 - f - @> - -let h = - <@@ - match 10 with - | x -> x - | 1 -> 20 - | 10 -> 10 - @@> - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/env.lst b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/env.lst deleted file mode 100644 index 7a8347b35e2..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/env.lst +++ /dev/null @@ -1,35 +0,0 @@ - SOURCE=E_constPattern01.fs # E_constPattern01.fs - SOURCE=E_namedLiberal01.fs # E_namedLiberal01.fs - SOURCE=E_SyntaxError01.fs # E_SyntaxError01.fs - - - SOURCE=CodeGenReg01.fs # CodeGenReg01.fs - - SOURCE=MatchFailureExn01.fs # MatchFailureExn01.fs - - SOURCE=ValueCapture01.fs # ValueCapture01.fs - SOURCE=ValueCapture02.fs # ValueCapture02.fs - SOURCE=E_ValueCapture01.fs # E_ValueCapture01.fs - - SOURCE=simplePatterns01.fs # simplePatterns01.fs - SOURCE=simplePatterns02.fs # simplePatterns02.fs - SOURCE=simplePatterns03.fs # simplePatterns03.fs - SOURCE=simplePatterns04.fs # simplePatterns04.fs - SOURCE=simplePatterns05.fs # simplePatterns05.fs - SOURCE=simplePatterns06.fs # simplePatterns06.fs - SOURCE=simplePatterns07.fs # simplePatterns07.fs - SOURCE=simplePatterns08.fs # simplePatterns08.fs - SOURCE=simplePatterns09.fs # simplePatterns09.fs - SOURCE=simplePatterns10.fs # simplePatterns10.fs - SOURCE=simplePatterns11.fs # simplePatterns11.fs - SOURCE=simplePatterns12.fs # simplePatterns12.fs - SOURCE=simplePatterns13.fs # simplePatterns13.fs - SOURCE=simplePatterns14.fs # simplePatterns14.fs - SOURCE=simplePatterns15.fs # simplePatterns15.fs - SOURCE=simplePatterns16.fs # simplePatterns16.fs - SOURCE=simplePatterns17.fs # simplePatterns17.fs - SOURCE=simplePatterns18.fs # Pattern Match short Unicode literals - SOURCE=simplePatterns19.fs # Pattern Match long Unicode literals - SOURCE=simplePatterns20.fs # Pattern Match lshort Unicode literals in strings - - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns01.fs deleted file mode 100644 index 72b063c7b41..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns01.fs +++ /dev/null @@ -1,15 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Test guarded patterns -let success = - let x = 42 - match x with - | x when x < 40 -> exit 1 - | _ when x > 42 -> exit 1 - | x when x = 42 -> true - | _ -> exit 1 - -if success then exit 0 -exit 1 - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns02.fs deleted file mode 100644 index ef72f1c539d..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns02.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Test constant pattern matches -let x = 42 -let _ = - match x with - | 41 -> exit 1 - | 43 -> exit 1 - | 42 -> exit 0 - | _ -> exit 1 - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns03.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns03.fs deleted file mode 100644 index 7490e2247b9..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns03.fs +++ /dev/null @@ -1,22 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Match pattern with 'named pattern' -type Foo() = - static member StaticProperty = 42 - -let testNamedPattern x = - match x with - | x as someNewIdentifier when x = 42 - -> if (someNewIdentifier <> x) || (someNewIdentifier <> 42) then - false - else - true - | _ as someNewIdentifier when someNewIdentifier = 0 -> true - | _ -> false - -if testNamedPattern 42 <> true then exit 1 -if testNamedPattern 0 <> true then exit 1 -if testNamedPattern (-1) <> false then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns04.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns04.fs deleted file mode 100644 index 284b8160f70..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns04.fs +++ /dev/null @@ -1,14 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Test guarded patterns -let success = - let x = -1 - match x with - | even when x % 2 = 0 && x > 0 -> exit 1 - | odd when x % 2= 1 && x > 0 -> exit 1 - | lessThanZero -> true - -if success then exit 0 -exit 1 - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns05.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns05.fs deleted file mode 100644 index 8b86c15d7c0..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns05.fs +++ /dev/null @@ -1,28 +0,0 @@ -// #Conformance #PatternMatching -#light - -type Alphabet = - | A | B | C | D | E - | F | G | H | I | J - | K | L | M | N | O - | P | Q | R | S | T - | U | V | W | X | Y - | Z - -let isVowel letter = - match letter with - | A | E | I - | O | U - -> true - | Y -> true // Only sometimes - | _ -> false - -if isVowel A <> true then exit 1 -if isVowel E <> true then exit 1 -if isVowel I <> true then exit 1 -if isVowel O <> true then exit 1 -if isVowel U <> true then exit 1 -if isVowel Y <> true then exit 1 -if isVowel C <> false then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns06.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns06.fs deleted file mode 100644 index aede484e41c..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns06.fs +++ /dev/null @@ -1,26 +0,0 @@ -// #Conformance #PatternMatching -#light - -let (|MulTwo|_|) x = if x % 2 = 0 then Some() else None -let (|MulThree|_|) x = if x % 3 = 0 then Some() else None -let (|MulFour|_|) x = if x % 4 = 0 then Some() else None - -let mulOf234 x = - match x with - | MulTwo & MulThree & MulFour -> (true, true, true) - | MulTwo & MulThree -> (true, true, false) - | MulThree & MulFour -> (false, true, true) - | MulTwo & MulFour -> (true, false, true) - | MulTwo -> (true, false, false) - | MulThree -> (false, true, false) - | MulFour -> (false, false, true) - | _ -> (false,false,false) - - -for i = 1 to 100 do - let m2,m3,m4 = mulOf234 i - if m2 <> (i % 2 = 0) then exit 1 - if m3 <> (i % 3 = 0) then exit 1 - if m4 <> (i % 4 = 0) then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns07.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns07.fs deleted file mode 100644 index b4d4d3646f7..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns07.fs +++ /dev/null @@ -1,20 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Contains sequence [6; 20; 82] -let rec containsSeq list = - match list with - // Base cases - | [] -> false - | _ :: [] -> false - | _ :: _ :: [] -> false - // Check - | 6 :: 20 :: 82 :: tl -> true - // Recurse - | _ :: tail -> containsSeq tail - -if containsSeq [1 .. 100] = true then exit 1 -if containsSeq [1; 2; 3; 6; 20; 82; 1; 1] = false then exit 1 - -exit 0 - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns08.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns08.fs deleted file mode 100644 index 8a37dc96877..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns08.fs +++ /dev/null @@ -1,17 +0,0 @@ -// #Conformance #PatternMatching -#light - -let rec listLength list = - match list with - | [] -> 0 - | [_] -> 1 - | [_; _] -> 2 - | [_; _; _] -> 3 - | hd :: tl -> 1 + listLength tl - -if listLength [] <> 0 then exit 1 -if listLength [1] <> 1 then exit 1 -if listLength [1..2] <> 2 then exit 1 -if listLength [1..5] <> 5 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns09.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns09.fs deleted file mode 100644 index 24ee7926832..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns09.fs +++ /dev/null @@ -1,19 +0,0 @@ -// #Conformance #PatternMatching -#light - -let sumArray array = - match array with - | [| |] -> 0 - | [|x|] -> x - | [|x; y|] -> x + y - | [|x; y; z|] -> x + y + z - | [|w; x; y; z|] -> w + x + y + z - | _ -> failwith "too large" - -if sumArray [| |] <> 0 then exit 1 -if sumArray [|1|] <> 1 then exit 1 -if sumArray [|1;2|] <> 3 then exit 1 -if sumArray [|1;2;3|] <> 6 then exit 1 -if sumArray [|1;2;3;4|] <> 10 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns10.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns10.fs deleted file mode 100644 index 9fd840d2d32..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns10.fs +++ /dev/null @@ -1,18 +0,0 @@ -// #Conformance #PatternMatching -#light - -let f x y = - match x, y with - | (0), (0) -> false - | (1), (0) -> true - | _, _ -> false - -let r1 = f 0 0 -let r2 = f 1 0 -let r3 = f 0 1 - -if r1 <> false then exit 1 -if r2 <> true then exit 1 -if r3 <> false then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns11.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns11.fs deleted file mode 100644 index 503cb88b8e3..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns11.fs +++ /dev/null @@ -1,15 +0,0 @@ -// #Conformance #PatternMatching -#light - -let sumEvenValues (tupel:int*int) = - match tupel with - | x, y when x % 2 = 0 && y % 2 = 0 -> x + y - | x, _ when x % 2 = 0 -> x - | _, y when y % 2 = 0 -> y - | _, _ -> 0 - | _ -> 0 - -if sumEvenValues (2, 2) <> 4 then exit 1 -if sumEvenValues (1, 5) <> 0 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns12.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns12.fs deleted file mode 100644 index 7e79990292b..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns12.fs +++ /dev/null @@ -1,21 +0,0 @@ -// #Conformance #PatternMatching -#light - -type Person = { Name : string; Age : int } - -type Classification = - | Child - | Adult - | Senior - -let getClass person = - match person with - | { Name = _; Age = age} when age < 12 -> Child - | { Name = _; Age = age} when age > 55 -> Senior - | { Name=_; Age=_} -> Adult - -if getClass {Name="Uncle Simpson"; Age=70} <> Senior then exit 1 -if getClass {Name="Homer"; Age=40} <> Adult then exit 1 -if getClass {Name="Lisa"; Age=11} <> Child then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns13.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns13.fs deleted file mode 100644 index 1bfad47a21f..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns13.fs +++ /dev/null @@ -1,20 +0,0 @@ -// #Conformance #PatternMatching -#light - -module SomeModule = - type DU = - | A of int - | B of string - | C - -module MainModule = - let getCount thingey = - match thingey with - | SomeModule.DU.A x -> x - | SomeModule.DU.B x -> x.Length - | SomeModule.DU.C -> 0 - - if getCount (SomeModule.DU.A(42)) <> 42 then exit 1 - if getCount (SomeModule.DU.B("cat")) <> 3 then exit 1 - - exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns14.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns14.fs deleted file mode 100644 index 355afa9c673..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns14.fs +++ /dev/null @@ -1,10 +0,0 @@ -// #Conformance #PatternMatching -#light - -let result = - match 42 with - | _ -> true - -if result <> true then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns15.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns15.fs deleted file mode 100644 index c30590dc0e8..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns15.fs +++ /dev/null @@ -1,18 +0,0 @@ -// #Conformance #PatternMatching -#light - -open System - -let abbreviate (ex:#obj) = - match box ex with - | :? NotImplementedException -> "nyi" - | :? ArgumentException -> "ae" - | :? Exception -> "e" - | _ -> "" - -if abbreviate (new NotImplementedException "") <> "nyi" then exit 1 -if abbreviate (new ArgumentException "") <> "ae" then exit 1 -if abbreviate (new Exception "") <> "e" then exit 1 -if abbreviate ("foo") <> "" then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns16.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns16.fs deleted file mode 100644 index a6c308b4a20..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns16.fs +++ /dev/null @@ -1,27 +0,0 @@ -// #Conformance #PatternMatching -#light - -open System - -let abbreviate (ex:#obj) = - match box ex with - | :? NotImplementedException as e - -> if e.GetType() <> typeof then - exit 1 - "nyi" - | :? ArgumentException as e - -> if e.GetType() <> typeof then - exit 1 - "ae" - | :? Exception as e - -> if e.GetType() <> typeof then - exit 1 - "e" - | _ -> "" - -if abbreviate (new NotImplementedException "") <> "nyi" then exit 1 -if abbreviate (new ArgumentException "") <> "ae" then exit 1 -if abbreviate (new Exception "") <> "e" then exit 1 -if abbreviate ("foo") <> "" then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns17.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns17.fs deleted file mode 100644 index e35cc2e1e9e..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns17.fs +++ /dev/null @@ -1,19 +0,0 @@ -// #Conformance #PatternMatching -#light - -open System - -let nullValue = Type.GetType("this type does not exist") -let result = - match nullValue with - | null -> true - | _ -> false - -if nullValue <> null then exit 1 -if null <> nullValue then exit 1 // This actually is a pattern match -if result <> true then exit 1 - -let f = fun null -> true -if f nullValue <> true then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns18.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns18.fs deleted file mode 100644 index 49f5a099c9e..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns18.fs +++ /dev/null @@ -1,30 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Pattern match a short unicode literal - -type Suit = - | Spade - | Club - | Heart - | Diamond - -let spade, club, heart, diamond = '\u2660', '\u2663', '\u2665', '\u2666' - -let getSuit c = - match c with - | '\u2660' -> Some(Spade) - | '\u2663' -> Some(Club) - | '\u2665' -> Some(Heart) - | '\u2666' -> Some(Diamond) - | _ -> None - -if getSuit 'a' <> None then exit 1 -if getSuit 'z' <> None then exit 1 - -if getSuit spade <> Some(Spade) then exit 1 -if getSuit club <> Some(Club) then exit 1 -if getSuit heart <> Some(Heart) then exit 1 -if getSuit diamond <> Some(Diamond) then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns19.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns19.fs deleted file mode 100644 index fcc0f9e5f69..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns19.fs +++ /dev/null @@ -1,26 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Pattern match long unicode literals - -[] -let UnicodeString1 = "\U00000000\U0002FFFF" - -[] -let UnicodeString2 = "\U00101111\U000F2222" - -let testStr x = - match x with - | UnicodeString1 -> 1 - | UnicodeString2 -> 2 - | _ -> 0 - -if testStr "foo" <> 0 then exit 1 - -if testStr UnicodeString1 <> 1 then exit 1 -if testStr "\U00000000\U0002FFFF" <> 1 then exit 1 - -if testStr UnicodeString2 <> 2 then exit 1 -if testStr "\U00101111\U000F2222" <> 2 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns20.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns20.fs deleted file mode 100644 index 9295135f6c8..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Simple/simplePatterns20.fs +++ /dev/null @@ -1,26 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Pattern match short unicode literals in strings - -[] -let UnicodeString1 = "\u0000\uFFFF" - -[] -let UnicodeString2 = "\u1111\u2222" - -let testStr x = - match x with - | UnicodeString1 -> 1 - | UnicodeString2 -> 2 - | _ -> 0 - -if testStr "foo" <> 0 then exit 1 - -if testStr UnicodeString1 <> 1 then exit 1 -if testStr "\u0000\uFFFF" <> 1 then exit 1 - -if testStr UnicodeString2 <> 2 then exit 1 -if testStr "\u1111\u2222" <> 2 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/DiffAssembly.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/DiffAssembly.fs deleted file mode 100644 index ca425eeca92..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/DiffAssembly.fs +++ /dev/null @@ -1,16 +0,0 @@ -// #Conformance #PatternMatching #Constants -#light - -#light - -// Verify pattern matching against constants defined in a different assembly. - -let testMatch x = - match x with - | System.Math.PI -> 1 - | _ -> 2 - -if testMatch System.Math.PI <> 1 then exit 1 -if testMatch 0.0 <> 2 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/E_NoRangeConst01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/E_NoRangeConst01.fs deleted file mode 100644 index b88f36e32b9..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/E_NoRangeConst01.fs +++ /dev/null @@ -1,25 +0,0 @@ -// #Regression #Conformance #PatternMatching #Constants -#light - -// Verify error when trying to use range constants -//Unexpected symbol '..' in pattern matching. Expected '->' or other token - -let areKnownLists l = - match l with - | 1 .. 2 .. 10 -> "odds" - | 2 .. 2 .. 10 -> "evens" - | 1 .. 10 -> "all" - | _ -> "?" - - -if areKnownLists [2; 4; 6; 8; 10] <> "evens" then exit 1 - -let odds = 1 :: 3 :: 5 :: 7 :: 9 :: [] -if areKnownLists odds <> "odds" then exit 1 - -let all = [10 .. -1 .. 1] |> List.rev -if areKnownLists all <> "all" then exit 1 - -if areKnownLists [] <> "?" then exit 1 - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/E_type_bigint.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/E_type_bigint.fs deleted file mode 100644 index da3a23ef76b..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/E_type_bigint.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #Regression #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: BigInt -//Non-primitive numeric literal constants.+ -#light - -let isZero x = - match x with - | 0I -> true - | 99I -> false - | _ -> false - -exit (if isZero 0I then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/E_type_bignum40.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/E_type_bignum40.fs deleted file mode 100644 index 430712651ab..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/E_type_bignum40.fs +++ /dev/null @@ -1,14 +0,0 @@ -// #Regression #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: BigNum -//Non-primitive numeric literal constants.+ -// On NetFx4.0/Dev10, we don't give the deprecation error: this is ok (FSHARP1.0:4599) -#light - -let isZero x = - match x with - | 99999N -> false - | 0N -> true - | _ -> false - -exit (if isZero 0N then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/FullyQualify01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/FullyQualify01.fs deleted file mode 100644 index 7759c8cfa21..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/FullyQualify01.fs +++ /dev/null @@ -1,33 +0,0 @@ -// #Conformance #PatternMatching #Constants -#light - -// Verify ability to pattern match against a fully qualified constant or literal - -module Test = - - module A = - module B = - module C = - module D = - type DU = - | A of int - | B of string - | C - - [] - let literalValue = "AString" - - - let test x = - match x with - | A.B.C.D.A(x) -> 1 - | A.B.C.D.B(x) when x = A.B.C.D.literalValue -> 2 - | A.B.C.D.B(x) -> 3 - | _ -> 0 - - - if test (A.B.C.D.A(5)) <> 1 then exit 1 - if test (A.B.C.D.B(A.B.C.D.literalValue)) <> 2 then exit 1 - if test (A.B.C.D.C) <> 0 then exit 1 - - exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/MatchLiteral01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/MatchLiteral01.fs deleted file mode 100644 index a3aaa24faf6..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/MatchLiteral01.fs +++ /dev/null @@ -1,30 +0,0 @@ -// #Regression #Conformance #PatternMatching #Constants -#light - -// Test ability to match a const literal value -//This rule will never be matched -//This rule will never be matched -//This rule will never be matched - -[] -let intLiteral = 42 - -if (match 42 with - | intLiteral -> true - | _ -> false) <> true then exit 1 - -[] -let strLiteral = "foobaz" - -if (match "foobaz" with - | strLiteral -> true - | _ -> false) <> true then exit 1 - -[] -let boolLiteral = false - -if (match false with - | boolLiteral -> true - | true -> false) <> true then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/MatchNaN.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/MatchNaN.fs deleted file mode 100644 index 9812451d83a..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/MatchNaN.fs +++ /dev/null @@ -1,29 +0,0 @@ -// #Conformance #PatternMatching #Constants -#light - -// Verify the ability to match against NaN. Note that -// this should - -let rec TestIsNaN x = - match box x with - | :? float as fx -> isNaNFloat fx - | :? float32 as f32x -> isNaNFloat32 f32x - -and isNaNFloat x = - match x with - | System.Double.NaN -> failwith "Should never match" - | 0.0 -> failwith "Should never match" - | _ -> () - -and isNaNFloat32 x = - match x with - | System.Single.NaN -> failwith "Should never match" - | 0.0f -> failwith "Should never match" - | _ -> () - -// This seems strange, but accoring to the IEEE spec -// NaN <> NaN -TestIsNaN System.Single.NaN -TestIsNaN System.Double.NaN - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/env.lst b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/env.lst deleted file mode 100644 index 1c60ead9d8b..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/env.lst +++ /dev/null @@ -1,35 +0,0 @@ - SOURCE=matchConst01.fs # matchConst01.fs - SOURCE=matchConst02.fs # matchConst02.fs - SOURCE=matchConst03.fs # matchConst03.fs - SOURCE=matchConst04.fs # matchConst04.fs - - SOURCE=E_NoRangeConst01.fs # E_NoRangeConst01.fs - - SOURCE=DiffAssembly.fs # DiffAssembly.fs - SOURCE=MatchNaN.fs # MatchNaN.fs - - SOURCE=MatchLiteral01.fs # MatchLiteral01.fs - - SOURCE=FullyQualify01.fs # FullyQualify01.fs - - SOURCE=type_bigint.fs # type_bigint.fs - - SOURCE=E_type_bignum40.fs SCFLAGS="--test:ErrorRanges" # E_type_bignum40.fs - - SOURCE=type_bool.fs # type_bool.fs - SOURCE=type_byte.fs # type_byte.fs - SOURCE=type_byteArr.fs # type_byteArr.fs - SOURCE=type_char.fs # type_char.fs - SOURCE=type_double.fs # type_double.fs - SOURCE=type_float32.fs # type_float32.fs - SOURCE=type_int.fs # type_int.fs - SOURCE=type_int16.fs # type_int16.fs - SOURCE=type_int64.fs # type_int64.fs - SOURCE=type_nativenint.fs # type_nativenint.fs - SOURCE=type_sbyte.fs # type_sbyte.fs - SOURCE=type_string.fs # type_string.fs - SOURCE=type_uint16.fs # type_uint16.fs - SOURCE=type_uint32.fs # type_uint32.fs - SOURCE=type_uint64.fs # type_uint64.fs - SOURCE=type_unativenint.fs # type_unativenint.fs - SOURCE=type_unit.fs # type_unit.fs diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/matchConst01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/matchConst01.fs deleted file mode 100644 index 9977f89e3cb..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/matchConst01.fs +++ /dev/null @@ -1,15 +0,0 @@ -// #Conformance #PatternMatching #Constants -#light - -let isZero x = - match x with - | 0 -> true - | x when x < 0 -> false - | x when x > 0 -> false - | _ -> failwith "Shouldn't ever happen" - -if isZero (-1) <> false then exit 1 -if isZero 0 <> true then exit 1 -if isZero 1 <> false then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/matchConst02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/matchConst02.fs deleted file mode 100644 index 4c763420234..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/matchConst02.fs +++ /dev/null @@ -1,15 +0,0 @@ -// #Conformance #PatternMatching #Constants -#light - -let isBob x = - match x with - | "Bob" -> true - | s when s < "Bob" -> false - | t when t > "Bob" -> false - | _ -> failwith "Shouldn't ever happen" - -if isBob "Alan" <> false then exit 1 -if isBob "Bob" <> true then exit 1 -if isBob "Carl" <> false then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/matchConst03.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/matchConst03.fs deleted file mode 100644 index 1fbe3d72a52..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/matchConst03.fs +++ /dev/null @@ -1,26 +0,0 @@ -// #Conformance #PatternMatching #Constants -#light - -// Match floating point numbers -type Number = NotPI | SortOfPI | CloseToPI | CloseEnoughToPI - -let piCheck x = - match x with - | 3.1 -> NotPI - | 3.14 -> SortOfPI - | 3.141 -> CloseToPI - | 3.1415 -> CloseEnoughToPI - | _ when System.Math.Abs((x - 3.1415)) < 0.0001 -> CloseEnoughToPI - | _ -> NotPI - -if piCheck 3.1 <> NotPI then exit 1 -if piCheck 3.14 <> SortOfPI then exit 1 -if piCheck 3.141 <> CloseToPI then exit 1 -if piCheck 3.1415 <> CloseEnoughToPI then exit 1 -if piCheck 3.14159 <> CloseEnoughToPI then exit 1 -if piCheck 3.141592 <> CloseEnoughToPI then exit 1 - -if piCheck 3.0 <> NotPI then exit 1 -if piCheck -42.0 <> NotPI then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/matchConst04.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/matchConst04.fs deleted file mode 100644 index d3a26b58ec7..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/matchConst04.fs +++ /dev/null @@ -1,24 +0,0 @@ -// #Conformance #PatternMatching #Constants -#light - -// Match against an enum - -open System - -let isWeekend day = - match day with - | DayOfWeek.Sunday | DayOfWeek.Saturday - -> true - | DayOfWeek.Monday | DayOfWeek.Tuesday - | DayOfWeek.Wednesday | DayOfWeek.Thursday - | DayOfWeek.Friday - -> false - | _ -> false - - -if isWeekend DayOfWeek.Saturday <> true then exit 1 - -// This is why a catch all pattern must be there... -if isWeekend (enum -42) <> false then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_bigint.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_bigint.fs deleted file mode 100644 index 19bbde72111..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_bigint.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: BigInt -#light - -let isZero x = - match x with - | y when y = 0I -> true // notice: 0I -> true would yield an error - | y when y = 99I -> false // notice: 99I -> false would yield an error - | _ -> false - -exit (if isZero 0I then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_bool.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_bool.fs deleted file mode 100644 index 0713270aaa6..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_bool.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: Bool -#light - -let isZero x = - match x with - | true -> true - | false -> false - | _ -> failwith "What?" - -exit (if (isZero true) && (not (isZero false)) then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_byte.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_byte.fs deleted file mode 100644 index 33270b0c448..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_byte.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: byte -#light - -let isZero x = - match x with - | 0uy -> true - | 99uy -> false - | _ -> false - -exit (if isZero 0uy then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_byteArr.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_byteArr.fs deleted file mode 100644 index 9dcd87e5c7d..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_byteArr.fs +++ /dev/null @@ -1,14 +0,0 @@ -// #Regression #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: byte[] -// This is a regression test for FSHARP1.0:2036 -#light - -let isZero x = - match x with - | ""B -> true - | @"\"B -> false - | "ASCII"B -> false - | _ -> false - -exit (if isZero ""B then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_char.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_char.fs deleted file mode 100644 index 338658c5162..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_char.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: char -#light - -let isZero x = - match x with - | 'a' -> true - | '\\' -> false - | _ -> false - -exit (if isZero 'a' then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_double.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_double.fs deleted file mode 100644 index f2659f21048..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_double.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: double -#light - -let isZero x = - match x with - | 1. -> false - | 1.01 -> false - | 1.01e10 -> true - | _ -> false - -exit (if isZero 1.01e10 then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_float32.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_float32.fs deleted file mode 100644 index 860dd9b21d1..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_float32.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: double -#light - -let isZero x = - match x with - | 1.f -> true - | 1.01f -> false - | 1.01e10f -> false - | _ -> false - -exit (if isZero 1.f then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_int.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_int.fs deleted file mode 100644 index 36e24c95194..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_int.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: int -#light - -let isZero x = - match x with - | 0 -> true - | 99 -> false - | _ -> false - -exit (if isZero 0 then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_int16.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_int16.fs deleted file mode 100644 index fbcbcb2ccb6..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_int16.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Constant expressions -// This is the example quoted from the specs -// Verification: -// - all the different types work -// - the type we get is what we meant it to be -#light - -let v = 17s // int16 -let check(x:int16) = true - -exit (if check(v) then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_int64.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_int64.fs deleted file mode 100644 index d8d3b993078..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_int64.fs +++ /dev/null @@ -1,14 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: int64 -#light - -let isZero x = - match x with - | 0L -> false - | 99L -> true - | -99L -> false - | _ -> false - -exit (if isZero 99L then 0 else 1) - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_nativenint.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_nativenint.fs deleted file mode 100644 index 49dac8802dc..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_nativenint.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: nativeint -#light - -let isZero x = - match x with - | 0n -> false - | 99999999n -> true - | _ -> false - -exit (if isZero 99999999n then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_sbyte.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_sbyte.fs deleted file mode 100644 index 76ac6ad324e..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_sbyte.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: sbyte -#light - -let isZero x = - match x with - | -20y -> true - | 99y -> false - | _ -> false - -exit (if isZero -20y then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_string.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_string.fs deleted file mode 100644 index 8c6f124ab9c..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_string.fs +++ /dev/null @@ -1,14 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: string -#light - -let isZero x = - match x with - | "3" -> false - | "c:\\home" -> false - | @"c:\home" -> false - | @"@" -> true - | _ -> false - -exit (if isZero @"@" then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_uint16.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_uint16.fs deleted file mode 100644 index 66c11053695..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_uint16.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: uint16 -#light - -let isZero x = - match x with - | 0us -> true - | 99us -> false - | _ -> false - -exit (if isZero 0us then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_uint32.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_uint32.fs deleted file mode 100644 index 8f8b2d0c6c8..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_uint32.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: uint32 -#light - -let isZero x = - match x with - | 0u -> true - | 99u -> false - | _ -> false - -exit (if isZero 0u then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_uint64.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_uint64.fs deleted file mode 100644 index 221d4009bd9..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_uint64.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: uint64 -#light - -let isZero x = - match x with - | 0UL -> false - | 9999999999999UL -> true - | _ -> false - -exit (if isZero 9999999999999UL then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_unativenint.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_unativenint.fs deleted file mode 100644 index a3447af87b7..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_unativenint.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: unativeint -#light - -let isZero x = - match x with - | 0un -> true - | 99un -> false - | _ -> false - -exit (if isZero 0un then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_unit.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_unit.fs deleted file mode 100644 index a9535e5d106..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/SimpleConstant/type_unit.fs +++ /dev/null @@ -1,11 +0,0 @@ -// #Conformance #PatternMatching #Constants -// Pattern Matching - Simple Constants -// Type: unit -#light - -let isZero x = - match x with - | () -> true - | _ -> false - -exit (if isZero () then 0 else 1) diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/SimpleTuples01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/SimpleTuples01.fs deleted file mode 100644 index 036b2d45094..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/SimpleTuples01.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Conformance #PatternMatching #Tuples -#light - -let tupleStartsWithOne x = - match x with - | 1, _ -> true - | _, _ -> false - -if tupleStartsWithOne (1, 0) <> true then exit 1 -if tupleStartsWithOne (0, 1) <> false then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/W_IncompleteMatches01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/W_IncompleteMatches01.fs deleted file mode 100644 index 9efcf49e8b8..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/W_IncompleteMatches01.fs +++ /dev/null @@ -1,14 +0,0 @@ -// #Regression #Conformance #PatternMatching #Tuples - - -// Verify warnings for incomplete pattern matches -//Incomplete pattern matches on this expression. - -let test() = - function - | 1, _ - | 2, _ - | 3, _ -> 'a' - | _, 0 -> 'b' - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/W_RedundantPattern01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/W_RedundantPattern01.fs deleted file mode 100644 index f8e38f3ce21..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/W_RedundantPattern01.fs +++ /dev/null @@ -1,15 +0,0 @@ -// #Regression #Conformance #PatternMatching #Tuples -#light - -// Verify warning with redundant pattern -//This rule will never be matched - -let redPat () = - function - | 1, _, _ - -> true - | 1, _, _ - -> true - | _ -> false - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/W_RedundantPattern02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/W_RedundantPattern02.fs deleted file mode 100644 index 3015210ce04..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/W_RedundantPattern02.fs +++ /dev/null @@ -1,19 +0,0 @@ -// #Regression #Conformance #PatternMatching #Tuples -#light - -// Verify warning if all DU tags are matched with and -// a wildcard is included. -//This rule will never be matched - -type DU = A | B | C of int - -let test = - function | A -> 1 | B -> 2 | C(0) -> 3 - | C(x) -> x | _ -> failwith "Bummer" - -let _ = test A -let _ = test B -let _ = test <| C(0) -let _ = test <| C(4) - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/env.lst b/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/env.lst deleted file mode 100644 index 25f330533ba..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/env.lst +++ /dev/null @@ -1,5 +0,0 @@ - SOURCE=tuples01.fs # tuples01.fs - SOURCE=SimpleTuples01.fs # SimpleTuples01.fs - SOURCE=W_IncompleteMatches01.fs # W_IncompleteMatches01.fs - SOURCE=W_RedundantPattern01.fs # W_RedundantPattern01.fs - SOURCE=W_RedundantPattern02.fs # W_RedundantPattern02.fs diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/tuples01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/tuples01.fs deleted file mode 100644 index 72d5e59165e..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Tuple/tuples01.fs +++ /dev/null @@ -1,19 +0,0 @@ -// #Conformance #PatternMatching #Tuples -#light - -// Match nested tuples - -let monsterTuple = ("0", "1", ("2", "2.1", "2.2"), "3", ("4", ("4.1", "4.1.1"), "4.2")) - -let result = - match monsterTuple with - | (_, _, (_, _, _), _, (_, (_, _), _)) -> true - -// Possible compile time error: -// MonsterTuple doesn't match signature (...) from type inference - -// Possible runtime error: -// MatchNotFoundException -if result <> true then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/TypeAnnotated/env.lst b/tests/fsharpqa/Source/Conformance/PatternMatching/TypeAnnotated/env.lst deleted file mode 100644 index 1bb8bf6d7fd..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/TypeAnnotated/env.lst +++ /dev/null @@ -1 +0,0 @@ -# empty diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/TypeConstraint/E_typecontraint01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/TypeConstraint/E_typecontraint01.fs deleted file mode 100644 index 4ce19c52666..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/TypeConstraint/E_typecontraint01.fs +++ /dev/null @@ -1,21 +0,0 @@ -// #Regression #Conformance #PatternMatching #TypeConstraints -// Regression test for FSHARP1.0:1525 -// type constraints on pattern matching are deprecated and are now errors (used to be warnings) -// As of Beta2, we are not even giving the deprecation error. -//Unexpected symbol ':>' in pattern. Expected '\)' or other token. -//Unmatched '\('$ -//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. -type A() = class - end - -type B() = class - inherit A() - end - -type C() = class - inherit B() - end - -let test1 (x:#A) = - match x with - | (o :> B) -> o.GetHashCode() diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/TypeConstraint/env.lst b/tests/fsharpqa/Source/Conformance/PatternMatching/TypeConstraint/env.lst deleted file mode 100644 index abf80037e6a..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/TypeConstraint/env.lst +++ /dev/null @@ -1 +0,0 @@ - SOURCE=E_typecontraint01.fs SCFLAGS="-a --test:ErrorRanges" # E_typecontraint01.fs diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Union/E_CapturesDiffVal01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Union/E_CapturesDiffVal01.fs deleted file mode 100644 index 363ab3c29a0..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Union/E_CapturesDiffVal01.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #Regression #Conformance #PatternMatching #Unions -#light - -// Verify error if two pattern match clauses match -// different values -//The two sides of this 'or' pattern bind different sets of variables - -let testMatch x = - match x with - | (x, 0, 0) | (0, y, 0) | (0, 0, z) -> true - | _ -> false - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Union/E_NotAllCaptureSameVal01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Union/E_NotAllCaptureSameVal01.fs deleted file mode 100644 index af9e457cd93..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Union/E_NotAllCaptureSameVal01.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #Regression #Conformance #PatternMatching #Unions -#light - -// Verify error if not all union pattern rules capture the -// same set of values -//The two sides of this 'or' pattern bind different sets of variables - -let tupeMatch x = - match x with - | (x, 0) | (0, x) | (0, 0) -> true - | _ -> false - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Union/E_UnionCapturesDiffType01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Union/E_UnionCapturesDiffType01.fs deleted file mode 100644 index def92d6297b..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Union/E_UnionCapturesDiffType01.fs +++ /dev/null @@ -1,11 +0,0 @@ -// #Regression #Conformance #PatternMatching #Unions -// Verify error if two union rules capture values with different types -//This expression was expected to have type. 'int' .but here has type. 'float' - -let testMatch x = - match x with - | 0, 0.0 -> true - | x, 0.0 - | 0, x -> false - | _, _ -> false - diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Union/env.lst b/tests/fsharpqa/Source/Conformance/PatternMatching/Union/env.lst deleted file mode 100644 index 0c296584ea2..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Union/env.lst +++ /dev/null @@ -1,8 +0,0 @@ - SOURCE=unionPattern01.fs # unionPattern01.fs - SOURCE=unionPattern02.fs # unionPattern02.fs - SOURCE=unionPattern03.fs # unionPattern03.fs - SOURCE=unionPattern04.fs # unionPattern04.fs - - SOURCE=E_NotAllCaptureSameVal01.fs # E_NotAllCaptureSameVal01.fs -xxx SOURCE=E_UnionCapturesDiffType01.fs SCFLAGS="--test:ErrorRanges --flaterrors" # E_UnionCapturesDiffType01.fs - SOURCE=E_CapturesDiffVal01.fs # E_CapturesDiffVal01.fs diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Union/unionPattern01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Union/unionPattern01.fs deleted file mode 100644 index 065c374776d..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Union/unionPattern01.fs +++ /dev/null @@ -1,21 +0,0 @@ -// #Conformance #PatternMatching #Unions -#light - -type Foo = - | A of int * string - | B of string * int - -let test x = - match x with - | A (x, "cheese") - | B (_, x) when x > 0 - -> x - | _ -> 0 - -if test (A(100, "")) <> 0 then exit 1 -if test (A(100, "cheese")) <> 100 then exit 1 - -if test (B("", -100)) <> 0 then exit 1 -if test (B("", 42)) <> 42 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Union/unionPattern02.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Union/unionPattern02.fs deleted file mode 100644 index c06ef31ab0a..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Union/unionPattern02.fs +++ /dev/null @@ -1,18 +0,0 @@ -// #Conformance #PatternMatching #Unions -#light - -// Test a match statement with just one 'match thingey' -type Foo = A | B of string | C of int - -let test x = - match x with - | A - | B _ - | C (_) - -> true - -if (test (A)) <> true then exit 1 -if (test (B(""))) <> true then exit 1 -if (test (C(0))) <> true then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Union/unionPattern03.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Union/unionPattern03.fs deleted file mode 100644 index 95f9bcb6925..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Union/unionPattern03.fs +++ /dev/null @@ -1,33 +0,0 @@ -// #Conformance #PatternMatching #Unions -#light - -// Test that when there are two potential matches, they are matched in the order they are defined. -type Foo = A | B | C | D - -let test1 x = - match x with - | A | B -> 1 - | B | C -> 2 - | C | D -> 3 - | D | A -> 4 - -// The union of patterns should be considered a single entity, and thus -// their relative ordering shoudln't matter. -let test2 x = - match x with - | B | A -> 1 - | C | B -> 2 - | D | C -> 3 - | A | D -> 4 - -if test1 A <> 1 then exit 1 -if test1 B <> 1 then exit 1 -if test1 C <> 2 then exit 1 -if test1 D <> 3 then exit 1 - -if test2 A <> 1 then exit 1 -if test2 B <> 1 then exit 1 -if test2 C <> 2 then exit 1 -if test2 D <> 3 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Union/unionPattern04.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Union/unionPattern04.fs deleted file mode 100644 index fe58732f913..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Union/unionPattern04.fs +++ /dev/null @@ -1,12 +0,0 @@ -// #Regression #Conformance #PatternMatching #Unions -#light - -// Regression test for FSHARP1.0:3914 - Invalid value when returning a pattern match-bound parameter in the enclosure of a lambda (does that make sense?) - -type XDuTag = XDuTag - -let foo XDuTag = fun y -> XDuTag - -let bar = foo XDuTag 0.0 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Wildcard/env.lst b/tests/fsharpqa/Source/Conformance/PatternMatching/Wildcard/env.lst deleted file mode 100644 index 7b32de49ca7..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Wildcard/env.lst +++ /dev/null @@ -1 +0,0 @@ - SOURCE=wildCardPatterns01.fs # wildCardPatterns01.fs diff --git a/tests/fsharpqa/Source/Conformance/PatternMatching/Wildcard/wildCardPatterns01.fs b/tests/fsharpqa/Source/Conformance/PatternMatching/Wildcard/wildCardPatterns01.fs deleted file mode 100644 index a3bca207911..00000000000 --- a/tests/fsharpqa/Source/Conformance/PatternMatching/Wildcard/wildCardPatterns01.fs +++ /dev/null @@ -1,17 +0,0 @@ -// #Conformance #PatternMatching -#light - -// Verify that the shape of data matched against a wildcard -// doesn't have to match. - -let matchList x = - match x with - | fsd :: second :: tail -> false - | last :: [] -> false - | _ -> true - -let matchTuple x = - match x with - | (1,2,3) | (3,4,5) -> false - | (x,_,9) -> false - | _ -> true diff --git a/tests/fsharpqa/Source/test.lst b/tests/fsharpqa/Source/test.lst index 7d700adc076..31b787ef41e 100644 --- a/tests/fsharpqa/Source/test.lst +++ b/tests/fsharpqa/Source/test.lst @@ -127,23 +127,6 @@ Conformance07 Conformance\ObjectOrientedTypeDefinitions\TypeExtensions\intrins Conformance07 Conformance\ObjectOrientedTypeDefinitions\TypeExtensions\optional Conformance07 Conformance\ObjectOrientedTypeDefinitions\TypeKindInference -Conformance07 Conformance\PatternMatching\And -Conformance07 Conformance\PatternMatching\Array -Conformance07 Conformance\PatternMatching\As -Conformance07 Conformance\PatternMatching\ConsList -Conformance07 Conformance\PatternMatching\DynamicTypeTest -Conformance07 Conformance\PatternMatching\Expression -Conformance07 Conformance\PatternMatching\Named -Conformance07 Conformance\PatternMatching\Null -Conformance07 Conformance\PatternMatching\Record -Conformance07 Conformance\PatternMatching\Simple -Conformance07 Conformance\PatternMatching\SimpleConstant -Conformance08 Conformance\PatternMatching\Tuple -Conformance08 Conformance\PatternMatching\TypeAnnotated -Conformance08 Conformance\PatternMatching\TypeConstraint -Conformance08 Conformance\PatternMatching\Union -Conformance08 Conformance\PatternMatching\Wildcard - Conformance08 Conformance\Signatures\SignatureConformance Conformance08 Conformance\Signatures\SignatureTypes