forked from scala-ide/scalariform
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
81 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
scalariform/src/test/scala/scalariform/formatter/NestedAnonymousFunctionsTest.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
package scalariform.formatter | ||
|
||
import scalariform.formatter.preferences._ | ||
import scalariform.parser._ | ||
|
||
|
||
class NestedAnonymousFunctionsTest extends AbstractFormatterTest { | ||
// format: OFF | ||
{ | ||
implicit val formattingPreferences = FormattingPreferences | ||
.setPreference(NewlinesAtNestedAnonymousFunctions, Force) | ||
|
||
"""def foo: Int => Int => String = { x: Int => y: Int => | ||
| "x" | ||
|}""" ==> | ||
"""def foo: Int => Int => String = { | ||
| x: Int => | ||
| y: Int => | ||
| "x" | ||
|}""" | ||
} | ||
|
||
{ | ||
implicit val formattingPreferences = FormattingPreferences | ||
.setPreference(NewlinesAtNestedAnonymousFunctions, Prevent) | ||
|
||
"""def bar: Int => Int => String = { | ||
| x: Int => | ||
| y: Int => | ||
| "x" | ||
|}""" ==> | ||
"""def bar: Int => Int => String = { x: Int => y: Int => | ||
| "x" | ||
|}""" | ||
} | ||
|
||
{ | ||
implicit val formattingPreferences = FormattingPreferences | ||
.setPreference(NewlinesAtNestedAnonymousFunctions, Preserve) | ||
|
||
"""def baz: Int => Int => String = { x: Int => | ||
| y: Int => | ||
| "x" | ||
|}""" ==> | ||
"""def baz: Int => Int => String = { x: Int => | ||
| y: Int => | ||
| "x" | ||
|}""" | ||
|
||
"""def quux: Int => Int => String = { x: Int => y: Int => | ||
| "x" | ||
|}""" ==> | ||
"""def quux: Int => Int => String = { x: Int => y: Int => | ||
| "x" | ||
|}""" | ||
} | ||
// format: ON | ||
|
||
override val debug = false | ||
|
||
def parse(parser: ScalaParser) = parser.nonLocalDefOrDcl() | ||
|
||
type Result = FullDefOrDcl | ||
|
||
def format(formatter: ScalaFormatter, result: Result) = formatter.format(result)(FormatterState()) | ||
|
||
} |