From 7a3e0b81df2431db1cbc8cbe4292f40c1704ed89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Doeraene?= Date: Wed, 31 May 2023 12:04:12 +0200 Subject: [PATCH] Make the weak-conformance test work on Scala.js. We use `x.isInstanceOf[T]` instead `x.getClass == classOf[T]` so that the tests pass on Scala.js. This is equivalent on the JVM, so it does not make the test weaker. [Cherry-picked 6db15daeb90cac1af56317bbb6bbcb67cf0a58a9] --- tests/run/weak-conformance.scala | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/tests/run/weak-conformance.scala b/tests/run/weak-conformance.scala index db551cf0ce15..af91698053e2 100644 --- a/tests/run/weak-conformance.scala +++ b/tests/run/weak-conformance.scala @@ -1,5 +1,3 @@ -// scalajs: --skip --pending - import collection.mutable.ArrayBuffer object Test extends App { inline val b = 33 @@ -16,11 +14,11 @@ object Test extends App { val x8 = List(5.toByte, 11) ; x8: List[Byte] val x9: List[AnyVal] = List(1.0f, 0) - assert(x9(0).getClass == classOf[java.lang.Float]) - assert(x9(1).getClass == classOf[java.lang.Float]) // expected type not fully defined, since `List` is covariant + assert(x9(0).isInstanceOf[java.lang.Float]) + assert(x9(1).isInstanceOf[java.lang.Float]) // expected type not fully defined, since `List` is covariant val x10 = List[Any](1.0f, 0) - assert(x10(0).getClass == classOf[java.lang.Float]) - assert(x10(1).getClass == classOf[java.lang.Integer]) + assert(x10(0).isInstanceOf[java.lang.Float]) + assert(x10(1).isInstanceOf[java.lang.Integer]) } locally { @@ -35,11 +33,11 @@ object Test extends App { val x8 = ArrayBuffer(5.toByte, 11) ; x8: ArrayBuffer[Byte] val x9: ArrayBuffer[AnyVal] = ArrayBuffer(1.0f, 0) - assert(x9(0).getClass == classOf[java.lang.Float]) - assert(x9(1).getClass == classOf[java.lang.Integer]) // expected type fully defined since ArrayBuffer is nonvariant + assert(x9(0).isInstanceOf[java.lang.Float]) + assert(x9(1).isInstanceOf[java.lang.Integer]) // expected type fully defined since ArrayBuffer is nonvariant val x10 = ArrayBuffer[Any](1.0f, 0) - assert(x10(0).getClass == classOf[java.lang.Float]) - assert(x10(1).getClass == classOf[java.lang.Integer]) + assert(x10(0).isInstanceOf[java.lang.Float]) + assert(x10(1).isInstanceOf[java.lang.Integer]) } locally { @@ -56,11 +54,11 @@ object Test extends App { val x8 = Array(5.toByte, 11) ; x8: Array[Int] val x9: Array[AnyVal] = Array(1.0f, 0) - assert(x9(0).getClass == classOf[java.lang.Float]) - assert(x9(1).getClass == classOf[java.lang.Integer]) // expected type fully defined since Array is nonvariant + assert(x9(0).isInstanceOf[java.lang.Float]) + assert(x9(1).isInstanceOf[java.lang.Integer]) // expected type fully defined since Array is nonvariant val x10 = Array[Any](1.0f, 0) - assert(x10(0).getClass == classOf[java.lang.Float]) - assert(x10(1).getClass == classOf[java.lang.Integer]) + assert(x10(0).isInstanceOf[java.lang.Float]) + assert(x10(1).isInstanceOf[java.lang.Integer]) } locally { @@ -74,4 +72,4 @@ object Test extends App { val x7 = if (true) b else if (true) 33 else 'a' ; x7: Char val x8 = if (true) 5.toByte else 11 ; x8: Byte } -} \ No newline at end of file +}