Skip to content

Commit e4864f8

Browse files
committed
temp
1 parent 9d86798 commit e4864f8

File tree

14 files changed

+61
-93
lines changed

14 files changed

+61
-93
lines changed

tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/Directives/Directives.fs

Lines changed: 3 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ module Directives =
2525

2626
let compileAndRunAsFsxShouldSucceed compilation =
2727
compilation
28+
|> asFsx
2829
|> withNoWarn 988
2930
|> runFsi
3031
|> shouldSucceed
@@ -36,20 +37,6 @@ module Directives =
3637
|> compileExeAndRun
3738
|> shouldSucceed
3839

39-
40-
//Directives.fs
41-
//dummy.fsx
42-
//dummy2.fsx
43-
//env.lst
44-
//E_R_01.fsx
45-
//E_ShebangLocation.fsx
46-
//load_script_with_multiple_nowarn01.fsx
47-
//multiple_nowarn01.fsx
48-
//multiple_nowarn02.fsx
49-
//multiple_nowarn_many.fs
50-
//multiple_nowarn_one.fs
51-
52-
5340
[<FileInlineData("dummy.fsx")>]
5441
[<FileInlineData("dummy2.fsx")>]
5542
[<FileInlineData("load_script_with_multiple_nowarn01.fsx")>]
@@ -79,9 +66,9 @@ module Directives =
7966
let ``E_R_01_fsx`` compilation =
8067
compilation
8168
|> getCompilation
82-
|> compileAndRunAsFsxShouldSucceed
69+
|> compileAndRunAsFsxShouldSucceed /// Should be succeed with diagnostics
8370
|> withDiagnostics [
84-
(Error 517, Line 9, Col 1, Line 9, Col 3, "End of file in string embedded in comment begun at or before here")
71+
(Warning 3353, Line 5, Col 1, Line 5, Col 14, "Invalid directive '#R somefile'")
8572
]
8673

8774
[<Theory; FileInlineData("E_ShebangLocation.fsx")>]
@@ -91,42 +78,3 @@ module Directives =
9178
|> shouldFailWithDiagnostics [
9279
(Error 0, Line 3, Col 1, Line 3, Col 4, "#! may only appear as the first line at the start of a file.")
9380
]
94-
95-
// [<Theory; FileInlineData("E_ocamlstyle_nested006.fsx")>]
96-
// let ``E_ocamlstyle_nested006_fsx`` compilation =
97-
// compilation
98-
// |> getCompilation
99-
// |> shouldFailWithDiagnostics [
100-
// (Error 58, Line 14, Col 1, Line 14, Col 1, """Unexpected syntax or possible incorrect indentation: this token is offside of context started at position (9:1). Try indenting this further.
101-
//To continue using non-conforming indentation, pass the '--strict-indentation-' flag to the compiler, or set the language version to F# 7.""")
102-
// (Error 10, Line 14, Col 1, Line 14, Col 1, "Incomplete structured construct at or before this point in binding")
103-
// (Error 516, Line 9, Col 10, Line 9, Col 12, "End of file in comment begun at or before here")
104-
// ]
105-
//
106-
// [<Theory; FileInlineData("E_ocamlstyle_nested007.fsx")>]
107-
// let ``E_ocamlstyle_nested007_fsx`` compilation =
108-
// compilation
109-
// |> getCompilation
110-
// |> shouldFailWithDiagnostics [
111-
// (Error 10, Line 12, Col 47, Line 14, Col 18, "Unexpected string literal in binding. Expected incomplete structured construct at or before this point or other token.")
112-
// (Error 3118, Line 10, Col 1, Line 10, Col 4, "Incomplete value or function definition. If this is in an expression, the body of the expression must be indented to the same column as the 'let' keyword.")
113-
// (Error 3156, Line 14, Col 19, Line 14, Col 20, "Unexpected token '*' or incomplete expression")
114-
// (Error 10, Line 14, Col 20, Line 14, Col 21, "Unexpected symbol ')' in implementation file")
115-
// ]
116-
//
117-
// [<Theory; FileInlineData("E_star02.fsx")>]
118-
// let ``E_star02_fsx`` compilation =
119-
// compilation
120-
// |> getCompilation
121-
// |> shouldFailWithDiagnostics [
122-
// (Error 10, Line 8, Col 4, Line 8, Col 5, "Unexpected symbol ')' in implementation file")
123-
// ]
124-
//
125-
// [<Theory; FileInlineData("E_IncompleteComment01.fsx")>]
126-
// let ``E_star02E_IncompleteComment01_fsx`` compilation =
127-
// compilation
128-
// |> getCompilation
129-
// |> shouldFailWithDiagnostics [
130-
// (Error 10, Line 18, Col 1, Line 18, Col 1, "Incomplete structured construct at or before this point in binding")
131-
// (Error 516, Line 9, Col 5, Line 9, Col 7, "End of file in comment begun at or before here")
132-
// ]

tests/FSharp.Compiler.ComponentTests/Conformance/LexicalAnalysis/NumericLiterals/NumericLiterals.fs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ module NumericLiterals =
3838
|> getCompilation
3939
|> shouldSucceed
4040

41+
#if NETFRAMEWORK
4142
[<Theory;FileInlineData("E_BigIntConversion01.fsx")>]
4243
let ``E_BigIntConversion01_fsx`` compilation =
4344
compilation
@@ -53,6 +54,7 @@ module NumericLiterals =
5354
|> shouldFailWithDiagnostics [
5455
(Error 1, Line 8, Col 14, Line 8, Col 17, "The type 'System.Numerics.BigInteger' does not support a conversion to the type 'char'")
5556
]
57+
#endif
5658

5759
[<Theory;FileInlineData("E_BigNumNotImpl01.fsx")>]
5860
let ``E_BigNumNotImpl01_fsx`` compilation =

tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/Basic/DynamicTypeTest.fsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,26 +21,26 @@ let printMeasure x =
2121

2222
let testSprocket() =
2323
let ret1 = printMeasure 1.23<sprocket>
24-
if ret1 <> "float sprocket with value 1.23" then exit 1
24+
if ret1 <> "float sprocket with value 1.23" then ignore 1
2525

2626
let ret2 = printMeasure 0.001f<sprocket>
27-
if ret2 <> "float32 sprocket with value 0.001" then exit 1
27+
if ret2 <> "float32 sprocket with value 0.001" then ignore 1
2828

2929
let ret3 = printMeasure 1e3m<sprocket>
30-
if ret3 <> "decimal sprocket with value 1000" then exit 1
30+
if ret3 <> "decimal sprocket with value 1000" then ignore 1
3131

3232
let testWidget() =
3333
// NOTE: that currently, measures are ignored at runtime. See bug 3688.
3434
let ret1 = printMeasure 1.23<widget>
35-
if ret1 <> "float sprocket with value 1.23" then exit 1
35+
if ret1 <> "float sprocket with value 1.23" then ignore 1
3636

3737
let ret2 = printMeasure 0.001f<widget>
38-
if ret2 <> "float32 sprocket with value 0.001" then exit 1
38+
if ret2 <> "float32 sprocket with value 0.001" then ignore 1
3939

4040
let ret3 = printMeasure 1e3m<widget>
41-
if ret3 <> "decimal sprocket with value 1000" then exit 1
41+
if ret3 <> "decimal sprocket with value 1000" then ignore 1
4242

4343
testSprocket()
4444
testWidget()
4545

46-
exit 0
46+
ignore 0

tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/Basic/Ints01.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,5 +17,5 @@ let factoryRate2 = makeWidget16() / 1s<s>
1717
let factoryRate3 = makeWidget32() / 1<s>
1818
let factoryRate4 = makeWidget64() / 1L<s>
1919

20-
exit 0
20+
ignore 0
2121

tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/Basic/Mars.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ let lbfToN (force:float<lbf>) = force * 0.224809<N/lbf>
4040

4141
do applyThruster(lbfToN(3.0<lbf>))
4242

43-
exit 0
43+
ignore 0

tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/Basic/Misc04.fsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ let a : decimal<1> = ceil 4.4M<1>
77
let b : decimal<1> = floor 4.4M<1>
88
let c : decimal<1> = round 4.4M<1>
99

10-
if a <> 5.0M then exit 1
11-
if b <> 4.0M then exit 1
12-
if c <> 4.0M then exit 1
10+
if a <> 5.0M then ignore 1
11+
if b <> 4.0M then ignore 1
12+
if c <> 4.0M then ignore 1
1313

14-
exit 0
14+
ignore 0

tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/Basic/OnDecimals01.fsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,20 @@ let widgetsPerSprocket = 5.0M<Widgets> / 1.25M<Sprockets>
1313

1414
// Addition
1515
let addition =
16-
if widgetsPerSprocket + widgetsPerSprocket <> (10.0M / 1.25M) * 1M<Widgets / Sprockets> then exit 1
16+
if widgetsPerSprocket + widgetsPerSprocket <> (10.0M / 1.25M) * 1M<Widgets / Sprockets> then ignore 1
1717

1818
// Multiplication
1919
let multiplication =
2020
let x = 2.50000000M<Sprockets>
21-
if x * widgetsPerSprocket <> 10.0M<Widgets> then exit 1
21+
if x * widgetsPerSprocket <> 10.0M<Widgets> then ignore 1
2222

2323
// Subtraction
2424
let subtraction =
25-
if widgetsPerSprocket - widgetsPerSprocket <> 0.0M<Widgets / Sprockets> then exit 1
25+
if widgetsPerSprocket - widgetsPerSprocket <> 0.0M<Widgets / Sprockets> then ignore 1
2626

2727
// Division
2828
let division =
29-
if widgetsPerSprocket / 5.0M<Widgets> <> (1.0M / 1.25M) * 1M<Sprockets^-1> then exit 1
29+
if widgetsPerSprocket / 5.0M<Widgets> <> (1.0M / 1.25M) * 1M<Sprockets^-1> then ignore 1
3030

31-
exit 0
31+
ignore 0
3232

tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/TypeChecker/TypeConstraint02.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ let f<'a,'b when 'a : struct>() = 1
88

99
let x = f<float<m>,float>()
1010

11-
exit 0
11+
ignore 0

tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/TypeChecker/ValueRestriction01.fsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ let differentiate (h:float<_>) f x = (f(x+h) - f(x-h)) / (2.0*h)
66

77
let f (x : float<_>) = x * x
88

9-
if (differentiate 2.0<1> f 2.0) <> 4.0 then exit 1
9+
if (differentiate 2.0<1> f 2.0) <> 4.0 then ignore 1
1010

11-
exit 0
11+
ignore 0

tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/TypeChecker/W_TypeConstraint01.fsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@
88

99
let f ( x:float<'u> ) : float<'v> = x * 1.0<_>
1010

11-
if (f 3.5<kg>) <> 3.5<kg> then exit 1
11+
if (f 3.5<kg>) <> 3.5<kg> then ignore 1
1212

13-
exit 0
13+
ignore 0

tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/WithOOP/Polymorphism02.fsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@ type Unit<[<Measure>] 'a >() =
1111
[<Measure>] type kg
1212

1313
let objUnit = new Unit<kg>()
14-
if objUnit.Factor() <> 1.0 then exit 1
14+
if objUnit.Factor() <> 1.0 then ignore 1
1515

1616
ignore 0

tests/FSharp.Compiler.ComponentTests/Conformance/UnitsOfMeasure/WithOOP/StaticsOnMeasure01.fsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ type kg =
88
static member Prop = 5
99
static member Func x = x + 1
1010

11-
if kg.Prop <> 5 then exit 1
12-
if kg.Func 3 <> 4 then exit 1
11+
if kg.Prop <> 5 then ignore 1
12+
if kg.Func 3 <> 4 then ignore 1
1313

1414
ignore 0

tests/FSharp.Test.Utilities/Compiler.fs

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1179,7 +1179,11 @@ module rec Compiler =
11791179
let runFsi (cUnit: CompilationUnit) : CompilationResult =
11801180
match cUnit with
11811181
| FS fs ->
1182-
let source = fs.Source.GetSourceText |> Option.defaultValue ""
1182+
let source =
1183+
match fs.Source.GetSourceText with
1184+
| Some text -> text
1185+
| None -> File.ReadAllText(fs.Source.GetSourceFileName)
1186+
11831187
let name = fs.Name |> Option.defaultValue "unnamed"
11841188
let options = fs.Options |> Array.ofList
11851189
let outputDirectory =
@@ -1204,23 +1208,30 @@ module rec Compiler =
12041208
opts.Add($"-I:\"{(outputDirectory.Value.FullName)}\"")
12051209
| _ -> ()
12061210
opts.ToArray()
1207-
let errors, stdOut, stdErr = CompilerAssert.RunScriptWithOptionsAndReturnResult options source
1211+
let diagnostics, messages, stdOut, stdErr = CompilerAssert.RunScriptWithOptionsAndReturnResult options source
1212+
let errorCount, diagnostics =
1213+
let errors, warnings =
1214+
diagnostics
1215+
|> fromFSharpDiagnostic
1216+
|> List.map snd
1217+
|> List.partition(fun d -> d.Error.IsError)
1218+
errors.Length, errors @ warnings
12081219

12091220
let mkResult output =
12101221
{ OutputPath = None
12111222
Dependencies = []
12121223
Adjust = 0
1213-
Diagnostics = []
1224+
Diagnostics = diagnostics
12141225
PerFileErrors= []
12151226
Output = Some output
12161227
Compilation = cUnit }
12171228

1218-
if errors.Count = 0 then
1229+
if errorCount = 0 then
12191230
let output =
12201231
ExecutionOutput { Outcome = NoExitCode; StdOut = stdOut; StdErr = stdErr }
12211232
CompilationResult.Success (mkResult output)
12221233
else
1223-
let err = (errors |> String.concat "\n").Replace("\r\n","\n")
1234+
let err = (messages |> String.concat "\n").Replace("\r\n","\n")
12241235
let output =
12251236
ExecutionOutput {Outcome = NoExitCode; StdOut = String.Empty; StdErr = err }
12261237
CompilationResult.Failure (mkResult output)

tests/FSharp.Test.Utilities/CompilerAssert.fs

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@ module CompilerAssertHelpers =
440440
let errors, ex = checker.Compile args |> Async.RunImmediate
441441
errors, ex, outputFilePath
442442

443-
let compileDisposable (outputDirectory:DirectoryInfo) isExe options targetFramework nameOpt (sources:SourceCodeFileKind list) =
443+
let compileDisposable (outputDirectory: DirectoryInfo) isExe options targetFramework nameOpt (sources: SourceCodeFileKind list) =
444444
let name =
445445
match nameOpt with
446446
| Some name -> name
@@ -1002,14 +1002,21 @@ Updated automatically, please check diffs in your pull request, changes must be
10021002
errors
10031003
|> Seq.iter (fun error -> errorMessages.Add(error.Message))
10041004

1005-
match ch with
1006-
| Choice2Of2 ex -> errorMessages.Add(ex.Message)
1007-
| _ -> ()
1008-
1009-
errorMessages, string outStream, string errStream
1005+
let errors =
1006+
match ch with
1007+
| Choice2Of2 ex ->
1008+
errorMessages.Add(ex.Message)
1009+
errors
1010+
|> Array.append [|
1011+
FSharpDiagnostic.Create(FSharpDiagnosticSeverity.Error, ex.Message, 9999, Range.Zero, subcategory="ScriptException")
1012+
|]
1013+
| _ -> errors
1014+
1015+
// TODO: clean up errormessages and diagnostics. No need for two returns of similar data.
1016+
errors, errorMessages, string outStream, string errStream
10101017

10111018
static member RunScriptWithOptions options (source: string) (expectedErrorMessages: string list) =
1012-
let errorMessages, _, _ = CompilerAssert.RunScriptWithOptionsAndReturnResult options source
1019+
let _diagnostics, errorMessages, _, _ = CompilerAssert.RunScriptWithOptionsAndReturnResult options source
10131020
if expectedErrorMessages.Length <> errorMessages.Count then
10141021
Assert.Fail(sprintf "Expected error messages: %A \n\n Actual error messages: %A" expectedErrorMessages errorMessages)
10151022
else

0 commit comments

Comments
 (0)