Skip to content

Commit

Permalink
RedundantSyntax: avoid invalid syntax for 2.12 tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bjaglin committed Aug 27, 2023
1 parent 839a22e commit 917649c
Show file tree
Hide file tree
Showing 6 changed files with 162 additions and 0 deletions.
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("")
}
}
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("")
}
}
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("")
}
}
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("")
}
}

0 comments on commit 917649c

Please sign in to comment.