@@ -101,7 +101,7 @@ class SignificantIndentationSuite extends BaseDottySuite {
101
101
)
102
102
}
103
103
104
- test(" indent-below-not-okay " .ignore ) {
104
+ test(" then-no-indent " ) {
105
105
// this test is related to dotty issue: https://github.com/lampepfl/dotty/issues/9790
106
106
// It should either assert error during parsing: "illegal start of simple expression"
107
107
// Or accept mismatch with parsing rules and parse as 'if (cond) { truep } else {falsep }'
@@ -112,17 +112,41 @@ class SignificantIndentationSuite extends BaseDottySuite {
112
112
| else
113
113
| falsep
114
114
|""" .stripMargin
115
- runTestAssert[Stat ](code, assertLayout = Some (" trait A { def f: Int }" ))(
116
- Defn .Trait (
115
+ runTestAssert[Stat ](
116
+ code,
117
+ assertLayout = Some (
118
+ """ |def fn: Unit = {
119
+ | if (cond) truep else falsep
120
+ |}
121
+ |""" .stripMargin
122
+ )
123
+ )(
124
+ Defn .Def (
117
125
Nil ,
118
- Type .Name (" A " ),
126
+ Term .Name (" fn " ),
119
127
Nil ,
120
- Ctor .Primary (Nil , Name (" " ), Nil ),
121
- Template (Nil , Nil , Self (Name (" " ), None ), List (defx))
128
+ Nil ,
129
+ Some (Type .Name (" Unit" )),
130
+ Term .Block (List (Term .If (Term .Name (" cond" ), Term .Name (" truep" ), Term .Name (" falsep" ))))
122
131
)
123
132
)
124
133
}
125
134
135
+ test(" then-no-indent-wrong" ) {
136
+ // this test is related to dotty issue: https://github.com/lampepfl/dotty/issues/9790
137
+ // It should either assert error during parsing: "illegal start of simple expression"
138
+ // Or accept mismatch with parsing rules and parse as 'if (cond) { truep } else {falsep }'
139
+ // Why error is thrown is described in mentioned issue.
140
+ val code = """ |def fn: Unit =
141
+ | if cond then
142
+ | truep1
143
+ | truep2
144
+ | else
145
+ | falsep
146
+ |""" .stripMargin
147
+ runTestError[Stat ](code, " expected but else found" )
148
+ }
149
+
126
150
test(" indent-inside-brace-ok" ) {
127
151
val code = """ |class X {
128
152
| def fx(): Unit =
0 commit comments