Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// #NoMT #CompilerOptions
// This test is designed to test the --codepage options.
// - The same source file (FunctionalLibrary01.fs) is compile twice, with different --codepage options
// - The same source file (libCodepage.fs) is compile twice, with different --codepage options
// - The library file is designed so that it gets compiled to slightly different assemblies
// - This file references both assemblies and should compile without problems
//<Expects status="success"></Expects>
Expand All @@ -10,4 +10,4 @@
let a = N.M.á.M()
let b = N.M.б.M()

(if a = b then 0 else 1) |> exit
if a = b then () else failwith "Failed: 1"
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
let x = "a"
let y = 'a'.ToString();

(if x = y then 0 else 1) |> exit
if x = y then () else failwith "Failed: 1"
Original file line number Diff line number Diff line change
@@ -0,0 +1,206 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace FSharp.Compiler.ComponentTests.CompilerOptions.fsc

open Xunit
open FSharp.Test
open FSharp.Test.Compiler
open System
open System.IO

module codepage =

let libCodepage1250 =
FsFromPath (Path.Combine(__SOURCE_DIRECTORY__, "libCodepage.fs"))
|> withCodepage "1250"
|> withName "libCodepage1250"
|> asLibrary

let libCodepage1251 =
FsFromPath (Path.Combine(__SOURCE_DIRECTORY__, "libCodepage.fs"))
|> withCodepage "1251"
|> withName "libCodepage1251"
|> asLibrary

let secondLibCodepage1250 =
FsFromPath (Path.Combine(__SOURCE_DIRECTORY__, "libCodepage.fs"))
|> withCodepage "1250"
|> withName "secondLibCodepage1250"
|> asLibrary


#if NETFRAMEWORK

[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ReferenceBoth.fs"|])>]
let ``Reference assembly compiled with same codepages`` compilation =
compilation
|> asExe
|> withReferences [ libCodepage1250; secondLibCodepage1250 ]
|> compile
|> shouldFail
|> withDiagnostics [
(Error 39, Line 11, Col 13, Line 11, Col 14, "The value, constructor, namespace or type 'б' is not defined.")
]

[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"ReferenceBoth.fs"|])>]
let ``Reference assembly compiled with different codepages`` compilation =
compilation
|> asExe
|> withReferences [ libCodepage1250; libCodepage1251 ]
|> compileAndRun
|> shouldSucceed
#endif

//# Boundary case
// SOURCE=E_NoDataForEncoding65535.fs SCFLAGS="--codepage:65535" # E_NoDataForEncoding65535.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_InvalidArgument.fs"|])>]
let ``Reference assembly compiled with no data for codepage`` compilation =
compilation
|> withCodepage "65535"
|> asExe
|> compile
|> shouldFail
|> withDiagnostics [
(Error 193, Line 1, Col 1, Line 1, Col 1, "No data is available for encoding 65535. For information on defining a custom encoding, see the documentation for the Encoding.RegisterProvider method.")
]

//# Boundary case
// SOURCE=Zero.fs SCFLAGS="--codepage:0x0" # Zero.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"Zero.fs"|])>]
let ``Reference assembly compiled with zero for codepage`` compilation =
compilation
|> withNoWarn 52
|> withCodepage "0x0"
|> asExe
|> compileAndRun
|> shouldSucceed


//# Negative cases
// SOURCE=E_OutOfRangeArgument01.fs SCFLAGS="--codepage:65536" # E_OutOfRangeArgument01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_InvalidArgument.fs"|])>]
let ``OutOfRangeArgument01_fs`` compilation =
compilation
|> asExe
|> withCodepage "65536"
|> compile
|> shouldFail
|> withDiagnostics [
#if NETFRAMEWORK
(Error 1000, Line 0, Col 1, Line 0, Col 1, "Problem with codepage '65536': Valid values are between 0 and 65535, inclusive.
Parameter name: codepage")
#else
(Error 1000, Line 0, Col 1, Line 0, Col 1, "Problem with codepage '65536': Valid values are between 0 and 65535, inclusive. (Parameter 'codepage')")
#endif
]

// SOURCE=E_OutOfRangeArgument01.fs SCFLAGS="--codepage:65536" FSIMODE=EXEC # E_OutOfRangeArgument01.fs-fsi
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_InvalidArgument.fs"|])>]
let ``E_OutOfRangeArgument01_fsx`` compilation =
compilation
|> asFsx
|> withCodepage "65536"
|> compile
|> shouldFail
|> withDiagnostics [
#if NETFRAMEWORK
(Error 1000, Line 0, Col 1, Line 0, Col 1, "Problem with codepage '65536': Valid values are between 0 and 65535, inclusive.
Parameter name: codepage")
#else
(Error 1000, Line 0, Col 1, Line 0, Col 1, "Problem with codepage '65536': Valid values are between 0 and 65535, inclusive. (Parameter 'codepage')")
#endif
]

// SOURCE=E_NegativeArgument01.fs SCFLAGS="--codepage:-1" # E_NegativeArgument01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_InvalidArgument.fs"|])>]
let ``E_NegativeArgument01_fs`` compilation =
compilation
|> asExe
|> withCodepage "-1"
|> compile
|> shouldFail
|> withDiagnostics [
#if NETFRAMEWORK
(Error 1000, Line 0, Col 1, Line 0, Col 1, "Problem with codepage '-1': Valid values are between 0 and 65535, inclusive.
Parameter name: codepage")
#else
(Error 1000, Line 0, Col 1, Line 0, Col 1, "Problem with codepage '-1': Valid values are between 0 and 65535, inclusive. (Parameter 'codepage')")
#endif
]

// SOURCE=E_NegativeArgument01.fs SCFLAGS="--codepage:-1" FSIMODE=EXEC # E_NegativeArgument01.fs-fsi
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_InvalidArgument.fs"|])>]
let ``E_NegativeArgument01_fsx`` compilation =
compilation
|> asFsx
|> withCodepage "-1"
|> compile
|> shouldFail
|> withDiagnostics [
#if NETFRAMEWORK
(Error 1000, Line 0, Col 1, Line 0, Col 1, "Problem with codepage '-1': Valid values are between 0 and 65535, inclusive.
Parameter name: codepage")
#else
(Error 1000, Line 0, Col 1, Line 0, Col 1, "Problem with codepage '-1': Valid values are between 0 and 65535, inclusive. (Parameter 'codepage')")
#endif
]

// SOURCE=E_NotAValidInteger01.fs SCFLAGS="--codepage:invalidinteger" # E_NotAValidInteger01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_InvalidArgument.fs"|])>]
let ``E_NotAValidInteger01_fs`` compilation =
compilation
|> asExe
|> withCodepage "invalidinteger"
|> compile
|> shouldFail
|> withDiagnostics [
(Error 241, Line 0, Col 1, Line 0, Col 1, "'invalidinteger' is not a valid integer argument")
]

// SOURCE=E_NotAValidInteger01.fs SCFLAGS="--codepage:invalidinteger" FSIMODE=EXEC # E_NotAValidInteger01.fs-fsi
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_InvalidArgument.fs"|])>]
let ``E_NotAValidInteger01_fsx`` compilation =
compilation
|> asFsx
|> withCodepage "invalidinteger"
|> compile
|> shouldFail
|> withDiagnostics [
(Error 241, Line 0, Col 1, Line 0, Col 1, "'invalidinteger' is not a valid integer argument")
]

// SOURCE=E_RequiresParameter01.fs TAILFLAGS="--codepage" # E_RequiresParameter01.fs
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_InvalidArgument.fs"|])>]
let ``E_RequiresParameter01_fs`` compilation =
compilation
|> asExe
|> withOptions ["--codepage"]
|> compile
|> shouldFail
|> withDiagnostics [
(Error 224, Line 0, Col 1, Line 0, Col 1, "Option requires parameter: --codepage:<n>")
]

// SOURCE=E_RequiresParameter01.fs TAILFLAGS="--codepage" FSIMODE=EXEC # E_RequiresParameter01.fs-fsi
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_InvalidArgument.fs"|])>]
let ``E_RequiresParameter01_fsx`` compilation =
compilation
|> asFsx
|> withOptions ["--codepage"]
|> compile
|> shouldFail
|> withDiagnostics [
(Error 224, Line 0, Col 1, Line 0, Col 1, "Option requires parameter: --codepage:<n>")
]

// SOURCE=E_DefaultCodePage02.fsx COMPILE_ONLY=1 # E_DefaultCodePage02.fsx
[<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"libCodepage.fs"|])>]
let ``libCodepage_fs`` compilation =
compilation
|> asLibrary
|> compile
|> shouldFail
|> withDiagnostics [
(Error 10, Line 7, Col 10, Line 7, Col 11, "Unexpected character '�' in type name")
(Error 10, Line 9, Col 14, Line 9, Col 17, "Unexpected keyword 'end' in implementation file")
]
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

namespace N

module M =
module M =
type � = class
static member M() = 11
end
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,7 @@
<Compile Include="TypeChecks\ParallelCheckingWithSignatureFilesTests.fs" />
<Compile Include="CompilerOptions\fsc\checked\checked.fs" />
<Compile Include="CompilerOptions\fsc\cliversion.fs" />
<Compile Include="CompilerOptions\fsc\codepage\codepage.fs" />
<Compile Include="CompilerOptions\fsc\debug.fs" />
<Compile Include="CompilerOptions\fsc\langversion.fs" />
<Compile Include="CompilerOptions\fsc\noframework\noframework.fs" />
Expand Down
3 changes: 3 additions & 0 deletions tests/FSharp.Test.Utilities/Compiler.fs
Original file line number Diff line number Diff line change
Expand Up @@ -354,6 +354,9 @@ module rec Compiler =
| FS fs -> FS { fs with Options = fs.Options @ options }
| _ -> failwith message

let withCodepage (codepage:string) (cUnit: CompilationUnit) : CompilationUnit =
withOptionsHelper [ $"--codepage:{codepage}" ] "codepage is only supported on F#" cUnit

let withDebug (cUnit: CompilationUnit) : CompilationUnit =
withOptionsHelper [ "--debug+" ] "debug+ is only supported on F#" cUnit

Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

34 changes: 0 additions & 34 deletions tests/fsharpqa/Source/CompilerOptions/fsc/codepage/env.lst

This file was deleted.

2 changes: 0 additions & 2 deletions tests/fsharpqa/Source/CompilerOptions/fsc/codepage/keep.lst

This file was deleted.

1 change: 0 additions & 1 deletion tests/fsharpqa/Source/test.lst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
# ReqNOCov -- skip this test/suite if we are doing a code coverage run
# ReqENU -- skip this test/suite if we are running on non-ENU (useful to exclude hard-to-localize tests)

CompilerOptions01,NoMT CompilerOptions\fsc\codepage
CompilerOptions01,NoMT CompilerOptions\fsc\crossoptimize
CompilerOptions01,NoMT,Determinism CompilerOptions\fsc\determinism
CompilerOptions01,NoMT CompilerOptions\fsc\dumpAllCommandLineOptions
Expand Down