Skip to content

Commit 1d09f6c

Browse files
committed
Fix tests and library to work with indentation
1 parent ba9a773 commit 1d09f6c

16 files changed

+91
-97
lines changed

library/src-bootstrapped/scala/quoted/Liftable.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,13 @@ object Liftable {
5858
given ArrayOfBooleanIsLiftable as Liftable[Array[Boolean]] = new Liftable[Array[Boolean]] {
5959
def toExpr(array: Array[Boolean]): given QuoteContext => Expr[Array[Boolean]] =
6060
if (array.length == 0) '{ Array.emptyBooleanArray }
61-
else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) }
61+
else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) }
6262
}
6363

6464
given ArrayOfByteIsLiftable as Liftable[Array[Byte]] = new Liftable[Array[Byte]] {
6565
def toExpr(array: Array[Byte]): given QuoteContext => Expr[Array[Byte]] =
6666
if (array.length == 0) '{ Array.emptyByteArray }
67-
else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) }
67+
else '{ Array(${array(0).toExpr}, ${array.toSeq.tail.toExpr}: _*) }
6868
}
6969

7070
given ArrayOfShortIsLiftable as Liftable[Array[Short]] = new Liftable[Array[Short]] {

tests/new/test.scala

-15
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,3 @@
11
trait T {
22
object O
33
}
4-
5-
object Test0 {
6-
trait A[T]
7-
given a[T] as A[T]
8-
9-
class B[T]
10-
given b[T] as B[T]
11-
}
12-
13-
class C extends T
14-
15-
object Test {
16-
val c = new C
17-
c.O
18-
}

tests/pos/indent.scala

+8
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,14 @@ object Test:
3535
val y = x * x
3636
y + y
3737

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+
3846
println(f(2) + g)
3947

4048
(new Test2).foo

tests/pos/t2171.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,6 @@ final object test {
22
def logIgnoredException(msg: => String) =
33
try 0 catch { case ex => println(msg) }
44

5-
def main (args: Array[String]): Unit =
6-
while (true) logIgnoredException ("...")
5+
def main (args: Array[String]): Unit =
6+
while (true) logIgnoredException ("...")
77
}

tests/run/Course-2002-04.scala

+7-7
Original file line numberDiff line numberDiff line change
@@ -59,13 +59,13 @@ object M1 {
5959
var i = l;
6060
var j = r;
6161
While (i <= j) {
62-
While (less(xs(i), pivot)) { i = i + 1 }
63-
While (less(pivot, xs(j))) { j = j - 1 }
64-
if (i <= j) {
65-
swap(i, j);
66-
i = i + 1;
67-
j = j - 1;
68-
}
62+
While (less(xs(i), pivot)) { i = i + 1 }
63+
While (less(pivot, xs(j))) { j = j - 1 }
64+
if (i <= j) {
65+
swap(i, j);
66+
i = i + 1;
67+
j = j - 1;
68+
}
6969
}
7070
if (l < j) sort1(l, j);
7171
if (j < r) sort1(i, r);

tests/run/Course-2002-08.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -517,9 +517,9 @@ abstract class CircuitSimulator() extends BasicCircuitSimulator() {
517517
def demux2(in: Wire, ctrl: List[Wire], out: List[Wire]) : Unit = {
518518
val ctrlN = ctrl.map(w => { val iw = new Wire(); inverter(w,iw); iw});
519519
val w0 = new Wire();
520-
val w1 = new Wire();
521-
val w2 = new Wire();
522-
val w3 = new Wire();
520+
val w1 = new Wire();
521+
val w2 = new Wire();
522+
val w3 = new Wire();
523523

524524
andGate(in, ctrl(1), w3);
525525
andGate(in, ctrl(1), w2);

tests/run/Course-2002-13.scala

+29-29
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ class Tokenizer(s: String, delimiters: String) extends Iterator[String] {
2323
var ch = s.charAt(i); i = i + 1;
2424
if (isDelimiter(ch)) ch.toString()
2525
else {
26-
while (i < s.length() &&
27-
s.charAt(i) > ' ' &&
28-
!isDelimiter(s.charAt(i))){ i = i + 1 }
29-
s.substring(start, i)
26+
while (i < s.length() &&
27+
s.charAt(i) > ' ' &&
28+
!isDelimiter(s.charAt(i))){ i = i + 1 }
29+
s.substring(start, i)
3030
}
3131
} else "";
3232

@@ -100,8 +100,8 @@ object Terms {
100100
case (List(), List()) => Some(s)
101101
case (x :: xs1, y :: ys1) =>
102102
unify(x, y, s) match {
103-
case Some(s1) => unify(xs1, ys1, s1)
104-
case None => None
103+
case Some(s1) => unify(xs1, ys1, s1)
104+
case None => None
105105
}
106106
case _ => None
107107
}
@@ -136,14 +136,14 @@ object Programs {
136136

137137
def solve2(query: List[Term], s: Subst): LazyList[Subst] = query match {
138138
case List() =>
139-
LazyList.cons(s, LazyList.empty)
139+
LazyList.cons(s, LazyList.empty)
140140
case Con("not", qs) :: query1 =>
141-
if (solve1(qs, s).isEmpty) LazyList.cons(s, LazyList.empty)
142-
else LazyList.empty
141+
if (solve1(qs, s).isEmpty) LazyList.cons(s, LazyList.empty)
142+
else LazyList.empty
143143
case q :: query1 =>
144-
for (clause <- list2stream(clauses);
145-
s1 <- tryClause(clause.newInstance, q, s);
146-
s2 <- solve1(query1, s1)) yield s2
144+
for (clause <- list2stream(clauses);
145+
s1 <- tryClause(clause.newInstance, q, s);
146+
s2 <- solve1(query1, s1)) yield s2
147147
}
148148

149149
def solve1(query: List[Term], s: Subst): LazyList[Subst] = {
@@ -200,7 +200,7 @@ class Parser(s: String) {
200200
token = it.next;
201201
Clause(NoTerm, rep(constructor));
202202
} else {
203-
Clause(
203+
Clause(
204204
constructor,
205205
if (token equals ":-") { token = it.next; rep(constructor) } else List())
206206
}
@@ -219,27 +219,27 @@ object Prolog {
219219
var tvs: List[String] = List();
220220
{ input =>
221221
new Parser(input).all foreach { c =>
222-
if (c.lhs == NoTerm) {
223-
c.rhs match {
224-
case List(Con("more", List())) =>
222+
if (c.lhs == NoTerm) {
223+
c.rhs match {
224+
case List(Con("more", List())) =>
225225
solutions = solutions.tail;
226-
case _ =>
226+
case _ =>
227227
solutions = solve(c.rhs, program);
228-
tvs = c.tyvars;
228+
tvs = c.tyvars;
229229
}
230-
if (solutions.isEmpty) {
231-
Console.println("no")
232-
} else {
233-
val s: Subst = solutions.head
234-
.filter(b => tvs contains b.name)
235-
.map(b => Binding(b.name, b.term map solutions.head))
230+
if (solutions.isEmpty) {
231+
Console.println("no")
232+
} else {
233+
val s: Subst = solutions.head
234+
.filter(b => tvs contains b.name)
235+
.map(b => Binding(b.name, b.term map solutions.head))
236236
.reverse;
237-
if (s.isEmpty) Console.println("yes")
238-
else Console.println(s);
237+
if (s.isEmpty) Console.println("yes")
238+
else Console.println(s);
239239
}
240-
} else {
241-
program = program ::: List(c);
242-
}
240+
} else {
241+
program = program ::: List(c);
242+
}
243243
}
244244
}
245245
}

tests/run/companion-loading.scala

+7-6
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ implicit object FooAssoc extends Assoc[Foo] {
1919
def foo(t: Foo): Int = t.i
2020
}
2121

22-
inline def link[T] = delegate match {
23-
case _: Link[T, s] =>
24-
delegate match {
25-
case stuff: s => stuff
26-
}
27-
}
22+
inline def link[T] <: Any =
23+
delegate match {
24+
case _: Link[T, s] =>
25+
delegate match {
26+
case stuff: s => stuff
27+
}
28+
}
2829

2930
object Test {
3031
println(s"Test")

tests/run/iq.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ object iq {
4040
q2
4141
}
4242
else {
43-
val (head, q3) = q2.dequeue
43+
val (head, q3) = q2.dequeue
4444
Console.println("Head: " + head)
4545
q3
4646
}

tests/run/lists-run.scala

+4-4
Original file line numberDiff line numberDiff line change
@@ -69,10 +69,10 @@ min cardinality(ys, e)))
6969
}, "obey min cardinality")
7070
assert({
7171
val intersection = xs intersect ys
72-
val unconsumed = xs.foldLeft(intersection){(rest, e) =>
73-
if (! rest.isEmpty && e == rest.head) rest.tail else rest
74-
}
75-
unconsumed.isEmpty
72+
val unconsumed = xs.foldLeft(intersection){(rest, e) =>
73+
if (! rest.isEmpty && e == rest.head) rest.tail else rest
74+
}
75+
unconsumed.isEmpty
7676
}, "maintain order")
7777
assert(xs == (xs intersect xs),
7878
"has the list as again intersection")

tests/run/predef-cycle.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Force {
2-
val t1 = new Thread {
2+
val t1 = new Thread {
33
override def run(): Unit = {
44
scala.`package`
55
}

tests/run/t3980.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,15 @@ object A {
55
x
66
}
77
def run2: Unit = {
8-
lazy val y: Int = 2
9-
println(y)
10-
println(y)
8+
lazy val y: Int = 2
9+
println(y)
10+
println(y)
1111
}
1212
}
1313

1414
object Test {
1515
def main(args: Array[String]) = {
16-
A.run1
17-
A.run2
16+
A.run1
17+
A.run2
1818
}
1919
}

tests/run/t4317/S_3.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
object Test {
22
def main(args: Array[String]): Unit = {
33
val j = new J_2()
4-
println(j.bar1())
5-
println(j.bar2())
6-
println(j.bar3())
4+
println(j.bar1())
5+
println(j.bar2())
6+
println(j.bar3())
77
}
88
}

tests/run/t6443-by-name.scala

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
object Test {
22

3-
def main(args: Array[String]): Unit = {
4-
def foo = {println("foo"); 0}
5-
lazyDep(X)(foo)
6-
}
3+
def main(args: Array[String]): Unit = {
4+
def foo = {println("foo"); 0}
5+
lazyDep(X)(foo)
6+
}
77

88
trait T {
9-
type U
9+
type U
1010
}
1111
object X extends T { type U = Int }
1212

13-
def lazyDep(t: T)(u: => t.U): Unit = {
14-
println("1")
15-
u
16-
u
17-
}
13+
def lazyDep(t: T)(u: => t.U): Unit = {
14+
println("1")
15+
u
16+
u
17+
}
1818
}

tests/run/t6443-varargs.scala

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
object Test {
22

3-
def main(args: Array[String]): Unit = {
4-
def foo = {println("foo"); 0}
5-
lazyDep(X)(foo)
6-
}
3+
def main(args: Array[String]): Unit = {
4+
def foo = {println("foo"); 0}
5+
lazyDep(X)(foo)
6+
}
77

88
trait T {
9-
type U
9+
type U
1010
}
1111
object X extends T { type U = Int }
1212

13-
def lazyDep(t: T)(us: t.U*): Unit = {
14-
List(us: _*)
15-
}
13+
def lazyDep(t: T)(us: t.U*): Unit = {
14+
List(us: _*)
15+
}
1616
}

tests/run/unreachable.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ object Test extends App {
9191
}
9292

9393
def unreachableSwitch: Int = {
94-
return 42
94+
return 42
9595
val x = nextInt() % 2
9696
x match {
9797
case 0 => return 0

0 commit comments

Comments
 (0)