@@ -61,107 +61,38 @@ class SyntaxHighlightingTests {
6161 }
6262
6363 @ Test
64- def valVarDef = {
65- val source =
66- """
67- |package test
68- |
69- |object A {
70- | val a = 123
71- | var b = 123 /*Int*/
72- | var c = "123" // String
73- | var d: Int = 123
74- | var e:Int = 123;e
75- | e
76- | print(a)
77- | 123;123
78- | def f = 123
79- | def f1(x: Int) = 123
80- | def f2[T](x: T) = { 123 }
81- |}
82- """ .stripMargin
83- val expected =
84- """
85- |<K|package> test
86- |
87- |<K|object> <T|A> {
88- | <K|val> <V|a> = <L|123>
89- | <K|var> <V|b> = <L|123> <C|/*Int*/>
90- | <K|var> <V|c> = <L|"123"> <C|// String
91- |> <K|var> <V|d>: <T|Int> = <L|123>
92- | <K|var> <V|e>:<T|Int> = <L|123>;e
93- | e
94- | print(a)
95- | <L|123>;<L|123>
96- | <K|def> <V|f> = <L|123>
97- | <K|def> <V|f1>(x: <T|Int>) = <L|123>
98- | <K|def> <V|f2>[<T|T>](x: <T|T>) = { <L|123> }
99- |}
100- """ .stripMargin
101- test(source, expected)
64+ def valDef = {
65+ test(" val a = 123" , " <K|val> <V|a> = <L|123>" )
66+ test(" var b = 123 /*Int*/" , " <K|var> <V|b> = <L|123> <C|/*Int*/>" )
67+ test(""" var c = "123" // String""" , """ <K|var> <V|c> = <L|"123"> <C|// String>""" )
68+ test(" var e:Int = 123;e" , " <K|var> <V|e>:<T|Int> = <L|123>;e" )
69+ test(" def f = 123" , " <K|def> <V|f> = <L|123>" )
70+ test(" def f1(x: Int) = 123" , " <K|def> <V|f1>(x: <T|Int>) = <L|123>" )
71+ test(" def f2[T](x: T) = { 123 }" , " <K|def> <V|f2>[<T|T>](x: <T|T>) = { <L|123> }" )
10272 }
10373
10474 @ Test
10575 def patternMatching = {
106- val source =
107- """
108- |val aFruit: Fruit = Apple("red", 123)
109- |
110- |val Apple(color, weight) = aFruit
111- |
112- |sealed trait Fruit
113- |case class Apple(color: String, weight: Double) extends Fruit
114- |case class Orange(weight: Double) extends Fruit
115- |case class Melon(weight: Double) extends Fruit
116- |
117- |aFruit match {
118- | case Apple(_, weight) => println(s"apple: $weight kgs")
119- | case o: Orange => println(s"orange ${o.weight} kgs")
120- | case m @ Melon(weight) => println(s"melon: ${m.weight} kgs")
121- |}
122- """ .stripMargin
123- val expected =
124- """
125- |<K|val> <V|aFruit>: <T|Fruit> = <T|Apple>(<L|"red">, <L|123>)
126- |
127- |<K|val> <T|Apple>(<V|color>, <V|weight>) = aFruit
128- |
129- |<K|sealed> <K|trait> <T|Fruit>
130- |<K|case> <K|class> <T|Apple>(color: <T|String>, weight: <T|Double>) <K|extends> <T|Fruit>
131- |<K|case> <K|class> <T|Orange>(weight: <T|Double>) <K|extends> <T|Fruit>
132- |<K|case> <K|class> <T|Melon>(weight: <T|Double>) <K|extends> <T|Fruit>
133- |
134- |aFruit <K|match> {
135- | <K|case> <T|Apple>(<V|_>, <V|weight>) <T|=>> println(s<L|"apple: <V|$weight <L|kgs">)
136- | <K|case> <V|o>: <T|Orange> <T|=>> println(s<L|"orange <V|${o.weight}<L| kgs">)
137- | <K|case> <V|m> @ <T|Melon>(<V|weight>) <T|=>> println(s<L|"melon: <V|${m.weight}<L| kgs">)
138- |}
139- """ .stripMargin
140- test(source, expected)
76+ test(""" val aFruit: Fruit = Apple("red", 123)""" ,
77+ """ <K|val> <V|aFruit>: <T|Fruit> = <T|Apple>(<L|"red">, <L|123>)""" )
78+ test(""" val Apple(color, weight) = aFruit""" ,
79+ """ <K|val> <T|Apple>(<V|color>, <V|weight>) = aFruit""" )
80+ test(""" case Apple(_, weight) => println(s"apple: $weight kgs")""" ,
81+ """ <K|case> <T|Apple>(<V|_>, <V|weight>) <T|=>> println(s<L|"apple: <V|$weight <L|kgs">)""" )
82+ test(""" case o: Orange => println(s"orange ${o.weight} kgs")""" ,
83+ """ <K|case> <V|o>: <T|Orange> <T|=>> println(s<L|"orange <V|${o.weight}<L| kgs">)""" )
84+ test(""" case m @ Melon(weight) => println(s"melon: ${m.weight} kgs")""" ,
85+ """ <K|case> <V|m> @ <T|Melon>(<V|weight>) <T|=>> println(s<L|"melon: <V|${m.weight}<L| kgs">)""" )
14186 }
14287
14388 @ Test
14489 def unionTypes = {
145- val source =
146- """
147- |type A = String|Int| Long
148- |type B = String |Int| Long
149- |type C = String | Int | Long
150- |type D = String&Int& Long
151- |type E = String &Int& Long
152- |type F = String & Int & Long
153- |fn[String|Char](input)
154- """ .stripMargin
155- val expected =
156- """
157- |<K|type> <T|A> = <T|String>|<T|Int>| <T|Long>
158- |<K|type> <T|B> = <T|String> |<T|Int>| <T|Long>
159- |<K|type> <T|C> = <T|String> | <T|Int> | <T|Long>
160- |<K|type> <T|D> = <T|String>&<T|Int>& <T|Long>
161- |<K|type> <T|E> = <T|String> &<T|Int>& <T|Long>
162- |<K|type> <T|F> = <T|String> & <T|Int> & <T|Long>
163- |fn[<T|String>|<T|Char>](input)
164- """ .stripMargin
165- test(source, expected)
90+ test(" type A = String|Int| Long" , " <K|type> <T|A> = <T|String>|<T|Int>| <T|Long>" )
91+ test(" type B = String |Int| Long" , " <K|type> <T|B> = <T|String> |<T|Int>| <T|Long>" )
92+ test(" type C = String | Int | Long" , " <K|type> <T|C> = <T|String> | <T|Int> | <T|Long>" )
93+ test(" type D = String&Int& Long" , " <K|type> <T|D> = <T|String>&<T|Int>& <T|Long>" )
94+ test(" type E = String &Int& Long" , " <K|type> <T|E> = <T|String> &<T|Int>& <T|Long>" )
95+ test(" type F = String & Int & Long" , " <K|type> <T|F> = <T|String> & <T|Int> & <T|Long>" )
96+ test(" fn[String|Char](input)" , " fn[<T|String>|<T|Char>](input)" )
16697 }
16798}
0 commit comments