From c15b5c4ecf0a60a0c672ac39d17b0bbe07f421d3 Mon Sep 17 00:00:00 2001 From: "Thorsten (Gerbrunn)" Date: Sun, 5 Jul 2020 18:44:45 +0200 Subject: [PATCH 1/8] Migrated DecimalLiterals01.fs test case --- .../InvalidNumericLiteralTests.fs | 8 ++++ .../BasicGrammarElements/DecimalConstants.fs | 45 +++++++++++++++++++ tests/fsharp/FSharpSuite.Tests.fsproj | 1 + .../Constants/DecimalLiterals01.fs | 26 ----------- .../BasicGrammarElements/Constants/env.lst | 1 - 5 files changed, 54 insertions(+), 27 deletions(-) create mode 100644 tests/fsharp/Compiler/Conformance/BasicGrammarElements/DecimalConstants.fs delete mode 100644 tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/DecimalLiterals01.fs diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs index a20dd899762..851d7aa0d3c 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs @@ -18,3 +18,11 @@ let foo = 1up // int 1156 (2, 11, 2, 14) "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger)." + + [] + [] + [] + let ``Valid Numeric Literals`` literal = + // Regressiont test for FSharp1.0: 2543 - Decimal literals do not support exponents + + CompilerAssert.Pass ("let x = " + literal) \ No newline at end of file diff --git a/tests/fsharp/Compiler/Conformance/BasicGrammarElements/DecimalConstants.fs b/tests/fsharp/Compiler/Conformance/BasicGrammarElements/DecimalConstants.fs new file mode 100644 index 00000000000..e87b123c2f0 --- /dev/null +++ b/tests/fsharp/Compiler/Conformance/BasicGrammarElements/DecimalConstants.fs @@ -0,0 +1,45 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework + +[] +module ``Decimal Constants`` = + + [] + let ``Product of decimal constants``() = + let oneOfOneMiDec = 1.0E-6M + let oneMiDec = 1.0E+6M + + Assert.areEqual 1.0M (oneOfOneMiDec * oneMiDec) + + [] + let ``Sum of decimal constants``() = + let x = + 1.0E0M + + 2.0E1M + + 3.0E2M + + 4.0E3M + + 5.0E4M + + 6.0E5M + + 7.0E6M + + 8.0E7M + + 9.0E8M + + 1.0E-1M + + 2.0E-2M + + 3.0E-3M + + 4.0E-4M + + 5.0E-5M + + 6.0E-6M + + 7.0E-7M + + 8.0E-8M + + 9.0E-9M + + Assert.areEqual 987654321.123456789M x + + [] + let ``Sum of decimal literals with leading zero in exponential``() = + let x = 1.0E00M + 2.0E01M + 3.E02M + 1.E-01M + 2.0E-02M + + Assert.areEqual 321.12M x \ No newline at end of file diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index a9d05e1fb76..026c06b2eff 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -33,6 +33,7 @@ + diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/DecimalLiterals01.fs b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/DecimalLiterals01.fs deleted file mode 100644 index f78853a422b..00000000000 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/DecimalLiterals01.fs +++ /dev/null @@ -1,26 +0,0 @@ -// #Regression #Conformance #BasicGrammarElements #Constants -#light - -// Regressiont test for FSharp1.0: 2543 - Decimal literals do not support exponents - -let oneOfOneMiDec = 1.0E-6M -let oneMiDec = 1.0E+6M - -let one = oneOfOneMiDec * oneMiDec - -if one <> 1.0M then exit 1 - -let result = 1.0E0M + 2.0E1M + 3.0E2M + 4.0E3M + 5.0E4M + 6.0E5M + 7.0E6M + 8.0E7M + 9.0E8M + - 1.0E-1M + 2.0E-2M + 3.0E-3M + 4.0E-4M + 5.0E-5M + 6.0E-6M + 7.0E-7M + 8.0E-8M + 9.0E-9M - -if result <> 987654321.123456789M then exit 1 - -// Test boundary case -let xMax = 1.0E28M -let XMin = 1.0E-28M - -// Test with leading zeros in exponential and -let y = 1.0E00M + 2.0E01M + 3.E02M + 1.E-01M + 2.0E-02M -if y <> 321.12M then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst index 97183b49781..905ee2d483d 100644 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst +++ b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst @@ -5,7 +5,6 @@ NOMONO,NoMT SOURCE=E_BasicConstantsBigNum40.fsx SCFLAGS="--test:ErrorRanges" # E SOURCE=NegativeNumbers02.fs # NegativeNumbers02.fs SOURCE=NegativeNumbers03.fs # NegativeNumbers03.fs - SOURCE=DecimalLiterals01.fs # DecimalLiterals01.fs # DecimalLiteral02.fs involves rounding of decimals. The F# design is to follow the BCL. # This means that the behavior is not deterministic, e.g. Mono and NetFx4 round; NetFx2 gives an error From 5e3f28252c2c46e8ad39b6214d50e2b6a61a0983 Mon Sep 17 00:00:00 2001 From: "Thorsten (Gerbrunn)" Date: Sun, 5 Jul 2020 18:55:33 +0200 Subject: [PATCH 2/8] Migrated DecimalConstants02.fs test case --- .../BasicGrammarElements/DecimalConstants.fs | 11 ++++++++++- .../Constants/DecimalLiterals02.fs | 11 ----------- .../BasicGrammarElements/Constants/env.lst | 4 +--- 3 files changed, 11 insertions(+), 15 deletions(-) delete mode 100644 tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/DecimalLiterals02.fs diff --git a/tests/fsharp/Compiler/Conformance/BasicGrammarElements/DecimalConstants.fs b/tests/fsharp/Compiler/Conformance/BasicGrammarElements/DecimalConstants.fs index e87b123c2f0..4fd012f7a03 100644 --- a/tests/fsharp/Compiler/Conformance/BasicGrammarElements/DecimalConstants.fs +++ b/tests/fsharp/Compiler/Conformance/BasicGrammarElements/DecimalConstants.fs @@ -42,4 +42,13 @@ module ``Decimal Constants`` = let ``Sum of decimal literals with leading zero in exponential``() = let x = 1.0E00M + 2.0E01M + 3.E02M + 1.E-01M + 2.0E-02M - Assert.areEqual 321.12M x \ No newline at end of file + Assert.areEqual 321.12M x + + [] + let ``Non-representable small values are rounded to zero``() = + // This test involves rounding of decimals. The F# design is to follow the BCL. + // This means that the behavior is not deterministic, e.g. Mono and NetFx4 round; NetFx2 gives an error + // This is a positive test on Dev10, at least until + // FSHARP1.0:4523 gets resolved. + + Assert.areEqual 0.0M 1.0E-50M \ No newline at end of file diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/DecimalLiterals02.fs b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/DecimalLiterals02.fs deleted file mode 100644 index ff61e0a1b47..00000000000 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/DecimalLiterals02.fs +++ /dev/null @@ -1,11 +0,0 @@ -// #Regression #Conformance #BasicGrammarElements #Constants #NoMono -// This is a positive test on Dev10, at least until -// FSHARP1.0:4523 gets resolved. -// - -let ok = 1.0E-50M // parses ok on Dev10 - -if ok <> 0.0M then - exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst index 905ee2d483d..8b182bec37d 100644 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst +++ b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst @@ -6,9 +6,7 @@ NOMONO,NoMT SOURCE=E_BasicConstantsBigNum40.fsx SCFLAGS="--test:ErrorRanges" # E SOURCE=NegativeNumbers03.fs # NegativeNumbers03.fs -# DecimalLiteral02.fs involves rounding of decimals. The F# design is to follow the BCL. -# This means that the behavior is not deterministic, e.g. Mono and NetFx4 round; NetFx2 gives an error - SOURCE=DecimalLiterals02.fs # DecimalLiterals02.fs + SOURCE=FullSetOfEscapeCharacters.fs # FullSetOfEscapeCharacters.fs SOURCE=E_UnderscoreLiterals.fs SCFLAGS="--test:ErrorRanges" # E_UnderscoreLiterals.fs \ No newline at end of file From 7c6296db54c3ca9def8d5080d9f7ec365eb3dde4 Mon Sep 17 00:00:00 2001 From: "Thorsten (Gerbrunn)" Date: Sun, 5 Jul 2020 19:01:36 +0200 Subject: [PATCH 3/8] Migrated E_BasicConstantsBigNum01.fs test case --- .../ErrorMessages/InvalidNumericLiteralTests.fs | 12 ++++++++++++ .../Constants/E_BasicConstantsBigNum01.fsx | 7 ------- 2 files changed, 12 insertions(+), 7 deletions(-) delete mode 100644 tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/E_BasicConstantsBigNum01.fsx diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs index 851d7aa0d3c..261b272a72b 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs @@ -19,6 +19,18 @@ let foo = 1up // int (2, 11, 2, 14) "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger)." + [] + let ``1N is invalid numeric literal``() = + CompilerAssert.TypeCheckSingleError + """ +let x = 1N + """ + FSharpErrorSeverity.Error + 0784 + (2, 9, 2, 11) + "This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope" + + [] [] [] diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/E_BasicConstantsBigNum01.fsx b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/E_BasicConstantsBigNum01.fsx deleted file mode 100644 index acc2c91301a..00000000000 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/E_BasicConstantsBigNum01.fsx +++ /dev/null @@ -1,7 +0,0 @@ -// #Regression #Conformance #BasicGrammarElements #Constants -// Verify the ability to specify basic constants - continued - - -//This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope - -let bignumConst = 1N From 9c2d790985cb8774ca9216dcd2f30fffbff6daf9 Mon Sep 17 00:00:00 2001 From: "Thorsten (Gerbrunn)" Date: Sun, 5 Jul 2020 19:22:07 +0200 Subject: [PATCH 4/8] Migrated E_BasicConstantsBigNum40.fs test case --- .../ErrorMessages/InvalidNumericLiteralTests.fs | 13 +++++++++++++ .../Constants/E_BasicConstantsBigNum40.fsx | 11 ----------- .../BasicGrammarElements/Constants/env.lst | 1 - 3 files changed, 13 insertions(+), 12 deletions(-) delete mode 100644 tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/E_BasicConstantsBigNum40.fsx diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs index 261b272a72b..aa6f080852c 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs @@ -5,6 +5,7 @@ namespace FSharp.Compiler.ErrorMessages.ComponentTests open Xunit open FSharp.Test.Utilities open FSharp.Compiler.SourceCodeServices +open FSharp.Compiler.AbstractIL.Internal module ``Numeric Literals`` = @@ -30,6 +31,18 @@ let x = 1N (2, 9, 2, 11) "This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope" + [] + let ``1N is invalid numeric literal in FSI``() = + if Utils.runningOnMono then () + else + CompilerAssert.RunScriptWithOptions [| "--langversion:preview"; "--test:ErrorRanges" |] + """ +let x = 1N + """ + [ + "This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope"; + "Operation could not be completed due to earlier error" + ] [] [] diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/E_BasicConstantsBigNum40.fsx b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/E_BasicConstantsBigNum40.fsx deleted file mode 100644 index 8060826cfbd..00000000000 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/E_BasicConstantsBigNum40.fsx +++ /dev/null @@ -1,11 +0,0 @@ -// #Regression #Conformance #BasicGrammarElements #Constants #NoMono #ReqNOMT - -// Verify the ability to specify basic constants - continued - - -// error FS0191: This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope -//This numeric literal requires that a module 'NumericLiteralN' defining functions FromZero, FromOne, FromInt32, FromInt64 and FromString be in scope - -let bignumConst = 1N - -exit 1 diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst index 8b182bec37d..94007a09be0 100644 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst +++ b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst @@ -1,4 +1,3 @@ -NOMONO,NoMT SOURCE=E_BasicConstantsBigNum40.fsx SCFLAGS="--test:ErrorRanges" # E_BasicConstantsBigNum40.fsx SOURCE=NegativeNumbers01.fs # NegativeNumbers01.fs From 64591eb16d203bfb6c620d3cf3d3adaa9273c1e3 Mon Sep 17 00:00:00 2001 From: "Thorsten (Gerbrunn)" Date: Sun, 5 Jul 2020 19:23:20 +0200 Subject: [PATCH 5/8] Removed unlisted test case --- .../Constants/E_DecimalLiterals02.fs | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/E_DecimalLiterals02.fs diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/E_DecimalLiterals02.fs b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/E_DecimalLiterals02.fs deleted file mode 100644 index 18849f241c0..00000000000 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/E_DecimalLiterals02.fs +++ /dev/null @@ -1,9 +0,0 @@ -// #Regression #Conformance #BasicGrammarElements #Constants #NoMono -#light - -// Negative Regressiont test for FSharp1.0: 2543 - Decimal literals do not support exponents -//This number is outside the allowable range for decimal literals - -let invalidDec = 1.0E-50M - -exit 1 From dd19a4f107b4fc930e6530e7cb70ce29184ca01e Mon Sep 17 00:00:00 2001 From: "Thorsten (Gerbrunn)" Date: Sun, 5 Jul 2020 19:50:18 +0200 Subject: [PATCH 6/8] Migrated E_UnderscoreLiterals.fs test case --- .../InvalidNumericLiteralTests.fs | 45 ++++++++++++++++--- .../Constants/E_UnderscoreLiterals.fs | 30 ------------- .../BasicGrammarElements/Constants/env.lst | 3 +- 3 files changed, 41 insertions(+), 37 deletions(-) delete mode 100644 tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/E_UnderscoreLiterals.fs diff --git a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs index aa6f080852c..720f18a06da 100644 --- a/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs +++ b/tests/FSharp.Compiler.ComponentTests/ErrorMessages/InvalidNumericLiteralTests.fs @@ -9,16 +9,51 @@ open FSharp.Compiler.AbstractIL.Internal module ``Numeric Literals`` = + [] + [] + [] + [] + [] + [] + [] + [] + [] + [] + [] + [] + [] + [] + [] + let ``Invalid Numeric Literals`` literal = + CompilerAssert.TypeCheckSingleError + ("let x = " + literal) + FSharpErrorSeverity.Error + 1156 + (1, 9, 1, 9 + (String.length literal)) + "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger)." + + [] + let ``3_(dot)1415F is invalid numeric literal``() = + CompilerAssert.TypeCheckWithErrors + """ +let x = 3_.1415F + """ + [| + FSharpErrorSeverity.Error, 1156, (2, 9, 2, 11), "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger)."; + FSharpErrorSeverity.Error, 599, (2, 11, 2, 12),"Missing qualification after '.'" + |] + [] - let ``1up is invalid Numeric Literal``() = + let ``_52 is invalid numeric literal``() = CompilerAssert.TypeCheckSingleError """ -let foo = 1up // int +let x = _52 """ FSharpErrorSeverity.Error - 1156 - (2, 11, 2, 14) - "This is not a valid numeric literal. Valid numeric literals include 1, 0x1, 0o1, 0b1, 1l (int), 1u (uint32), 1L (int64), 1UL (uint64), 1s (int16), 1y (sbyte), 1uy (byte), 1.0 (float), 1.0f (float32), 1.0m (decimal), 1I (BigInteger)." + 39 + (2, 9, 2, 12) + "The value or constructor '_52' is not defined." + [] let ``1N is invalid numeric literal``() = diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/E_UnderscoreLiterals.fs b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/E_UnderscoreLiterals.fs deleted file mode 100644 index 7f7e1745b8c..00000000000 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/E_UnderscoreLiterals.fs +++ /dev/null @@ -1,30 +0,0 @@ -//This is not a valid numeric literal. Valid numeric literals include -//This is not a valid numeric literal. Valid numeric literals include -//This is not a valid numeric literal. Valid numeric literals include -//This is not a valid numeric literal. Valid numeric literals include -//This is not a valid numeric literal. Valid numeric literals include -//This is not a valid numeric literal. Valid numeric literals include -//This is not a valid numeric literal. Valid numeric literals include -//This is not a valid numeric literal. Valid numeric literals include -//This is not a valid numeric literal. Valid numeric literals include -//This is not a valid numeric literal. Valid numeric literals include -//This is not a valid numeric literal. Valid numeric literals include -//This is not a valid numeric literal. Valid numeric literals include -//This is not a valid numeric literal. Valid numeric literals include -//This is not a valid numeric literal. Valid numeric literals include - -let pi1 = 3_.1415F -let pi2 = 3._1415F -let socialSecurityNumber1 = 999_99_9999_L -let x1 = _52 -let x2 = 52_ -let x3 = 0_x52 -let x4 = 0x_52 -let x5 = 0x52_ -let x6 = 052_ -let x7 = 0_o52 -let x8 = 0o_52 -let x9 = 0o52_ -let x10 = 2.1_e2F -let x11 = 2.1e_2F -let x12 = 1.0_F \ No newline at end of file diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst index 94007a09be0..4372e954fe3 100644 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst +++ b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst @@ -7,5 +7,4 @@ - SOURCE=FullSetOfEscapeCharacters.fs # FullSetOfEscapeCharacters.fs - SOURCE=E_UnderscoreLiterals.fs SCFLAGS="--test:ErrorRanges" # E_UnderscoreLiterals.fs \ No newline at end of file + SOURCE=FullSetOfEscapeCharacters.fs # FullSetOfEscapeCharacters.fs \ No newline at end of file From cf810f519ad37ae8d06a171955996418c4297ad9 Mon Sep 17 00:00:00 2001 From: "Thorsten (Gerbrunn)" Date: Sun, 5 Jul 2020 19:55:28 +0200 Subject: [PATCH 7/8] Migrated FullSetOfEscapeCharacters.fs test case --- .../BasicGrammarElements/CharConstants.fs | 21 +++++++++++++++++++ tests/fsharp/FSharpSuite.Tests.fsproj | 1 + .../Constants/FullSetOfEscapeCharacters.fs | 21 ------------------- .../BasicGrammarElements/Constants/env.lst | 2 -- 4 files changed, 22 insertions(+), 23 deletions(-) create mode 100644 tests/fsharp/Compiler/Conformance/BasicGrammarElements/CharConstants.fs delete mode 100644 tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/FullSetOfEscapeCharacters.fs diff --git a/tests/fsharp/Compiler/Conformance/BasicGrammarElements/CharConstants.fs b/tests/fsharp/Compiler/Conformance/BasicGrammarElements/CharConstants.fs new file mode 100644 index 00000000000..0ff4375ce51 --- /dev/null +++ b/tests/fsharp/Compiler/Conformance/BasicGrammarElements/CharConstants.fs @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework + +[] +module ``Char Constants`` = + + [] // alert + [] // backspace + [] // horizontal tab + [] // new line + [] // vertical tab + [] // form feed + [] // return + [] // double quote + [] // single quote + [] // backslash + let ``Escape characters`` character value = + Assert.areEqual character (char value) \ No newline at end of file diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index 026c06b2eff..d7fef85fd5b 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -33,6 +33,7 @@ + diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/FullSetOfEscapeCharacters.fs b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/FullSetOfEscapeCharacters.fs deleted file mode 100644 index e3015854a5e..00000000000 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/FullSetOfEscapeCharacters.fs +++ /dev/null @@ -1,21 +0,0 @@ -// #Regression #Conformance #BasicGrammarElements #Constants -#light - -// Regression test for FSharp1.0: 2956 - F# should have parity with C# wrt escape characters - -let isEscape = - true - && ('\a' = char 7 ) // alert - && ('\b' = char 8 ) // backspace - && ('\t' = char 9 ) // horizontal tab - && ('\n' = char 10) // new line - && ('\v' = char 11) // vertical tab - && ('\f' = char 12) // form feed - && ('\r' = char 13) // return - && ('\"' = char 34) // double quote - && ('\'' = char 39) // single quote - && ('\\' = char 92) // backslash - -if not isEscape then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst index 4372e954fe3..d6b01b54ffb 100644 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst +++ b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst @@ -6,5 +6,3 @@ - - SOURCE=FullSetOfEscapeCharacters.fs # FullSetOfEscapeCharacters.fs \ No newline at end of file From 3eea6772de13964fb3241d6f8f1472a383b7fabe Mon Sep 17 00:00:00 2001 From: "Thorsten (Gerbrunn)" Date: Sun, 5 Jul 2020 20:03:57 +0200 Subject: [PATCH 8/8] Migrated NegativeNumbers01.fs, NegativeNumbers02.fs, NegativeNumbers03.fs test cases --- .../BasicGrammarElements/IntegerConstants.fs | 44 +++++++++++++++++++ tests/fsharp/FSharpSuite.Tests.fsproj | 1 + .../Constants/NegativeNumbers01.fs | 14 ------ .../Constants/NegativeNumbers02.fs | 15 ------- .../Constants/NegativeNumbers03.fs | 13 ------ .../BasicGrammarElements/Constants/env.lst | 8 ---- 6 files changed, 45 insertions(+), 50 deletions(-) create mode 100644 tests/fsharp/Compiler/Conformance/BasicGrammarElements/IntegerConstants.fs delete mode 100644 tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/NegativeNumbers01.fs delete mode 100644 tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/NegativeNumbers02.fs delete mode 100644 tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/NegativeNumbers03.fs delete mode 100644 tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst diff --git a/tests/fsharp/Compiler/Conformance/BasicGrammarElements/IntegerConstants.fs b/tests/fsharp/Compiler/Conformance/BasicGrammarElements/IntegerConstants.fs new file mode 100644 index 00000000000..a5be0ccde11 --- /dev/null +++ b/tests/fsharp/Compiler/Conformance/BasicGrammarElements/IntegerConstants.fs @@ -0,0 +1,44 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework + +[] +module ``Integer Constants`` = + + [] + let ``Operations with negative one``() = + // Verify the ability to specify negative numbers + // (And not get confused wrt subtraction.) + + let x = -1 + + Assert.areEqual -2 (x + x) + Assert.areEqual 0 (x - x) + Assert.areEqual 1 (x * x) + Assert.areEqual 1 (x / x) + + [] + let ``Operations with negative integers``() = + // Verify the ability to specify negative numbers + // (And not get confused wrt subtraction.) + + let fiveMinusSix = 5 - 6 + let fiveMinusSeven = 5-7 + let negativeSeven = -7 + + Assert.areEqual -1 fiveMinusSix + Assert.areEqual -2 fiveMinusSeven + Assert.areEqual (-1 * 7) negativeSeven + + [] + let ``Functions with negative integers``() = + // Verify the ability to specify negative numbers + // (And not get confused wrt subtraction.) + + let ident x = x + let add x y = x + y + + Assert.areEqual -10 (ident -10) + Assert.areEqual -10 (add -5 -5) \ No newline at end of file diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index d7fef85fd5b..f8d78ae0d17 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -35,6 +35,7 @@ + diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/NegativeNumbers01.fs b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/NegativeNumbers01.fs deleted file mode 100644 index 1291c1377b5..00000000000 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/NegativeNumbers01.fs +++ /dev/null @@ -1,14 +0,0 @@ -// #Conformance #BasicGrammarElements #Constants -#light - -// Verify the ability to specify negative numbers -// (And not get confused wrt subtraction.) - -let x = -1 - -if x + x <> -2 then exit 1 -if x - x <> 0 then exit 1 -if x * x <> 1 then exit 1 -if x / x <> 1 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/NegativeNumbers02.fs b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/NegativeNumbers02.fs deleted file mode 100644 index c9b43056971..00000000000 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/NegativeNumbers02.fs +++ /dev/null @@ -1,15 +0,0 @@ -// #Conformance #BasicGrammarElements #Constants -#light - -// Verify the ability to specify negative numbers -// (And not get confused wrt subtraction.) - -let fiveMinusSix = 5 - 6 -let fiveMinusSeven = 5-7 -let negativeSeven = -7 - -if fiveMinusSix <> -1 then exit 1 -if fiveMinusSeven <> -2 then exit 1 -if negativeSeven <> -1 * 7 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/NegativeNumbers03.fs b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/NegativeNumbers03.fs deleted file mode 100644 index 751d026a469..00000000000 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/NegativeNumbers03.fs +++ /dev/null @@ -1,13 +0,0 @@ -// #Conformance #BasicGrammarElements #Constants -#light - -// Verify the ability to specify negative numbers -// (And not get confused wrt subtraction.) - -let ident x = x -let add x y = x + y - -if ident -10 <> -10 then exit 1 -if add -5 -5 <> -10 then exit 1 - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst deleted file mode 100644 index d6b01b54ffb..00000000000 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst +++ /dev/null @@ -1,8 +0,0 @@ - - - SOURCE=NegativeNumbers01.fs # NegativeNumbers01.fs - SOURCE=NegativeNumbers02.fs # NegativeNumbers02.fs - SOURCE=NegativeNumbers03.fs # NegativeNumbers03.fs - - -