|
| 1 | +// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information. |
| 2 | + |
| 3 | +namespace FSharp.Compiler.ComponentTests.Conformance |
| 4 | + |
| 5 | +open Xunit |
| 6 | +open FSharp.Test |
| 7 | +open FSharp.Test.Compiler |
| 8 | + |
| 9 | +module EntryPoint = |
| 10 | + |
| 11 | + // SOURCE=behavior001.fs # noarguments001.fs |
| 12 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"behavior001.fs"|])>] |
| 13 | + let ``behavior001_fs`` compilation = |
| 14 | + compilation |
| 15 | + |> asExe |
| 16 | + |> compile |
| 17 | + |> shouldSucceed |
| 18 | + |
| 19 | + // SOURCE=noarguments001.fs # noarguments001.fs |
| 20 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"noarguments001.fs"|])>] |
| 21 | + let ``noarguments001_fs`` compilation = |
| 22 | + compilation |
| 23 | + |> asExe |
| 24 | + |> compile |
| 25 | + |> shouldSucceed |
| 26 | + |
| 27 | + |
| 28 | + //NoMT SOURCE="twofiles_001a.fs twofiles_001b.fs" # twofiles_001a/b |
| 29 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"twofiles_001a.fs"|])>] |
| 30 | + let ``twofiles_001a_fs_twofiles_001b_fs`` compilation = |
| 31 | + compilation |
| 32 | + |> withAdditionalSourceFile (SourceFromPath (__SOURCE_DIRECTORY__ ++ "twofiles_001b.fs")) |
| 33 | + |> asExe |
| 34 | + |> compile |
| 35 | + |> shouldSucceed |
| 36 | + |
| 37 | + //NoMT SOURCE=inamodule001.fs # inamodule001.fs |
| 38 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"inamodule001.fs"|])>] |
| 39 | + let ``inamodule001_fs`` compilation = |
| 40 | + compilation |
| 41 | + |> asExe |
| 42 | + |> compile |
| 43 | + |> shouldSucceed |
| 44 | + |
| 45 | + // SOURCE=E_twoentrypoints001.fs SCFLAGS="--test:ErrorRanges" # E_twoentrypoints001.fs |
| 46 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_twoentrypoints001.fs"|])>] |
| 47 | + let ``E_twoentrypoints001_fs`` compilation = |
| 48 | + compilation |
| 49 | + |> asExe |
| 50 | + |> withOptions [ "--test:ErrorRanges" ] |
| 51 | + |> compile |
| 52 | + |> shouldFail |
| 53 | + |> withDiagnostics [ |
| 54 | + (Error 433, Line 18, Col 5, Line 19, Col 19, "A function labeled with the 'EntryPointAttribute' attribute must be the last declaration in the last file in the compilation sequence.") |
| 55 | + ] |
| 56 | + |
| 57 | + // SOURCE="E_twofiles_002b.fs E_twofiles_002a.fs" SCFLAGS="--test:ErrorRanges" # E_twofiles_002b/a |
| 58 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_twofiles_002b.fs"|])>] |
| 59 | + let ``E_twofiles_002b_fs_E_twofiles_002a_fs`` compilation = |
| 60 | + compilation |
| 61 | + |> asExe |
| 62 | + |> withAdditionalSourceFile (SourceFromPath (__SOURCE_DIRECTORY__ ++ "E_twofiles_002a.fs")) |
| 63 | + |> withOptions [ "--test:ErrorRanges" ] |
| 64 | + |> compile |
| 65 | + |> shouldFail |
| 66 | + |> withDiagnostics [ |
| 67 | + (Error 433, Line 10, Col 5, Line 10, Col 9, "A function labeled with the 'EntryPointAttribute' attribute must be the last declaration in the last file in the compilation sequence.") |
| 68 | + ] |
| 69 | + |
| 70 | + // SOURCE=E_oninvalidlanguageelement001.fs SCFLAGS="--test:ErrorRanges" # E_oninvalidlanguageelement001.fs |
| 71 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_oninvalidlanguageelement001.fs"|])>] |
| 72 | + let ``E_oninvalidlanguageelement001_fs`` compilation = |
| 73 | + compilation |
| 74 | + |> asExe |
| 75 | + |> compile |
| 76 | + |> shouldFail |
| 77 | + |> withDiagnostics [ |
| 78 | + (Error 842, Line 9, Col 3, Line 9, Col 13, """This attribute is not valid for use on this language element""") |
| 79 | + ] |
| 80 | + |
| 81 | + // SOURCE=E_twoattributesonsamefunction001.fs SCFLAGS="--test:ErrorRanges" # E_twoattributesonsamefunction001.fs |
| 82 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_twoattributesonsamefunction001.fs"|])>] |
| 83 | + let ``E_twoattributesonsamefunction001_fs`` compilation = |
| 84 | + compilation |
| 85 | + |> asExe |
| 86 | + |> compile |
| 87 | + |> shouldFail |
| 88 | + |> withDiagnostics [ |
| 89 | + (Error 429, Line 12, Col 7, Line 12, Col 17, """The attribute type 'EntryPointAttribute' has 'AllowMultiple=false'. Multiple instances of this attribute cannot be attached to a single language element.""") |
| 90 | + ] |
| 91 | + |
| 92 | + // SOURCE=entrypointfunctionnotmain001.fs # entrypointfunctionnotmain001.fs |
| 93 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"entrypointfunctionnotmain001.fs"|])>] |
| 94 | + let ``entrypointfunctionnotmain001_fs`` compilation = |
| 95 | + compilation |
| 96 | + |> asExe |
| 97 | + |> compile |
| 98 | + |> shouldSucceed |
| 99 | + |
| 100 | + // SOURCE=E_invalidsignature001.fs SCFLAGS="--test:ErrorRanges" # E_invalidsignature001.fs |
| 101 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_invalidsignature001.fs"|])>] |
| 102 | + let ``E_invalidsignature001_fs`` compilation = |
| 103 | + compilation |
| 104 | + |> asExe |
| 105 | + |> compile |
| 106 | + |> shouldFail |
| 107 | + |> withDiagnostics [ |
| 108 | + (Error 1, Line 15, Col 23, Line 15, Col 27, """This expression was expected to have type |
| 109 | + 'int list' |
| 110 | +but here has type |
| 111 | + 'string array' """) |
| 112 | + ] |
| 113 | + |
| 114 | + // SOURCE=E_InvalidSignature02.fs SCFLAGS="--test:ErrorRanges" # E_InvalidSignature02 |
| 115 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"E_InvalidSignature02.fs"|])>] |
| 116 | + let ``E_InvalidSignature02_fs`` compilation = |
| 117 | + compilation |
| 118 | + |> asExe |
| 119 | + |> compile |
| 120 | + |> shouldFail |
| 121 | + |> withDiagnostics [ |
| 122 | + (Error 1, Line 15, Col 4, Line 15, Col 6, """This expression was expected to have type |
| 123 | + 'int' |
| 124 | +but here has type |
| 125 | + 'unit' """) |
| 126 | + ] |
| 127 | + |
| 128 | + //NoMT SOURCE=entrypointandFSI.fs SCFLAGS="--multiemit-" FSIMODE=PIPE COMPILE_ONLY=1 # entrypointandFSI.fs |
| 129 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"entrypointandFSI.fs"|])>] |
| 130 | + let ``entrypointandFSI.fs`` compilation = |
| 131 | + compilation |
| 132 | + |> asExe |
| 133 | + |> compile |
| 134 | + |> shouldSucceed |
| 135 | + |
| 136 | + //NoMT SOURCE=entrypointandFSI02.fsx SCFLAGS="--multiemit-" FSIMODE=EXEC COMPILE_ONLY=1 # entrypointandFSI02.fsx |
| 137 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"entrypointandFSI02.fsx"|])>] |
| 138 | + let ``entrypointandFSI02_fsx`` compilation = |
| 139 | + compilation |
| 140 | + |> asExe |
| 141 | + |> compile |
| 142 | + |> shouldSucceed |
| 143 | + |
| 144 | + // SOURCE=E_CompilingToALibrary01.fs SCFLAGS="--test:ErrorRanges --target:library" # E_CompilingToALibrary01.fs |
| 145 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"CompilingToALibrary01.fs"|])>] |
| 146 | + let ``CompilingToALibrary01_fs`` compilation = |
| 147 | + compilation |
| 148 | + |> asLibrary |
| 149 | + |> withOptions [ "--test:ErrorRanges" ] |
| 150 | + |> compile |
| 151 | + |> shouldSucceed |
| 152 | + |
| 153 | + // SOURCE=E_CompilingToAModule01.fs SCFLAGS="--test:ErrorRanges --target:module" # E_CompilingToAModule01.fs |
| 154 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"CompilingToAModule01.fs"|])>] |
| 155 | + let ``CompilingToAModule01_fs`` compilation = |
| 156 | + compilation |
| 157 | + |> asModule |
| 158 | + |> withOptions [ "--test:ErrorRanges" ] |
| 159 | + |> compile |
| 160 | + |> shouldSucceed |
| 161 | + |
| 162 | + // SOURCE=EntryPointAndAssemblyCulture.fs # EntryPointAndAssemblyCulture.fs |
| 163 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"EntryPointAndAssemblyCulture.fs"|])>] |
| 164 | + let ``EntryPointAndAssemblyCulture_fs`` compilation = |
| 165 | + compilation |
| 166 | + |> asExe |
| 167 | + |> compile |
| 168 | + |> shouldSucceed |
| 169 | + |
| 170 | + // SOURCE=W_NoEntryPointInLastModuleInsideMultipleNamespace.fs SCFLAGS="--test:ErrorRanges" # W_NoEntryPointInLastModuleInsideMultipleNamespace.fs |
| 171 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"W_NoEntryPointInLastModuleInsideMultipleNamespace.fs"|])>] |
| 172 | + let ``W_NoEntryPointInLastModuleInsideMultipleNamespace_fs`` compilation = |
| 173 | + compilation |
| 174 | + |> asExe |
| 175 | + |> compile |
| 176 | + |> shouldFail |
| 177 | + |> withDiagnostics [ |
| 178 | + (Warning 988, Line 1, Col 1, Line 1, Col 1, "Main module of program is empty: nothing will happen when it is run") |
| 179 | + ] |
| 180 | + |
| 181 | + // SOURCE=W_NoEntryPointModuleInNamespace.fs SCFLAGS="--test:ErrorRanges" # W_NoEntryPointModuleInNamespace.fs |
| 182 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"W_NoEntryPointModuleInNamespace.fs"|])>] |
| 183 | + let ``W_NoEntryPointModuleInNamespace_fs`` compilation = |
| 184 | + compilation |
| 185 | + |> asExe |
| 186 | + |> compile |
| 187 | + |> shouldFail |
| 188 | + |> withDiagnostics [ |
| 189 | + (Warning 988, Line 11, Col 24, Line 11, Col 24, "Main module of program is empty: nothing will happen when it is run") |
| 190 | + ] |
| 191 | + |
| 192 | + // SOURCE=W_NoEntryPointMultipleModules.fs SCFLAGS="--test:ErrorRanges" # W_NoEntryPointMultipleModules.fs |
| 193 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"W_NoEntryPointMultipleModules.fs"|])>] |
| 194 | + let ``W_NoEntryPointMultipleModules_fs`` compilation = |
| 195 | + compilation |
| 196 | + |> asExe |
| 197 | + |> compile |
| 198 | + |> shouldFail |
| 199 | + |> withDiagnostics [ |
| 200 | + (Warning 988, Line 13, Col 24, Line 13, Col 24, "Main module of program is empty: nothing will happen when it is run") |
| 201 | + ] |
| 202 | + |
| 203 | + // SOURCE=W_NoEntryPointTypeInNamespace.fs SCFLAGS="--test:ErrorRanges" # W_NoEntryPointTypeInNamespace.fs |
| 204 | + [<Theory; Directory(__SOURCE_DIRECTORY__, Includes=[|"W_NoEntryPointTypeInNamespace.fs"|])>] |
| 205 | + let ``W_NoEntryPointTypeInNamespace_fs`` compilation = |
| 206 | + compilation |
| 207 | + |> asExe |
| 208 | + |> compile |
| 209 | + |> shouldFail |
| 210 | + |> withDiagnostics [ |
| 211 | + (Warning 988, Line 10, Col 18, Line 10, Col 18, "Main module of program is empty: nothing will happen when it is run") |
| 212 | + ] |
0 commit comments