-
Notifications
You must be signed in to change notification settings - Fork 821
[WIP] Support --typecheck-only for fsi run (just typecheck, no execution) #18687
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4995602
89b69aa
a8db5c6
7ea403c
bd5aa05
9836e52
e276875
d3d4ea0
66ba4f3
312cdbd
7d5cba7
0140ab0
f43c85a
6daac2e
c37be65
bed45ff
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module FSharp.Compiler.ComponentTests.Scripting.TypeCheckOnlyTests | ||
|
||
open Xunit | ||
open FSharp.Test | ||
open FSharp.Test.Compiler | ||
|
||
[<Fact>] | ||
let ``typecheck-only flag works for valid script``() = | ||
Fsx """ | ||
let x = 42 | ||
printfn "This should not execute" | ||
exit 999 // this would have crashed if really running | ||
""" | ||
|> withOptions ["--typecheck-only"] | ||
|> runFsi | ||
|> shouldSucceed | ||
|
||
[<Fact>] | ||
let ``typecheck-only flag catches type errors``() = | ||
Fsx """ | ||
let x: int = "string" // Type error | ||
""" | ||
|> withOptions ["--typecheck-only"] | ||
|> runFsi | ||
|> shouldFail | ||
|> withStdErrContains """This expression was expected to have type""" | ||
|
||
[<Fact>] | ||
let ``typecheck-only flag prevents execution side effects``() = | ||
Fsx """ | ||
printfn "MyCrazyString" | ||
let x = 42 | ||
""" | ||
|> withOptions ["--typecheck-only"] | ||
|> runFsi | ||
|> shouldSucceed | ||
|> verifyNotInOutput "MyCrazyString" | ||
|
||
[<Fact>] | ||
let ``script executes without typecheck-only flag``() = | ||
Fsx """ | ||
let x = 21+21 | ||
""" | ||
|> withOptions ["--nologo"] | ||
|> runFsi | ||
|> shouldSucceed | ||
|> verifyOutputContains [|"val x: int = 42"|] |
Uh oh!
There was an error while loading. Please reload this page.