-
Notifications
You must be signed in to change notification settings - Fork 186
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RedundantSyntax: avoid invalid syntax for 2.12 tests
- Loading branch information
Showing
6 changed files
with
162 additions
and
0 deletions.
There are no files selected for viewing
43 changes: 43 additions & 0 deletions
43
scalafix-tests/input/src/main/scala-2.12/test/redundantSyntax/StringInterpolator.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,43 @@ | ||
/* | ||
rules = RedundantSyntax | ||
RedundantSyntax.stringInterpolator = true | ||
*/ | ||
|
||
package test.redundantSyntax | ||
|
||
class StringInterpolator { | ||
|
||
val a = 42d | ||
|
||
var b = "" | ||
b = "foo" | ||
b = s"foo" | ||
b = s"foo $a bar" | ||
//b = s"my \"quoted\" string" does not compile as of 2.12.18 as https://github.com/scala/scala/pull/8830 was not backported | ||
|
||
b = """foo""" | ||
b = | ||
s"""foo | ||
|bar""" | ||
b = s"""my \"quoted\" string""" | ||
b = s"""foo $a bar""" | ||
b = s"""$a""" | ||
|
||
b = f"foo" | ||
b = f"foo $a%2.2f" | ||
|
||
b = raw"foo $a \nbar" | ||
b = raw"""foo\nbar\\""" | ||
b = raw"foo\nbar\\" | ||
b = raw"foo bar" | ||
b = raw"a\*b\+" | ||
|
||
b = my"foo" | ||
b = my"foo $a bar" | ||
|
||
b = s"foo" // scalafix:ok | ||
|
||
implicit class MyInterpolator(sc: StringContext) { | ||
def my(subs: Any*): String = sc.toString + subs.mkString("") | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
scalafix-tests/input/src/main/scala-2.13/test/redundantSyntax/StringInterpolator.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,43 @@ | ||
/* | ||
rules = RedundantSyntax | ||
RedundantSyntax.stringInterpolator = true | ||
*/ | ||
|
||
package test.redundantSyntax | ||
|
||
class StringInterpolator { | ||
|
||
val a = 42d | ||
|
||
var b = "" | ||
b = "foo" | ||
b = s"foo" | ||
b = s"foo $a bar" | ||
//b = s"my \"quoted\" string" | ||
|
||
b = """foo""" | ||
b = | ||
s"""foo | ||
|bar""" | ||
b = s"""my \"quoted\" string""" | ||
b = s"""foo $a bar""" | ||
b = s"""$a""" | ||
|
||
b = f"foo" | ||
b = f"foo $a%2.2f" | ||
|
||
b = raw"foo $a \nbar" | ||
b = raw"""foo\nbar\\""" | ||
b = raw"foo\nbar\\" | ||
b = raw"foo bar" | ||
b = raw"a\*b\+" | ||
|
||
b = my"foo" | ||
b = my"foo $a bar" | ||
|
||
b = s"foo" // scalafix:ok | ||
|
||
implicit class MyInterpolator(sc: StringContext) { | ||
def my(subs: Any*): String = sc.toString + subs.mkString("") | ||
} | ||
} |
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
scalafix-tests/output/src/main/scala-2.12/test/redundantSyntax/StringInterpolator.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,38 @@ | ||
package test.redundantSyntax | ||
|
||
class StringInterpolator { | ||
|
||
val a = 42d | ||
|
||
var b = "" | ||
b = "foo" | ||
b = "foo" | ||
b = s"foo $a bar" | ||
//b = s"my \"quoted\" string" does not compile as of 2.12.18 as https://github.com/scala/scala/pull/8830 was not backported | ||
|
||
b = """foo""" | ||
b = | ||
"""foo | ||
|bar""" | ||
b = s"""my \"quoted\" string""" | ||
b = s"""foo $a bar""" | ||
b = s"""$a""" | ||
|
||
b = "foo" | ||
b = f"foo $a%2.2f" | ||
|
||
b = raw"foo $a \nbar" | ||
b = """foo\nbar\\""" | ||
b = raw"foo\nbar\\" | ||
b = "foo bar" | ||
b = raw"a\*b\+" | ||
|
||
b = my"foo" | ||
b = my"foo $a bar" | ||
|
||
b = s"foo" // scalafix:ok | ||
|
||
implicit class MyInterpolator(sc: StringContext) { | ||
def my(subs: Any*): String = sc.toString + subs.mkString("") | ||
} | ||
} |
File renamed without changes.
38 changes: 38 additions & 0 deletions
38
scalafix-tests/output/src/main/scala-3/test/redundantSyntax/StringInterpolator.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,38 @@ | ||
package test.redundantSyntax | ||
|
||
class StringInterpolator { | ||
|
||
val a = 42d | ||
|
||
var b = "" | ||
b = "foo" | ||
b = "foo" | ||
b = s"foo $a bar" | ||
b = "my \"quoted\" string" | ||
|
||
b = """foo""" | ||
b = | ||
"""foo | ||
|bar""" | ||
b = s"""my \"quoted\" string""" | ||
b = s"""foo $a bar""" | ||
b = s"""$a""" | ||
|
||
b = "foo" | ||
b = f"foo $a%2.2f" | ||
|
||
b = raw"foo $a \nbar" | ||
b = """foo\nbar\\""" | ||
b = raw"foo\nbar\\" | ||
b = "foo bar" | ||
b = raw"a\*b\+" | ||
|
||
b = my"foo" | ||
b = my"foo $a bar" | ||
|
||
b = s"foo" // scalafix:ok | ||
|
||
implicit class MyInterpolator(sc: StringContext) { | ||
def my(subs: Any*): String = sc.toString + subs.mkString("") | ||
} | ||
} |