Skip to content

Commit ec5ac6d

Browse files
committed
Move warn tests form tests/error to tests/warn
1 parent c139210 commit ec5ac6d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

99 files changed

+3233
-0
lines changed

tests/warn/i10247.scala

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
//> using options -deprecation
2+
3+
def usered = Color.Red // warn: value Red is deprecated
4+
5+
object DeprecatedContainer {
6+
@deprecated("no foo", "0.1") val foo = 23
7+
}
8+
9+
enum Day {
10+
11+
@deprecated("no more Mondays!", "0.1") case Monday
12+
13+
}
14+
15+
enum Color {
16+
17+
@deprecated("no Red", "0.1") case Red
18+
19+
@deprecated("no Generic", "0.1") case Generic(rgb: Int)
20+
21+
def useFoo1 = DeprecatedContainer.foo // warn // check that only enum cases are avoided
22+
def useMonday = Day.Monday // warn // check that enum cases are declared in this enum
23+
24+
}
25+
26+
object Color {
27+
def useFoo2 = DeprecatedContainer.foo // warn // check that only enum cases are avoided
28+
}

tests/warn/i10930.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
3+
import language.future
4+
@main def Test =
5+
type LeafElem[X] = X match
6+
case String => Char
7+
case Array[t] => LeafElem[t]
8+
case Iterable[t] => LeafElem[t]
9+
case AnyVal => X
10+
11+
def leafElem[X](x: X): LeafElem[X] = x match
12+
case x: String => x.charAt(0) // warn
13+
case x: Array[t] => leafElem(x(1)) // warn
14+
case x: Iterable[t] => leafElem(x.head) // warn
15+
case x: AnyVal => x // warn

tests/warn/i10994.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
3+
def foo = true match
4+
case (b: Boolean): Boolean => () // warn
5+

tests/warn/i11022.check

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- Deprecation Warning: tests/warn/i11022.scala:10:7 -------------------------------------------------------------------
2+
10 |val a: CaseClass = CaseClass(42) // warn: deprecated type // warn: deprecated apply method
3+
| ^^^^^^^^^
4+
| class CaseClass is deprecated: no CaseClass
5+
-- Deprecation Warning: tests/warn/i11022.scala:10:19 ------------------------------------------------------------------
6+
10 |val a: CaseClass = CaseClass(42) // warn: deprecated type // warn: deprecated apply method
7+
| ^^^^^^^^^
8+
| class CaseClass is deprecated: no CaseClass
9+
-- Deprecation Warning: tests/warn/i11022.scala:11:7 -------------------------------------------------------------------
10+
11 |val b: CaseClass = new CaseClass(42) // warn: deprecated type // warn: deprecated class
11+
| ^^^^^^^^^
12+
| class CaseClass is deprecated: no CaseClass
13+
-- Deprecation Warning: tests/warn/i11022.scala:11:23 ------------------------------------------------------------------
14+
11 |val b: CaseClass = new CaseClass(42) // warn: deprecated type // warn: deprecated class
15+
| ^^^^^^^^^
16+
| class CaseClass is deprecated: no CaseClass
17+
-- Deprecation Warning: tests/warn/i11022.scala:12:14 ------------------------------------------------------------------
18+
12 |val c: Unit = CaseClass(42).magic() // warn: deprecated apply method
19+
| ^^^^^^^^^
20+
| class CaseClass is deprecated: no CaseClass

tests/warn/i11022.scala

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
//> using options -deprecation
2+
3+
@deprecated("no CaseClass")
4+
case class CaseClass(rgb: Int):
5+
def magic(): Unit = ()
6+
7+
object CaseClass:
8+
def notDeprecated(): Unit = ()
9+
10+
val a: CaseClass = CaseClass(42) // warn: deprecated type // warn: deprecated apply method
11+
val b: CaseClass = new CaseClass(42) // warn: deprecated type // warn: deprecated class
12+
val c: Unit = CaseClass(42).magic() // warn: deprecated apply method
13+
val d: Unit = CaseClass.notDeprecated() // compiles

tests/warn/i11097.scala

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
2+
3+
@main def test: Unit = {
4+
class C { type T1; type T2 }
5+
6+
def pmatch(s: C): s.T2 = s match {
7+
case p: (C { type T1 = Int; type T2 >: T1 } & s.type) => // warn
8+
(3: p.T1): p.T2
9+
case p: (C { type T1 = String; type T2 >: T1 } & s.type) => // warn
10+
("this branch should be matched": p.T1): p.T2
11+
}
12+
13+
// ClassCastException: class java.lang.Integer cannot be cast to class java.lang.String
14+
val x = pmatch(new C { type T1 = String; type T2 = String })
15+
}

tests/warn/i11333.check

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:4:19 -------------------------------------------------------
2+
4 | val f1: Float = 123456789 // warn
3+
| ^^^^^^^^^
4+
| Widening conversion from Int to Float loses precision.
5+
| Write `.toFloat` instead.
6+
-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:5:19 -------------------------------------------------------
7+
5 | val d1: Double = 1234567890123456789L // warn
8+
| ^^^^^^^^^^^^^^^^^^^^
9+
| Widening conversion from Long to Double loses precision.
10+
| Write `.toDouble` instead.
11+
-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:6:19 -------------------------------------------------------
12+
6 | val f2: Float = 123456789L // warn
13+
| ^^^^^^^^^^
14+
| Widening conversion from Long to Float loses precision.
15+
| Write `.toFloat` instead.
16+
-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:12:21 ------------------------------------------------------
17+
12 | val f1_b: Float = i1 // warn
18+
| ^^
19+
| Widening conversion from Int to Float loses precision.
20+
| Write `.toFloat` instead.
21+
-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:13:21 ------------------------------------------------------
22+
13 | val d1_b: Double = l1 // warn
23+
| ^^
24+
| Widening conversion from Long to Double loses precision.
25+
| Write `.toDouble` instead.
26+
-- [E167] Lossy Conversion Warning: tests/warn/i11333.scala:14:21 ------------------------------------------------------
27+
14 | val f2_b: Float = l2 // warn
28+
| ^^
29+
| Widening conversion from Long to Float loses precision.
30+
| Write `.toFloat` instead.

tests/warn/i11333.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
3+
class C:
4+
val f1: Float = 123456789 // warn
5+
val d1: Double = 1234567890123456789L // warn
6+
val f2: Float = 123456789L // warn
7+
8+
inline val i1 = 123456789
9+
inline val l1 = 1234567890123456789L
10+
inline val l2 = 123456789L
11+
12+
val f1_b: Float = i1 // warn
13+
val d1_b: Double = l1 // warn
14+
val f2_b: Float = l2 // warn

tests/warn/i11344.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
//> using options -deprecation
2+
3+
trait Pet(val name: String, rest: Int):
4+
def f(suffix: String) = s"$name$suffix$rest"
5+
6+
class Birdie(override val name: String) extends Pet("huh", 1) // warn
7+
8+
9+

tests/warn/i11963a.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
3+
open trait Foo // warn
4+

0 commit comments

Comments
 (0)