Skip to content

Commit

Permalink
Update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
som-snytt committed Oct 18, 2023
1 parent 370ec3a commit 6ef2b2e
Show file tree
Hide file tree
Showing 23 changed files with 82 additions and 42 deletions.
4 changes: 2 additions & 2 deletions src/compiler/scala/tools/nsc/settings/ScalaVersion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,13 +81,13 @@ object ScalaVersion {
private val dot = """\."""
private val dash = "-"
private val vchar = """\d""" //"[^-+.]"
private val vpat = s"(?s)($vchar+)(?:$dot($vchar+)(?:$dot($vchar+))?)?(?:$dash(.*))?".r
private val vpat = s"(?s)($vchar+)(?:$dot($vchar+)(?:$dot($vchar+))?)?(?:$dash(.+))?".r
private val rcpat = """(?i)rc(\d*)""".r
private val mspat = """(?i)m(\d*)""".r

def apply(versionString: String, errorHandler: String => Unit): ScalaVersion = {
def error() = errorHandler(
s"Bad version (${versionString}) not major[.minor[.revision[-suffix]]]"
s"Bad version (${versionString}) not major[.minor[.revision]][-suffix]"
)

def toInt(s: String) = s match {
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/multiLineOps-b.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Werror -Xsource:3
//> using options -Werror -Xsource:3-X

class Test {
val b1 = {
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/multiLineOps-c.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Werror -Xsource:3
//> using options -Werror -Xsource:3-X

class Test {
val x = 42
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/multiLineOps.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Werror -Xlint -Xsource:3
//> using options -Werror -Xlint -Xsource:3-X

class Test {
val x = 1
Expand Down
4 changes: 2 additions & 2 deletions test/files/neg/t12798-migration.check
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ class `misuse of underscore`[_]
t12798-migration.scala:48: warning: early initializers are deprecated; use trait parameters instead.
class `early bird` extends { val x = "hello, world" } with Runnable { def run() = println(x) }
^
t12798-migration.scala:17: warning: Unicode escapes in raw interpolations are ignored under -Xsource:3; use literal characters instead
t12798-migration.scala:17: warning: Unicode escapes in raw interpolations are ignored in Scala 3; use literal characters instead
def f = raw"\u0043 is for $entry"
^
t12798-migration.scala:18: warning: Unicode escapes in raw interpolations are ignored under -Xsource:3; use literal characters instead
t12798-migration.scala:18: warning: Unicode escapes in raw interpolations are ignored in Scala 3; use literal characters instead
def g = raw"""\u0043 is for Cat"""
^
t12798-migration.scala:50: warning: constructor modifiers are assumed by synthetic `copy` method
Expand Down
4 changes: 2 additions & 2 deletions test/files/neg/t12798.check
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,12 @@ Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration
class `early bird` extends { val x = "hello, world" } with Runnable { def run() = println(x) }
^
t12798.scala:17: error: Unicode escapes in raw interpolations are ignored under -Xsource:3; use literal characters instead
t12798.scala:17: error: Unicode escapes in raw interpolations are ignored in Scala 3; use literal characters instead
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=interpolated unicode such as C.f
def f = raw"\u0043 is for $entry"
^
t12798.scala:18: error: Unicode escapes in raw interpolations are ignored under -Xsource:3; use literal characters instead
t12798.scala:18: error: Unicode escapes in raw interpolations are ignored in Scala 3; use literal characters instead
Scala 3 migration messages are errors under -Xsource:3. Use -Wconf / @nowarn to filter them or add -Xmigration to demote them to warnings.
Applicable -Wconf / @nowarn filters for this fatal warning: msg=<part of the message>, cat=scala3-migration, site=interpolated unicode such as C.g
def g = raw"""\u0043 is for Cat"""
Expand Down
18 changes: 2 additions & 16 deletions test/files/neg/t7212.check
Original file line number Diff line number Diff line change
@@ -1,18 +1,3 @@
t7212.scala:8: error: type mismatch;
found : Object
required: String
val s: String = k.f
^
t7212.scala:14: error: type mismatch;
found : Object
required: String
val s: String = f.f
^
t7212.scala:21: error: type mismatch;
found : Object
required: String
val s: String = w.f
^
t7212.scala:5: warning: under -Xsource:3, inferred Object instead of String [quickfixable]
class K extends T { def f = "" }
^
Expand All @@ -22,5 +7,6 @@ class F extends T { val f = "" }
t7212.scala:17: warning: under -Xsource:3, inferred Object instead of String [quickfixable]
trait V extends T { var f = "" }
^
error: No warnings can be incurred under -Werror.
3 warnings
3 errors
1 error
2 changes: 1 addition & 1 deletion test/files/neg/t7212.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// scalac: -Xmigration -Xsource:3
//> using options -Werror -Xmigration -Xsource:3

trait T { def f: Object }
class K extends T { def f = "" }
Expand Down
26 changes: 26 additions & 0 deletions test/files/neg/t7212b.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
t7212b.scala:8: error: type mismatch;
found : Object
required: String
val s: String = k.f
^
t7212b.scala:14: error: type mismatch;
found : Object
required: String
val s: String = f.f
^
t7212b.scala:21: error: type mismatch;
found : Object
required: String
val s: String = w.f
^
t7212b.scala:5: warning: under -Xsource:3, inferred Object instead of String [quickfixable]
class K extends T { def f = "" }
^
t7212b.scala:11: warning: under -Xsource:3, inferred Object instead of String [quickfixable]
class F extends T { val f = "" }
^
t7212b.scala:17: warning: under -Xsource:3, inferred Object instead of String [quickfixable]
trait V extends T { var f = "" }
^
3 warnings
3 errors
22 changes: 22 additions & 0 deletions test/files/neg/t7212b.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

//> using options -Xmigration -Xsource:3-X

trait T { def f: Object }
class K extends T { def f = "" }
object K {
val k = new K
val s: String = k.f
}

class F extends T { val f = "" }
object F {
val f = new F
val s: String = f.f
}

trait V extends T { var f = "" }
class W extends V
object W {
val w = new W
val s: String = w.f
}
5 changes: 4 additions & 1 deletion test/files/neg/t8035-deprecated.check
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ t8035-deprecated.scala:4: warning: adaptation of an empty argument list by inser
after adaptation: SetOps((): Unit)
List(1,2,3).toSet()
^
t8035-deprecated.scala:4: warning: a type was inferred to be `AnyVal`; this may indicate a programming error.
List(1,2,3).toSet()
^
t8035-deprecated.scala:7: warning: adaptation of an empty argument list by inserting () is deprecated: this is unlikely to be what you want
signature: A(x: T): Foo.A[T]
given arguments: <none>
Expand All @@ -17,5 +20,5 @@ t8035-deprecated.scala:11: warning: adaptation of an empty argument list by inse
sdf.format()
^
error: No warnings can be incurred under -Werror.
3 warnings
4 warnings
1 error
2 changes: 1 addition & 1 deletion test/files/neg/t8035-deprecated.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -deprecation -Xfatal-warnings
//> using options -Werror -Xlint
//
object Foo {
List(1,2,3).toSet()
Expand Down
2 changes: 1 addition & 1 deletion test/files/neg/t8035-removed.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Xsource:3.0 -Xlint -Werror
//> using options -Werror -Xlint -Xsource:3-X
//
object Foo {
List(1,2,3).toSet()
Expand Down
2 changes: 1 addition & 1 deletion test/files/pos/infixed.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Xsource:3
// scalac: -Xsource:3-X

class K { def x(y: Int) = 0 }

Expand Down
2 changes: 1 addition & 1 deletion test/files/pos/leading-infix-op.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// scalac: -Xsource:3
// scalac: -Xsource:3-X

trait T {
def f(x: Int): Boolean =
Expand Down
2 changes: 1 addition & 1 deletion test/files/pos/multiLineOps.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Werror -Xsource:3
// scalac: -Werror -Xsource:3-X

class Channel {
def ! (msg: String): Channel = this
Expand Down
2 changes: 1 addition & 1 deletion test/files/pos/t7212.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// scalac: -Xsource:3 -Xmigration
// scalac: -Xsource:3-X -Xmigration

class A {
def f: Option[String] = Some("hello, world")
Expand Down
2 changes: 1 addition & 1 deletion test/files/pos/t7212b/ScalaThing.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

// scalac: -Xsource:3 -Xmigration
// scalac: -Xsource:3-X -Xmigration

class ScalaThing extends JavaThing {
override def remove() = ???
Expand Down
2 changes: 1 addition & 1 deletion test/files/run/multiLineOps.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Xsource:3
// scalac: -Xsource:3-X
//
// was: without backticks, "not found: value +" (but parsed here as +a * 6, where backticks fool the lexer)
// now: + is taken as "solo" infix op
Expand Down
2 changes: 1 addition & 1 deletion test/files/run/productElementName.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Xsource:3
// scalac: -Xsource:3-X
import scala.tools.testkit.AssertUtil.assertThrown
import scala.util.chaining.*
import org.junit.Assert.assertEquals
Expand Down
2 changes: 1 addition & 1 deletion test/files/run/t12071.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Werror -Xlint -Xsource:3
//> using options -Werror -Xlint -Xsource:3-X

class C {
def `c c`(n: Int): Int = n + 1
Expand Down
2 changes: 1 addition & 1 deletion test/files/run/t3220-214.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// scalac: -Xsource:3 -Xmigration
//> using options -Xmigration -Xsource:3-X

object Literals214 {
def inTripleQuoted = """\u000A"""
Expand Down
11 changes: 7 additions & 4 deletions test/junit/scala/tools/nsc/settings/ScalaVersionTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ScalaVersionTest {
assertEquals(V(2,11,7,Development("maybegood")), ScalaVersion("2.11.7-maybegood"))
assertEquals(V(2,11,7,Development("RCCola")), ScalaVersion("2.11.7-RCCola"))
assertEquals(V(2,11,7,Development("RC1.5")), ScalaVersion("2.11.7-RC1.5"))
assertEquals(V(2,11,7,Development("")), ScalaVersion("2.11.7-"))
assertEquals(V(2,11,0,Development("Z")), ScalaVersion("2.11-Z"))
assertEquals(V(2,11,7,Development("0.5")), ScalaVersion("2.11.7-0.5"))
assertEquals(V(2,11,7,Development("devbuild\nt9167")), ScalaVersion("2.11.7-devbuild\nt9167"))
assertEquals(V(2,11,7,Development("final")), ScalaVersion("2.11.7-final"))
Expand All @@ -50,11 +50,14 @@ class ScalaVersionTest {
assertThrows[NumberFormatException] { ScalaVersion("2..") }
assertThrows[NumberFormatException] { ScalaVersion("2...") }
assertThrows[NumberFormatException] { ScalaVersion("2-") }
assertThrows[NumberFormatException] { ScalaVersion("2-.") } // scalacheck territory
//assertThrows[NumberFormatException] { ScalaVersion("2-.") } // scalacheck territory
assertEquals(V(2,0,0,Development(".")), ScalaVersion("2-.")) // build labels are arbitrary text
assertEquals(V(2,11,0,Development("ok")), ScalaVersion("2.11-ok")) // build labels are arbitrary text
assertThrows[NumberFormatException] { ScalaVersion("2.11.7-") }
assertThrows[NumberFormatException] { ScalaVersion("any.7") }

assertThrows[NumberFormatException] ( ScalaVersion("2.11-ok"), _ ==
"Bad version (2.11-ok) not major[.minor[.revision[-suffix]]]" )
assertThrows[NumberFormatException] ( ScalaVersion("2.11-"), _ ==
"Bad version (2.11-) not major[.minor[.revision]][-suffix]" )

}

Expand Down

0 comments on commit 6ef2b2e

Please sign in to comment.