Skip to content

Commit 82e7c4e

Browse files
committed
Change tests to new syntax
1 parent 5feebea commit 82e7c4e

File tree

125 files changed

+375
-375
lines changed

Some content is hidden

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

125 files changed

+375
-375
lines changed

scala3doc-testcases/src/tests/FilterTest.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,9 +65,9 @@ class FilterTestBase:
6565
given Map[String, Double] = Map.empty
6666

6767
/** doc */
68-
protected given namedSet as Set[String | Int] = Set(1, "ala")
68+
protected given namedSet: Set[String | Int] = Set(1, "ala")
6969
/** doc */
70-
given namedMap as Map[String, Double] = Map.empty
70+
given namedMap: Map[String, Double] = Map.empty
7171

7272
class FilterTest extends FilterTestBase with FilterTestBaseTrait:
7373
/** doc */
@@ -116,9 +116,9 @@ class FilterTest extends FilterTestBase with FilterTestBaseTrait:
116116
given List[String] = "ula" :: Nil
117117

118118
/** doc */
119-
given namedList as List[String] = "ula" :: Nil
119+
given namedList: List[String] = "ula" :: Nil
120120
/** doc */
121-
protected given namedSeq as Seq[String | Int | Double] = List(1)
121+
protected given namedSeq: Seq[String | Int | Double] = List(1)
122122

123123
extension (e: FilterTest):
124124
def extensionMethod(name: FilterTest): FilterTest = ???

scala3doc-testcases/src/tests/givenDRI.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,25 +10,25 @@ given A[String]
1010

1111
given A[Seq[String]]
1212

13-
given [T: A] as A[Option[T]]
13+
given [T: A]: A[Option[T]] with {}
1414

15-
given [T: B] as A[T]
15+
given [T: B]: A[T] with {}
1616

17-
given [C] as A[C]
17+
given [C]: A[C] with {}
1818

1919
given A[C]
2020

21-
given [S <: C] as A[S]
21+
given [S <: C]: A[S] with {}
2222

2323
class R:
2424
def a = 1
2525

26-
given R as A[Int]:
26+
given R: A[Int] with
2727
def a = 2
2828

2929
class S:
3030
class R:
3131
def a = 3
3232

33-
given R as A[Int]:
33+
given R: A[Int] with
3434
def a = 5

scala3doc-testcases/src/tests/givenSignatures.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,16 +15,16 @@ class GivenClass {
1515
extension (x: T) def < (y: T) = compare(x, y) < 0
1616
extension (x: T) def > (y: T) = compare(x, y) > 0
1717
}
18-
given intOrd as Ord[Int] {
18+
given intOrd: Ord[Int] with {
1919
def compare(x: Int, y: Int) =
2020
if (x < y) -1 else if (x > y) +1 else 0
2121
}
2222

23-
given asd(using int: Int) as B
23+
given asd(using int: Int): B with {}
2424

25-
given asd2[T] as C[T]
25+
given asd2[T]: C[T] with {}
2626

27-
given listOrd[T](using ord: Ord[T]) as Ord[List[T]] {
27+
given listOrd[T](using ord: Ord[T]): Ord[List[T]] with {
2828

2929
def compare(xs: List[T], ys: List[T]): Int = (xs, ys) match
3030
case (Nil, Nil) => 0
@@ -35,7 +35,7 @@ class GivenClass {
3535
if (fst != 0) fst else compare(xs1, ys1)
3636
}
3737

38-
given IntOps as Int.type = Int
38+
given IntOps: Int.type = Int
3939

4040
given GivenType = GivenType()
4141

scala3doc-testcases/src/tests/implicitConversions.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package tests
22

33
package implicitConversions
44

5-
given Conversion[A, B] {
5+
given Conversion[A, B] with {
66
def apply(a: A): B = ???
77
}
88

scala3doc-testcases/src/tests/implicitConversions2.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class OuterClass //unexpected
2929
= ???
3030
}
3131

32-
given conversionFromVal as Conversion[ClassWithConversionFromVal, Methods] //unexpected
32+
given conversionFromVal: Conversion[ClassWithConversionFromVal, Methods] with //unexpected
3333
{
3434
def apply(a: ClassWithConversionFromVal): Methods //unexpected
3535
= ???

scala3doc-testcases/src/tests/shadowingDRI.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ class S:
77
class R:
88
def findThisDeclaration = 1
99

10-
given R as A[B]
10+
given R: A[B] with {}

tests/disabled/pos-macros/i7853/JsonEncoder_1.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ object JsonEncoder {
3535
}
3636
}
3737

38-
given listEncoder[T](using encoder: JsonEncoder[T]) as JsonEncoder[List[T]] {
38+
given listEncoder[T](using encoder: JsonEncoder[T]): JsonEncoder[List[T]] with {
3939
def encode(list: List[T]) = s"[${ list.map(v => encoder.encode(v)).mkString(", ") }]"
4040
}
4141

42-
given intEncoder as JsonEncoder[Int] {
42+
given intEncoder: JsonEncoder[Int] with {
4343
def encode(value: Int) = value + ""
4444
}
4545

46-
given stringEncoder as JsonEncoder[String] {
46+
given stringEncoder: JsonEncoder[String] with {
4747
def encode(value: String) = value
4848
}
4949
}

tests/disabled/pos/i7851.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
trait Wrappable[T] { }
2-
given Wrappable[Float] { }
2+
given Wrappable[Float] with { }
33

44
case class Wrapped[T: Wrappable](value: T)
55

66
trait Wrapper[T] { type WrappedT }
77
object Wrapper { type Aux[T <: Tuple, WrappedT0 <: Tuple] = Wrapper[T] { type WrappedT = WrappedT0 } }
88

9-
given Wrapper[EmptyTuple] { type WrappedT = EmptyTuple }
9+
given Wrapper[EmptyTuple] with { type WrappedT = EmptyTuple }
1010

11-
given [T: Wrappable] as Wrapper[T] { type WrappedT = Wrapped[T] }
11+
given [T: Wrappable]: Wrapper[T] with with { type WrappedT = Wrapped[T] }
1212

1313
given [H: Wrappable, T <: Tuple, WrappedT0 <: Tuple]
1414
(using Wrapper.Aux[T, WrappedT0])

tests/disabled/pos/i8311.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ class Foo
88

99
object test:
1010

11-
given box[A](using Show[A]) as Show[Box[A]] = _.toString
12-
given foo as Show[Foo] = _.toString
11+
given box[A](using Show[A]): Show[Box[A]] = _.toString
12+
given foo: Show[Foo] = _.toString
1313

1414
def run(s: Box[Box[Foo]]): Unit =
1515
val x = summon[Show[Box[Box[Foo]]]]

tests/init/crash/i6914.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object test1 {
55
class ToExpr[T](using Liftable[T]) extends Conversion[T, Expr[T]] {
66
def apply(x: T): Expr[T] = ???
77
}
8-
given toExprFun[T](using Liftable[T]) as ToExpr[T]
8+
given toExprFun[T](using Liftable[T]): ToExpr[T] with {}
99

1010
given Liftable[Int] = ???
1111
given Liftable[String] = ???
@@ -18,7 +18,7 @@ object test1 {
1818

1919
object test2 {
2020

21-
given autoToExpr[T](using Liftable[T]) as Conversion[T, Expr[T]] {
21+
given autoToExpr[T](using Liftable[T]): Conversion[T, Expr[T]] with {
2222
def apply(x: T): Expr[T] = ???
2323
}
2424

tests/init/crash/i7821.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ object XObject {
33

44
def anX: X = 5
55

6-
given ops as Object {
6+
given ops: Object with {
77
extension (x: X) def + (y: X): X = x + y
88
}
99
}
@@ -13,7 +13,7 @@ object MyXObject {
1313

1414
def anX: MyX = XObject.anX
1515

16-
given ops as Object {
16+
given ops: Object with {
1717
extension (x: MyX) def + (y: MyX): MyX = x + y // error: warring: Infinite recursive call
1818
}
1919
}

tests/neg-custom-args/fatal-warnings/i7821.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ object XObject {
33

44
def anX: X = 5
55

6-
given ops as Object {
6+
given ops: Object with {
77
extension (x: X) def + (y: X): X = x + y
88
}
99
}
@@ -13,7 +13,7 @@ object MyXObject {
1313

1414
def anX: MyX = XObject.anX
1515

16-
given ops as Object {
16+
given ops: Object with {
1717
extension (x: MyX) def + (y: MyX): MyX = x + y // error: warring: Infinite recursive call
1818
}
1919
}

tests/neg-custom-args/impl-conv/A.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package implConv
33
object A {
44

55
implicit def s2i(x: String): Int = Integer.parseInt(x) // error: feature
6-
given i2s as Conversion[Int, String] = _.toString // ok
6+
given i2s: Conversion[Int, String] = _.toString // ok
77

88
implicit class Foo(x: String) {
99
def foo = x.length

tests/neg-custom-args/implicit-conversions.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@ class B
33

44
object A {
55

6-
given Conversion[A, B] {
6+
given Conversion[A, B] with {
77
def apply(x: A): B = ???
88
}
99

10-
given Conversion[B, A] {
10+
given Conversion[B, A] with {
1111
def apply(x: B): A = ???
1212
}
1313
}
1414

1515
class C
1616

1717
object D {
18-
given Conversion[A, C] {
18+
given Conversion[A, C] with {
1919
def apply(x: A): C = ???
2020
}
2121
}

tests/neg-macros/BigFloat/BigFloat_1.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ object BigFloat extends App {
3535
def fromDigits(digits: String) = apply(digits)
3636
}
3737

38-
given BigFloatFromDigits {
38+
given BigFloatFromDigits with {
3939
override inline def fromDigits(digits: String) = ${
4040
BigFloatFromDigitsImpl('digits)
4141
}
4242
}
4343

4444
// Should be in StdLib:
4545

46-
given Liftable[BigInt] {
46+
given Liftable[BigInt] with {
4747
def toExpr(x: BigInt) =
4848
'{BigInt(${Expr(x.toString)})}
4949
}

tests/neg-macros/GenericNumLits/Even_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object Even {
1616
def fromDigits(digits: String) = evenFromDigits(digits)
1717
}
1818

19-
given EvenFromDigits {
19+
given EvenFromDigits with {
2020
override inline def fromDigits(digits: String) = ${
2121
EvenFromDigitsImpl('digits)
2222
}

tests/neg-macros/i4044b.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@ def test(using Quotes) = {
44

55
'{
66
val qctx: Quotes = ???
7-
given x1 as qctx.type = qctx
7+
given x1: qctx.type = qctx
88

99
val b = '{3}
1010

1111
'{
1212
val qctx: Quotes = ???
13-
given x2 as qctx.type = qctx
13+
given x2: qctx.type = qctx
1414

1515
b // error
1616
${b}

tests/neg-macros/i7919.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import scala.quoted._
33
object Test {
44
def staged[T](using Quotes) = {
55
import quotes.reflect._
6-
given typeT as Type[T] // error
6+
given typeT as Type[T] with {} // error
77
val tt = TypeRepr.of[T]
88
'{ "in staged" }
99
}

tests/neg-with-compiler/GenericNumLits/Even_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object Even {
1616
def fromDigits(digits: String) = evenFromDigits(digits)
1717
}
1818

19-
given EvenFromDigits {
19+
given EvenFromDigits with {
2020
override inline def fromDigits(digits: String) = ${
2121
EvenFromDigitsImpl('digits)
2222
}

tests/neg/eql.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object lst:
22
opaque type Lst[+T] = Any
33
object Lst:
4-
given lstCanEqual[T, U] as CanEqual[Lst[T], Lst[U]] = CanEqual.derived
4+
given lstCanEqual[T, U]: CanEqual[Lst[T], Lst[U]] = CanEqual.derived
55
val Empty: Lst[Nothing] = ???
66
end lst
77

tests/neg/exports.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
type PrinterType
66
def print(bits: BitMap): Unit = ???
77
def status: List[String] = ???
8-
given bitmap as BitMap
8+
given bitmap: BitMap with {}
99
}
1010

1111
class Scanner {

tests/neg/gadt-approximation-interaction.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object GivenLookup {
2828

2929
class Tag[T]
3030

31-
given ti as Tag[Int]
31+
given ti: Tag[Int] with {}
3232

3333
def foo[T](t: T, ev: T SUB Int) =
3434
ev match { case SUB.Refl() =>

tests/neg/genericNumbers.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ object Test extends App {
77

88
case class Even(n: Int)
99

10-
given FromDigits[Even] {
10+
given FromDigits[Even] with {
1111
def fromDigits(digits: String): Even = {
1212
val intValue = digits.toInt
1313
if (intValue % 2 == 0) Even(intValue)

tests/neg/i10074.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
class Context
22
given Context = ??? // ok
3-
given as Context = ??? // error // error // error
3+
given: Context = ??? // error

tests/neg/i5978.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ opaque type Position[Buffer] = Int
55
trait TokenParser[Token, R]
66

77
object TextParser {
8-
given TP as TokenParser[Char, Position[CharSequence]] {}
8+
given TP: TokenParser[Char, Position[CharSequence]] with {}
99

1010
given FromCharToken(using T: TokenParser[Char, Position[CharSequence]])
1111
as Conversion[Char, Position[CharSequence]] = ???
@@ -21,7 +21,7 @@ object Testcase {
2121
val co_x : Position[CharSequence] = 'x' // error
2222

2323
{
24-
given XXX as Conversion[Char, Position[CharSequence]] = co_i
24+
given XXX: Conversion[Char, Position[CharSequence]] = co_i
2525
val co_y : Position[CharSequence] = 'x'
2626
}
2727
}

tests/neg/i7078.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
trait A
22
class B extends A
33

4-
transparent given g1 as A = B() // error: `transparent` can only be used in conjunction with `inline`
4+
transparent given g1: A = B() // error: `transparent` can only be used in conjunction with `inline`
55

6-
inline given g2 as _ <: A: // error: `=' expected
6+
inline given g2: _ <: A: // error: `=' expected // error
77
def foo = 2

tests/neg/i7248.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
object Test extends App {
2-
given f[H](using h: H) as H = h
2+
given f[H](using h: H): H = h
33
summon[Int] // error
44
}

tests/neg/i7249.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ trait F[H, T]
44

55

66
object Test extends App {
7-
given f[H, T](using h: H, t: T) as F[H, T] = ???
7+
given f[H, T](using h: H, t: T): F[H, T] = ???
88
summon[F[Int, Unit]] // error
99
}

0 commit comments

Comments
 (0)