Skip to content

Commit f5ba8d6

Browse files
committed
More OG tests
1 parent 37d1da8 commit f5ba8d6

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed

tests/pos/i22193.scala

+63
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,30 @@ def test() =
6363
val x = "Hello"
6464
println(x)
6565

66+
fn3( // arg at 3, body at 3
67+
arg = "blue sleeps faster than tuesday",
68+
arg2 = "the quick brown fox jumped over the lazy dog"):
69+
val x = "Hello"
70+
println(x)
71+
72+
fn3( // arg at 3, body at 1: not sure if sig indent of 1 is allowed, saw some comments from odersky
73+
arg = "blue sleeps faster than tuesday",
74+
arg2 = "the quick brown fox jumped over the lazy dog"):
75+
val x = "Hello"
76+
println(x)
77+
78+
fn3( // arg at 3, body at 2: even if sig indent of 1 is not allowed, body is at fn3+2, not arg2-1
79+
arg = "blue sleeps faster than tuesday",
80+
arg2 = "the quick brown fox jumped over the lazy dog"):
81+
val x = "Hello"
82+
println(x)
83+
84+
fn3( // arg at 3, body at 4
85+
arg = "blue sleeps faster than tuesday",
86+
arg2 = "the quick brown fox jumped over the lazy dog"):
87+
val x = "Hello"
88+
println(x)
89+
6690
// don't turn innocent empty cases into functions
6791
def regress(x: Int) =
6892
x match
@@ -76,3 +100,42 @@ def k(xs: List[Int]) =
76100
: (acc, x) =>
77101
acc + x
78102

103+
def `test kit`(xs: List[Int]): Unit =
104+
def addOne(i: Int): Int = i + 1
105+
def isPositive(i: Int): Boolean = i > 0
106+
// doesn't compile but would be nice
107+
// first body is indented "twice", or, rather, first outdent establishes an intermediate indentation level
108+
xs.map: x =>
109+
x + 1
110+
.filter: x =>
111+
x > 0
112+
xs.map:
113+
addOne
114+
.filter:
115+
isPositive
116+
117+
// does compile
118+
xs
119+
.map: x =>
120+
x + 1
121+
.filter: x =>
122+
x > 0
123+
124+
// does compile but doesn't look good, at least, to some people
125+
xs.map: x =>
126+
x + 1
127+
.filter: x =>
128+
x > 0
129+
130+
def `tested kit`(xs: List[Int]): Unit =
131+
{
132+
def addOne(i: Int): Int = i.+(1)
133+
def isPositive(i: Int): Boolean = i.>(0)
134+
xs.map[Int]((x: Int) => x.+(1)).filter((x: Int) => x.>(0))
135+
xs.map[Int]((i: Int) => addOne(i)).filter((i: Int) => isPositive(i))
136+
xs.map[Int]((x: Int) => x.+(1)).filter((x: Int) => x.>(0))
137+
{
138+
xs.map[Int]((x: Int) => x.+(1)).filter((x: Int) => x.>(0))
139+
()
140+
}
141+
}

0 commit comments

Comments
 (0)