diff --git a/src/fsharp/xlf/FSComp.txt.es.xlf b/src/fsharp/xlf/FSComp.txt.es.xlf index 56f087fb38d..279d16a7c90 100644 --- a/src/fsharp/xlf/FSComp.txt.es.xlf +++ b/src/fsharp/xlf/FSComp.txt.es.xlf @@ -124,7 +124,7 @@ All branches of a pattern match expression must return values of the same type as the first branch, which here is '{0}'. This branch returns a value of type '{1}'. - Todas las ramas de una expresión de coincidencia de patrón deben devolver valores del mismo tipo. La primera rama devolvió un valor de tipo "{0}", pero esta rama devolvió un valor de tipo "\{1 \}". + All branches of a pattern match expression must return values of the same type as the first branch, which here is '{0}'. This branch returns a value of type '{1}'. diff --git a/tests/fsharp/Compiler/Conformance/BasicGrammarElements/BasicConstants.fs b/tests/fsharp/Compiler/Conformance/BasicGrammarElements/BasicConstants.fs new file mode 100644 index 00000000000..9bae4946568 --- /dev/null +++ b/tests/fsharp/Compiler/Conformance/BasicGrammarElements/BasicConstants.fs @@ -0,0 +1,177 @@ +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. + +namespace FSharp.Compiler.UnitTests + +open NUnit.Framework +open FSharp.Compiler.SourceCodeServices + +[] +module ``Basic Grammar Element Constants`` = + + [] + let `` Basic constants compile `` () = + CompilerAssert.Pass + """ +let sbyteConst = 1y +let int16Const = 1us +let int32Const = 1ul +let int64Const = 1UL + +let byteConst = 1uy +let uint16Const = 1us +let uint32Const = 1ul +let uint64Const = 1uL + +let ieee32Const1 = 1.0f +let ieee32Const2 = 1.0F +let ieee32Const3 = 0x0000000000000001lf + +let ieee64Const1 = 1.0 +let ieee64Const2 = 0x0000000000000001LF + +let bigintConst = 1I + +// let bignumConst = 1N - you need a reference to PowerPack.dll now + +let decimalConst1 = 1.0M +let decimalConst2 = 1.0m + +let charConst = '1' + +let stringConst = "1" + +let bytestringConst = "1"B + +let bytecharConst = '1'B + +let boolConst1 = true +let boolConst2 = false + +let unitConst = () + """ + + [] + let ``Long with underscores``() = + CompilerAssert.CompileExeAndRun + """ +let creditCardNumber = 1234_5678_9012_3456L +let socialSecurityNumber = 999_99_9999L + +if socialSecurityNumber <> 999999999L then failwith "Wrong parsing" +if creditCardNumber <> 1234567890123456L then failwith "Wrong parsing" +exit 0 + """ + + [] + let ``float 32 with underscores``() = + CompilerAssert.CompileExeAndRun + """ +let pi = 3.14_15F +if pi <> 3.1415F then failwith "Wrong parsing" +exit 0 + """ + + [] + let ``int with underscores hexBytes``() = + CompilerAssert.CompileExeAndRun + """ +let hexBytes = 0xFF_EC_DE_5E +if hexBytes <> 0xFFECDE5E then failwith "Wrong parsing" +exit 0 + """ + + + [] + let ``int with underscore hexWords``() = + CompilerAssert.CompileExeAndRun + """ +let hexWords = 0xCAFE_BABE +if hexWords <> 0xCAFEBABE then failwith "Wrong parsing" +exit 0 + """ + + [] + let ``Long with underscores maxLong``() = + CompilerAssert.CompileExeAndRun + """ +let maxLong = 0x7fff_ffff_ffff_ffffL +if maxLong <> 0x7fffffffffffffffL then failwith "Wrong parsing" +exit 0 + """ + + [] + let ``int with underscore nybbles``() = + CompilerAssert.CompileExeAndRun + """ +let nybbles = 0b0010_0101 +if nybbles <> 0b00100101 then failwith "Wrong parsing" +exit 0 + """ + + [] + let ``int with underscores bytes``() = + CompilerAssert.CompileExeAndRun + """ +let bytes = 0b11010010_01101001_10010100_10010010 +if bytes <> 0b11010010011010011001010010010010 then failwith "Wrong parsing" +exit 0 + """ + + [] + let ``int with single underscore literal``() = + CompilerAssert.CompileExeAndRun + """ +let x2 = 5_2 +if x2 <> 52 then failwith "Wrong parsing" +exit 0 + """ + + [] + let ``int with multiple underscores literal``() = + CompilerAssert.CompileExeAndRun + """ +let x4 = 5_______2 +if x4 <> 52 then failwith "Wrong parsing" +exit 0 + """ + + [] + let ``int with single underscore Hex literal``() = + CompilerAssert.CompileExeAndRun + """ +let x7 = 0x5_2 +if x7 <> 0x52 then + failwith "Wrong parsing" +exit 0 + """ + + [] + let ``int with single underscore after leading zero literal``() = + CompilerAssert.CompileExeAndRun + """ +let x9 = 0_52 +if x9 <> 052 then failwith "Wrong parsing" +exit 0 + """ + + [] + let ``int with single underscore after leteral with leading zero ``() = + CompilerAssert.CompileExeAndRun + """ +let x10 = 05_2 +if x10 <> 052 then failwith "Wrong parsing" +exit 0 + """ + + [] + let ``int with single underscore after octo leteral ``() = + CompilerAssert.CompileExeAndRun + """ +let x14 = 0o5_2 +if x14 <> 0o52 then failwith "Wrong parsing" +exit 0 + """ + + + + diff --git a/tests/fsharp/FSharpSuite.Tests.fsproj b/tests/fsharp/FSharpSuite.Tests.fsproj index 9f3aeee1e43..f3262e5938e 100644 --- a/tests/fsharp/FSharpSuite.Tests.fsproj +++ b/tests/fsharp/FSharpSuite.Tests.fsproj @@ -32,6 +32,7 @@ + diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/BasicConstants.fs b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/BasicConstants.fs deleted file mode 100644 index 78303d2713e..00000000000 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/BasicConstants.fs +++ /dev/null @@ -1,99 +0,0 @@ -// #Conformance #BasicGrammarElements #Constants -#light - -// Verify the ability to specify basic constants - -let sbyteConst = 1y -let int16Const = 1us -let int32Const = 1ul -let int64Const = 1UL - -let byteConst = 1uy -let uint16Const = 1us -let uint32Const = 1ul -let uint64Const = 1uL - -let ieee32Const1 = 1.0f -let ieee32Const2 = 1.0F -let ieee32Const3 = 0x0000000000000001lf - -let ieee64Const1 = 1.0 -let ieee64Const2 = 0x0000000000000001LF - -let bigintConst = 1I - -// let bignumConst = 1N - you need a reference to PowerPack.dll now - -let decimalConst1 = 1.0M -let decimalConst2 = 1.0m - -let charConst = '1' - -let stringConst = "1" - -let bytestringConst = "1"B - -let bytecharConst = '1'B - -let boolConst1 = true -let boolConst2 = false - -let unitConst = () - -let creditCardNumber = 1234_5678_9012_3456L -if creditCardNumber <> 1234567890123456L then - failwith "Wrong parsing" - -let socialSecurityNumber = 999_99_9999L -if socialSecurityNumber <> 999999999L then - failwith "Wrong parsing" - -let pi = 3.14_15F -if pi <> 3.1415F then - failwith "Wrong parsing" - -let hexBytes = 0xFF_EC_DE_5E -if hexBytes <> 0xFFECDE5E then - failwith "Wrong parsing" - -let hexWords = 0xCAFE_BABE -if hexWords <> 0xCAFEBABE then - failwith "Wrong parsing" - -let maxLong = 0x7fff_ffff_ffff_ffffL -if maxLong <> 0x7fffffffffffffffL then - failwith "Wrong parsing" - -let nybbles = 0b0010_0101 -if nybbles <> 0b00100101 then - failwith "Wrong parsing" - -let bytes = 0b11010010_01101001_10010100_10010010 -if bytes <> 0b11010010011010011001010010010010 then - failwith "Wrong parsing" - -let x2 = 5_2 -if x2 <> 52 then - failwith "Wrong parsing" - -let x4 = 5_______2 -if x4 <> 52 then - failwith "Wrong parsing" - -let x7 = 0x5_2 -if x7 <> 0x52 then - failwith "Wrong parsing" - -let x9 = 0_52 -if x9 <> 052 then - failwith "Wrong parsing" - -let x10 = 05_2 -if x10 <> 052 then - failwith "Wrong parsing" - -let x14 = 0o5_2 -if x14 <> 0o52 then - failwith "Wrong parsing" - -exit 0 diff --git a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst index 500d42d77e1..97183b49781 100644 --- a/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst +++ b/tests/fsharpqa/Source/Conformance/BasicGrammarElements/Constants/env.lst @@ -1,4 +1,3 @@ - SOURCE=BasicConstants.fs # BasicConstants.fs NOMONO,NoMT SOURCE=E_BasicConstantsBigNum40.fsx SCFLAGS="--test:ErrorRanges" # E_BasicConstantsBigNum40.fsx