Skip to content
This repository has been archived by the owner on Dec 23, 2024. It is now read-only.

Commit

Permalink
don't auto-resolve types from System.Runtime.WindowsRuntime (dotnet#9644
Browse files Browse the repository at this point in the history
) (dotnet#9646)

Co-authored-by: Brett V. Forsgren <brettfo@microsoft.com>
  • Loading branch information
2 people authored and nosami committed Feb 22, 2021
1 parent 7c76069 commit 699964d
Showing 1 changed file with 16 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,70 +5,71 @@ namespace FSharp.Compiler.Scripting.UnitTests
open System
open System.Threading.Tasks
open FSharp.Compiler.Scripting
open Xunit
open NUnit.Framework

[<TestFixture>]
type CompletionTests() =

[<Fact>]
[<Test>]
member _.``Instance completions in the same submission``() =
async {
use script = new FSharpScript()
let lines = [ "let x = 1"
"x." ]
let! completions = script.GetCompletionItems(String.Join("\n", lines), 2, 2)
let matchingCompletions = completions |> Array.filter (fun d -> d.Name = "CompareTo")
Assert.Equal(1, matchingCompletions.Length)
Assert.AreEqual(1, matchingCompletions.Length)
} |> Async.StartAsTask :> Task

[<Fact>]
[<Test>]
member _.``Instance completions from a previous submission``() =
async {
use script = new FSharpScript()
script.Eval("let x = 1") |> ignoreValue
let! completions = script.GetCompletionItems("x.", 1, 2)
let matchingCompletions = completions |> Array.filter (fun d -> d.Name = "CompareTo")
Assert.Equal(1, matchingCompletions.Length)
Assert.AreEqual(1, matchingCompletions.Length)
} |> Async.StartAsTask :> Task

[<Fact>]
[<Test>]
member _.``Completions from types that try to pull in Windows runtime extensions``() =
async {
use script = new FSharpScript()
script.Eval("open System") |> ignoreValue
script.Eval("let t = TimeSpan.FromHours(1.0)") |> ignoreValue
let! completions = script.GetCompletionItems("t.", 1, 2)
let matchingCompletions = completions |> Array.filter (fun d -> d.Name = "TotalHours")
Assert.Equal(1, matchingCompletions.Length)
Assert.AreEqual(1, matchingCompletions.Length)
} |> Async.StartAsTask :> Task

[<Fact>]
[<Test>]
member _.``Static member completions``() =
async {
use script = new FSharpScript()
let! completions = script.GetCompletionItems("System.String.", 1, 14)
let matchingCompletions = completions |> Array.filter (fun d -> d.Name = "Join")
Assert.True(matchingCompletions.Length >= 1)
Assert.GreaterOrEqual(matchingCompletions.Length, 1)
} |> Async.StartAsTask :> Task

[<Fact>]
[<Test>]
member _.``Type completions from namespace``() =
async {
use script = new FSharpScript()
let! completions = script.GetCompletionItems("System.", 1, 7)
let matchingCompletions = completions |> Array.filter (fun d -> d.Name = "String")
Assert.True(matchingCompletions.Length >= 1)
Assert.GreaterOrEqual(matchingCompletions.Length, 1)
} |> Async.StartAsTask :> Task

[<Fact>]
[<Test>]
member _.``Namespace completions``() =
async {
use script = new FSharpScript()
let! completions = script.GetCompletionItems("System.", 1, 7)
let matchingCompletions = completions |> Array.filter (fun d -> d.Name = "Collections")
Assert.Equal(1, matchingCompletions.Length)
Assert.AreEqual(1, matchingCompletions.Length)
} |> Async.StartAsTask :> Task

[<Fact>]
[<Test>]
member _.``Extension method completions``() =
async {
use script = new FSharpScript()
Expand All @@ -77,5 +78,5 @@ type CompletionTests() =
"list." ]
let! completions = script.GetCompletionItems(String.Join("\n", lines), 3, 5)
let matchingCompletions = completions |> Array.filter (fun d -> d.Name = "Select")
Assert.Equal(1, matchingCompletions.Length)
Assert.AreEqual(1, matchingCompletions.Length)
} |> Async.StartAsTask :> Task

0 comments on commit 699964d

Please sign in to comment.