@@ -63,6 +63,30 @@ def test() =
63
63
val x = " Hello"
64
64
println(x)
65
65
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
+
66
90
// don't turn innocent empty cases into functions
67
91
def regress (x : Int ) =
68
92
x match
@@ -76,3 +100,42 @@ def k(xs: List[Int]) =
76
100
: (acc, x) =>
77
101
acc + x
78
102
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