Skip to content

Commit 2645cab

Browse files
danielyliallanrenucci
authored andcommitted
Add tests for mid-expression user inputs
These tests currently fail because of a bug in the syntax highlighter.
1 parent 368fc5b commit 2645cab

File tree

1 file changed

+27
-5
lines changed

1 file changed

+27
-5
lines changed

compiler/test/dotty/tools/dotc/printing/SyntaxHighlightingTests.scala

Lines changed: 27 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ class SyntaxHighlightingTests extends DottyTest {
3636

3737
@Test
3838
def types = {
39+
test("type Foo", "<K|type> <T|Foo>")
40+
test("type Foo =", "<K|type> <T|Foo> =")
3941
test("type Foo = Int", "<K|type> <T|Foo> = <T|Int>")
4042
test("type A = String | Int", "<K|type> <T|A> = <T|String | Int>")
4143
test("type B = String & Int", "<K|type> <T|B> = <T|String & Int>")
@@ -74,15 +76,35 @@ class SyntaxHighlightingTests extends DottyTest {
7476
@Test
7577
def expressions = {
7678
test("if (true) 1 else 2", "<K|if> (<L|true>) <L|1> <K|else> <L|2>")
77-
test("val x = 1 + 2 + 3", "<K|val> <V|x> = <L|1> + <L|2> + <L|3>")
78-
test("if (true) 3 else 1", "<K|if> (<K|true>) <L|3> <K|else> <L|1>")
79+
test("1 + 2 + 3", "<L|1> + <L|2> + <L|3>")
7980
}
8081

8182
@Test
8283
def valOrDefDef = {
83-
test("val a = 123", "<K|val> <V|a> = <L|123>")
84-
test("var e: Int = 123", "<K|var> <V|e>: <T|Int> = <L|123>")
85-
test("def f = 123", "<K|def> <V|f> = <L|123>")
84+
test("val", "<K|val>")
85+
test("val foo", "<K|val> <V|foo>")
86+
test("val foo =", "<K|val> <V|foo> =")
87+
test("val foo = 123", "<K|val> <V|foo> = <L|123>")
88+
89+
test("var", "<K|var>")
90+
test("var foo", "<K|var> <V|foo>")
91+
test("var foo:", "<K|var> <V|foo>:")
92+
test("var foo: Int", "<K|var> <V|foo>: <T|int>")
93+
test("var foo: Int =", "<K|var> <V|foo>: <T|int> =")
94+
test("var foo: Int = 123", "<K|var> <V|foo>: <T|int> = <L|123>")
95+
96+
test("def", "<K|def>")
97+
test("def foo", "<K|def> <V|foo>")
98+
test("def foo(", "<K|def> <V|foo>(")
99+
test("def foo(bar", "<K|def> <V|foo>(<V|bar>")
100+
test("def foo(bar:", "<K|def> <V|foo>(<V|bar>:")
101+
test("def foo(bar: Int", "<K|def> <V|foo>(<V|bar>: <T|Int>")
102+
test("def foo(bar: Int)", "<K|def> <V|foo>(<V|bar>: <T|Int>)")
103+
test("def foo(bar: Int):", "<K|def> <V|foo>(<V|bar>: <T|Int>):")
104+
test("def foo(bar: Int): Int", "<K|def> <V|foo>(<V|bar>: <T|Int>): <T|Int>")
105+
test("def foo(bar: Int): Int =", "<K|def> <V|foo>(<V|bar>: <T|Int>): <T|Int> =")
106+
test("def foo(bar: Int): Int = 123", "<K|def> <V|foo>(<V|bar>: <T|Int>): <T|Int> = <L|123>")
107+
86108
test("def f1(x: Int) = 123", "<K|def> <V|f1>(<V|x>: <T|Int>) = <L|123>")
87109
test("def f2[T](x: T) = { 123 }", "<K|def> <V|f2>[<T|T>](<V|x>: <T|T>) = { <L|123> }")
88110
}

0 commit comments

Comments
 (0)