aboutsummaryrefslogtreecommitdiff
path: root/tests/run
diff options
context:
space:
mode:
Diffstat (limited to 'tests/run')
-rw-r--r--tests/run/builder.check2
-rw-r--r--tests/run/builder.scala12
-rw-r--r--tests/run/bytecodecs.scala39
-rw-r--r--tests/run/iterator-from.scala6
-rw-r--r--tests/run/puzzler54.scala13
-rw-r--r--tests/run/t8280.check3
-rw-r--r--tests/run/t8280.scala9
-rw-r--r--tests/run/var-arity-class-symbol.scala19
8 files changed, 29 insertions, 74 deletions
diff --git a/tests/run/builder.check b/tests/run/builder.check
index 48f7d9253..04048dfcc 100644
--- a/tests/run/builder.check
+++ b/tests/run/builder.check
@@ -1 +1 @@
-Table(Row(Cell(A1), Cell(B1)), Row(Cell(A2), Cell(B2)))
+Table(Row(Cell(top left), Cell(top right)), Row(Cell(botttom left), Cell(bottom right)))
diff --git a/tests/run/builder.scala b/tests/run/builder.scala
index 532a95071..d09e9f2c8 100644
--- a/tests/run/builder.scala
+++ b/tests/run/builder.scala
@@ -12,9 +12,7 @@ class Row {
override def toString = cells.mkString("Row(", ", ", ")")
}
-class Cell(elem: String) {
- override def toString = s"Cell($elem)"
-}
+case class Cell(elem: String)
object Test {
@@ -36,12 +34,12 @@ object Test {
val data =
table {
row {
- cell("A1")
- cell("B1")
+ cell("top left")
+ cell("top right")
}
row {
- cell("A2")
- cell("B2")
+ cell("botttom left")
+ cell("bottom right")
}
}
diff --git a/tests/run/bytecodecs.scala b/tests/run/bytecodecs.scala
deleted file mode 100644
index 454958dfa..000000000
--- a/tests/run/bytecodecs.scala
+++ /dev/null
@@ -1,39 +0,0 @@
-import scala.reflect.internal.pickling.ByteCodecs._
-
-object Test {
-
- def test8to7(xs: Array[Byte]): Unit = {
- val ys = encode8to7(xs)
- decode7to8(ys, ys.length)
- assert(ys.take(xs.length).deep == xs.deep,
- "test8to7("+xs.deep+") failed, result = "+ys.take(xs.length).deep)
- }
-
- def testAll(xs: Array[Byte]): Unit = {
- val ys = encode(xs)
- decode(ys)
- assert(ys.take(xs.length).deep == xs.deep,
- "testAll("+xs.deep+") failed, result = "+ys.take(xs.length).deep)
- }
-
- def test(inputs: Array[Byte]*): Unit = {
- for (input <- inputs) {
- test8to7(input)
- testAll(input)
- }
- }
-
- def main(args: Array[String]): Unit = {
- test(
- Array(1, 2, 3),
- Array(1, 2, 3, 4, 5, 6, 7),
- Array(1, -2, 0, -3, -5, -6, -7),
- Array(1, 3, -1, -128, 0, 0, -128, 1, 2, 3))
- val rand = new scala.util.Random()
- for (i <- 1 until 5000) {
- var xs = new Array[Byte](i)
- rand.nextBytes(xs)
- test(xs)
- }
- }
-}
diff --git a/tests/run/iterator-from.scala b/tests/run/iterator-from.scala
index 4f403680c..c7c0f9809 100644
--- a/tests/run/iterator-from.scala
+++ b/tests/run/iterator-from.scala
@@ -11,7 +11,9 @@ object Test extends dotty.runtime.LegacyApp {
val maxKey = 50
val maxValue = 50
- def testSet[A <% Ordered[A]](set: SortedSet[A], list: List[A]): Unit = {
+ implicit def convertIfView[A](x: A)(implicit view: A => Ordered[A]): Ordered[A] = view(x)
+
+ def testSet[A: Ordering](set: SortedSet[A], list: List[A]): Unit = {
val distinctSorted = list.distinct.sorted
assertEquals("Set size wasn't the same as list sze", set.size, distinctSorted.size)
@@ -24,7 +26,7 @@ object Test extends dotty.runtime.LegacyApp {
}
}
- def testMap[A <% Ordered[A], B](map: SortedMap[A, B], list: List[(A, B)]): Unit = {
+ def testMap[A: Ordering, B](map: SortedMap[A, B], list: List[(A, B)]): Unit = {
val distinctSorted = distinctByKey(list).sortBy(_._1)
assertEquals("Map size wasn't the same as list sze", map.size, distinctSorted.size)
diff --git a/tests/run/puzzler54.scala b/tests/run/puzzler54.scala
new file mode 100644
index 000000000..9dd4cbb47
--- /dev/null
+++ b/tests/run/puzzler54.scala
@@ -0,0 +1,13 @@
+// Scala Puzzler 54
+object Test {
+ case class Card(number: Int, suit: String = "clubs") {
+ val value = (number % 13) + 1 // ace = 1, king = 13
+ def isInDeck(implicit deck: List[Card]) = deck contains this
+ }
+
+ def main(args: Array[String]) = {
+ implicit val deck = List(Card(1, "clubs"))
+ implicit def intToCard(n: Int): Card = Card(n)
+ assert(1.isInDeck)
+ }
+}
diff --git a/tests/run/t8280.check b/tests/run/t8280.check
index 44c51f5aa..b5885df48 100644
--- a/tests/run/t8280.check
+++ b/tests/run/t8280.check
@@ -1,7 +1,6 @@
-Int
-Int
Long
Int
Int
Int
Int
+Int
diff --git a/tests/run/t8280.scala b/tests/run/t8280.scala
index f433dcc32..5fcbad0a3 100644
--- a/tests/run/t8280.scala
+++ b/tests/run/t8280.scala
@@ -37,7 +37,8 @@ object Moop1 {
implicit object f1 extends (Int => String) { def apply(x: Int): String = "Int" }
implicit val f2: Long => String = _ => "Long"
- println(5: String)
+ //println(5: String)
+ // This picked f1 before, but is now disallowed since subtypes of functions are no longer implicit conversions
}
}
@@ -73,14 +74,14 @@ object Moop3 {
// Dotty deviation. This fails for Dotty with ambiguity error for similar reasons as ob1.
}
object ob2 {
- implicit val f1: Int => String = _ => "Int"
+ implicit val f1: ImplicitConverter[Int, String] = _ => "Int"
implicit def f2(x: Long): String = "Long"
println(5: String)
}
object ob3 {
- implicit val f1: Int => String = _ => "Int"
- implicit val f2: Long => String = _ => "Long"
+ implicit val f1: ImplicitConverter[Int, String] = _ => "Int"
+ implicit val f2: ImplicitConverter[Long, String] = _ => "Long"
println(5: String)
}
diff --git a/tests/run/var-arity-class-symbol.scala b/tests/run/var-arity-class-symbol.scala
deleted file mode 100644
index 2a7d32987..000000000
--- a/tests/run/var-arity-class-symbol.scala
+++ /dev/null
@@ -1,19 +0,0 @@
-import scala.reflect.runtime.universe._, definitions._
-object Test extends dotty.runtime.LegacyApp {
- // Tuples
- assert(TupleClass.seq.size == 22)
- assert(TupleClass(0) == NoSymbol)
- assert(TupleClass(23) == NoSymbol)
- assert((1 to 22).forall { i => TupleClass(i).name.toString == s"Tuple$i" })
- // Functions
- assert(FunctionClass.seq.size == 23)
- assert(FunctionClass(-1) == NoSymbol)
- assert(FunctionClass(23) == NoSymbol)
- assert((0 to 22).forall { i => FunctionClass(i).name.toString == s"Function$i" })
- // Products
- assert(ProductClass.seq.size == 23)
- assert(ProductClass(-1) == NoSymbol)
- assert(ProductClass(0) == UnitClass)
- assert(ProductClass(23) == NoSymbol)
- assert((1 to 22).forall { i => ProductClass(i).name.toString == s"Product$i" })
-}