Skip to content

Commit edd51ad

Browse files
oderskysmarter
authored andcommitted
Avoid colon-at-eol in tests
Drop it since it is not longer supported without a special option
1 parent 785ddcc commit edd51ad

File tree

4 files changed

+133
-9
lines changed

4 files changed

+133
-9
lines changed

compiler/test/dotty/tools/dotc/CompilationTests.scala

+2-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,8 @@ class CompilationTests extends ParallelTesting {
5656
"tests/neg-custom-args/fatal-warnings/xfatalWarnings.scala",
5757
defaultOptions.and("-nowarn", "-Xfatal-warnings")
5858
),
59-
compileFile("tests/pos-special/typeclass-scaling.scala", defaultOptions.and("-Xmax-inlines", "40"))
59+
compileFile("tests/pos-special/typeclass-scaling.scala", defaultOptions.and("-Xmax-inlines", "40")),
60+
compileFile("tests/pos-special/indent-colons.scala", defaultOptions.and("-Yindent-colons"))
6061
).checkCompile()
6162
}
6263

tests/pos-special/indent-colons.scala

+118
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,118 @@
1+
object Test
2+
3+
locally:
4+
var x = 0
5+
while x < 10 do x += 1
6+
val f = 10
7+
while
8+
x += 1
9+
x < 10
10+
do ()
11+
12+
def f(x: Int): Int =
13+
val y =
14+
if x > 0 then
15+
println("hello")
16+
22
17+
else
18+
println("world")
19+
33
20+
val z = 22
21+
x + y + z
22+
end f
23+
24+
def g = "!"
25+
26+
val xs = List(1, 2, 3)
27+
28+
xs.map:
29+
x =>
30+
val y = x * x
31+
y * y
32+
33+
xs.map:
34+
x =>
35+
val y = x * x
36+
y + y
37+
38+
xs.map { x =>
39+
val y = x * x
40+
if y >= 0 then
41+
val z = y + y
42+
println(z)
43+
y + 1
44+
}
45+
46+
println(f(2) + g)
47+
48+
(new Test2).foo
49+
(new Test3).foo
50+
51+
var x = 1
52+
while
53+
x += 1
54+
val y = x
55+
println(y)
56+
x < 10
57+
do ()
58+
59+
class Test2
60+
self =>
61+
def foo = 1
62+
63+
val x =
64+
new Test2:
65+
override def foo = 2
66+
end new
67+
end x
68+
end Test2
69+
70+
class Test3
71+
self =>
72+
def foo = 1
73+
74+
import collection.mutable.HashMap
75+
76+
class Coder(words: List[String])
77+
78+
class Foo
79+
println()
80+
end Foo
81+
82+
class Bar
83+
84+
(2 -> "ABC", new ArrowAssoc('3') -> "DEF")
85+
86+
private val mnemonics = Map(
87+
'2' -> "ABC", '3' -> "DEF", '4' -> "GHI", '5' -> "JKL",
88+
'6' -> "MNO", '7' -> "PQRS", '8' -> "TUV", '9' -> "WXYZ")
89+
90+
('1', "1") match
91+
case (digit, str) => true
92+
case _ => false
93+
94+
('1', "1") match
95+
case (digit, str) => true
96+
case _ => false
97+
98+
try List(1, 2, 3) match
99+
case x :: xs => println(x)
100+
case Nil => println("Nil")
101+
catch
102+
case ex: java.io.IOException => println(ex)
103+
case ex: Throwable =>
104+
throw ex
105+
end try
106+
107+
/** Invert the mnemonics map to give a map from chars 'A' ... 'Z' to '2' ... '9' */
108+
private val charCode0: Map[Char, Char] =
109+
mnemonics
110+
.withFilter:
111+
case (digit, str) => true
112+
case _ => false
113+
.flatMap:
114+
case (digit, str) => str map (ltr => ltr -> digit)
115+
end Coder
116+
117+
object Test22
118+
def foo: Int = 22

tests/pos/i7217.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
class Foo(p1: String, p2: String):
1+
class Foo(p1: String, p2: String)
22
def this(p1: String) = this(p1, "blah")
33

44
val x = { Foo("blah", "hah") }

tests/pos/indent.scala

+12-7
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
object Test
22

3-
locally:
3+
locally {
44
var x = 0
55
while x < 10 do x += 1
66
val f = 10
77
while
88
x += 1
99
x < 10
1010
do ()
11+
}
1112

1213
def f(x: Int): Int =
1314
val y =
@@ -25,15 +26,17 @@ object Test
2526

2627
val xs = List(1, 2, 3)
2728

28-
xs.map:
29+
xs.map {
2930
x =>
3031
val y = x * x
3132
y * y
33+
}
3234

33-
xs.map:
35+
xs.map {
3436
x =>
3537
val y = x * x
3638
y + y
39+
}
3740

3841
xs.map { x =>
3942
val y = x * x
@@ -61,9 +64,9 @@ class Test2
6164
def foo = 1
6265

6366
val x =
64-
new Test2:
67+
new Test2 {
6568
override def foo = 2
66-
end new
69+
}
6770
end x
6871
end Test2
6972

@@ -107,11 +110,13 @@ class Coder(words: List[String])
107110
/** Invert the mnemonics map to give a map from chars 'A' ... 'Z' to '2' ... '9' */
108111
private val charCode0: Map[Char, Char] =
109112
mnemonics
110-
.withFilter:
113+
.withFilter {
111114
case (digit, str) => true
112115
case _ => false
113-
.flatMap:
116+
}
117+
.flatMap {
114118
case (digit, str) => str map (ltr => ltr -> digit)
119+
}
115120
end Coder
116121

117122
object Test22

0 commit comments

Comments
 (0)