Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
refactor tests
  • Loading branch information
vasily-kirichenko committed Dec 17, 2017
commit 25dae9e3000881922c2df8f8bf15645f0a152a39
325 changes: 51 additions & 274 deletions tests/service/ServiceUntypedParseTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ open Tests.Service

let [<Literal>] private Marker = "(* marker *)"

let (=>) (source: string) (expected: CompletionContext option) =
let private (=>) (source: string) (expected: CompletionContext option) =

let lines =
use reader = new StringReader(source)
Expand Down Expand Up @@ -49,277 +49,54 @@ let (=>) (source: string) (expected: CompletionContext option) =
printfn "ParseTree: %A" parseTree
reraise()

(*** open ended attribute ***)

[<Test>]
let ``AttributeApplication completion context at [<|``() =
"""
module AttributeCompletion =
[<Test>]
let ``at [<|, applied to nothing``() =
"""
[<(* marker *)
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttr|``() =
"""
[<AnAttr(* marker *)
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<type:|``() =
"""
[<type:(* marker *)
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<type:AnAttr|``() =
"""
[<type:AnAttr(* marker *)
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [< |``() =
"""
[< (* marker *)
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute;|``() =
"""
[<AnAttribute;(* marker *)
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute; |``() =
"""
[<AnAttribute; (* marker *)
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute>][<|``() =
"""
[<AnAttribute>][<(* marker *)
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute>][< |``() =
"""
[<AnAttribute>][< (* marker *)
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``No AttributeApplication completion context at [<AnAttribute(|``() =
"""
[<AnAttribute((* marker *)
type T =
{ F: int }
"""
=> None

[<Test>]
let ``No AttributeApplication completion context at [<AnAttribute( |``() =
"""
[<AnAttribute( (* marker *)
type T =
{ F: int }
"""
=> None

[<Test>]
let ``No AttributeApplication completion context at [<AnAttribute |``() =
"""
[<AnAttribute (* marker *)
type T =
{ F: int }
"""
=> None

[<Test>]
let ``No AttributeApplication completion context at [<AnAttribute>][<AnAttribute(|``() =
"""
[<AnAttribute>][<AnAttribute((* marker *)
type T =
{ F: int }
"""
=> None

[<Test>]
let ``No AttributeApplication completion context at [<AnAttribute; AnAttribute(|``() =
"""
[<AnAttribute; AnAttribute((* marker *)
type T =
{ F: int }
"""
=> None

(*** closed attribute ***)

[<Test>]
let ``AttributeApplication completion context at [<|>]``() =
"""
[<(* marker *)>]
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttr|>]``() =
"""
[<AnAttr(* marker *)>]
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<type:|>]``() =
"""
[<type:(* marker *)>]
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<type:AnAttr|>]``() =
"""
[<type:AnAttr(* marker *)>]
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication


[<Test>]
let ``AttributeApplication completion context at [< |>]``() =
"""
[< (* marker *)>]
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute>][<|>]``() =
"""
[<AnAttribute>][<(* marker *)>]
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute>][< |>]``() =
"""
[<AnAttribute>][< (* marker *)>]
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute;|>]``() =
"""
[<AnAttribute;(* marker *)>]
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute; | >]``() =
"""
[<AnAttribute; (* marker *) >]
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``AttributeApplication completion context at [<AnAttribute>][<AnAttribute; | >]``() =
"""
[<AnAttribute>][<AnAttribute;(* marker *)>]
type T =
{ F: int }
"""
=> Some CompletionContext.AttributeApplication

[<Test>]
let ``No AttributeApplication completion context at [<AnAttribute(|>]``() =
"""
[<AnAttribute((* marker *)>]
type T =
{ F: int }
"""
=> None

[<Test>]
let ``No AttributeApplication completion context at [<AnAttribute | >]``() =
"""
[<AnAttribute (* marker *) >]
type T =
{ F: int }
"""
=> None

[<Test>]
let ``No AttributeApplication completion context at [<AnAttribute>][<AnAttribute( | >]``() =
"""
[<AnAttribute>][<AnAttribute((* marker *)>]
type T =
{ F: int }
"""
=> None

[<Test>]
let ``No AttributeApplication completion context at [<AnAttribute; AnAttribute(| >]``() =
"""
[<AnAttribute; AnAttribute((* marker *)>]
type T =
{ F: int }
"""
=> None

[<Test>]
let ``No AttributeApplication completion context at [<AnAttribute; AnAttribute( | >]``() =
"""
[<AnAttribute; AnAttribute( (* marker *)>]
type T =
{ F: int }
"""
=> None

[<Test>]
let ``No AttributeApplication completion context at [<AnAttribute>][<AnAttribute; AnAttribute(| >]``() =
"""
[<AnAttribute>][<AnAttribute; AnAttribute((* marker *)>]
type T =
{ F: int }
"""
=> None
"""
=> Some CompletionContext.AttributeApplication

[<TestCase ("[<(* marker *)", true)>]
[<TestCase ("[<AnAttr(* marker *)", true)>]
[<TestCase ("[<type:(* marker *)", true)>]
[<TestCase ("[<type:AnAttr(* marker *)", true)>]
[<TestCase ("[< (* marker *)", true)>]
[<TestCase ("[<AnAttribute;(* marker *)", true)>]
[<TestCase ("[<AnAttribute; (* marker *)", true)>]
[<TestCase ("[<AnAttribute>][<(* marker *)", true)>]
[<TestCase ("[<AnAttribute>][< (* marker *)", true)>]
[<TestCase ("[<AnAttribute((* marker *)", false)>]
[<TestCase ("[<AnAttribute( (* marker *)", false)>]
[<TestCase ("[<AnAttribute (* marker *)", false)>]
[<TestCase ("[<AnAttribute>][<AnAttribute((* marker *)", false)>]
[<TestCase ("[<AnAttribute; AnAttribute((* marker *)", false)>]
let ``incomplete``(lineStr: string, expectAttributeApplicationContext: bool) =
(sprintf """
%s
type T =
{ F: int }
""" lineStr) => (if expectAttributeApplicationContext then Some CompletionContext.AttributeApplication else None)

[<TestCase ("[<(* marker *)>]", true)>]
[<TestCase ("[<AnAttr(* marker *)>]", true)>]
[<TestCase ("[<type:(* marker *)>]", true)>]
[<TestCase ("[<type:AnAttr(* marker *)>]", true)>]
[<TestCase ("[< (* marker *)>]", true)>]
[<TestCase ("[<AnAttribute>][<(* marker *)>]", true)>]
[<TestCase ("[<AnAttribute>][< (* marker *)>]", true)>]
[<TestCase ("[<AnAttribute;(* marker *)>]", true)>]
[<TestCase ("[<AnAttribute; (* marker *) >]", true)>]
[<TestCase ("[<AnAttribute>][<AnAttribute;(* marker *)>]", true)>]
[<TestCase ("[<AnAttribute((* marker *)>]", false)>]
[<TestCase ("[<AnAttribute (* marker *) >]", false)>]
[<TestCase ("[<AnAttribute>][<AnAttribute((* marker *)>]", false)>]
[<TestCase ("[<AnAttribute; AnAttribute((* marker *)>]", false)>]
[<TestCase ("[<AnAttribute; AnAttribute( (* marker *)>]", false)>]
[<TestCase ("[<AnAttribute>][<AnAttribute; AnAttribute((* marker *)>]", false)>]
let ``complete``(lineStr: string, expectAttributeApplicationContext: bool) =
(sprintf """
%s
type T =
{ F: int }
""" lineStr) => (if expectAttributeApplicationContext then Some CompletionContext.AttributeApplication else None)