scala / bug

Scala 2 bug reports only. Please, no questions — proper bug reports only.
https://scala-lang.org
230 stars 21 forks source link

Tasty test case TestLogarithms failed #12759

Closed liang3zy22 closed 1 year ago

liang3zy22 commented 1 year ago

Reproduction steps

Scala version: scala/scala 2.13.x branch

sbt:root> restarrFull
sbt:root> compile
sbt:root> tasty/test

Problem

Test case tastytest.TestLogarithms failed.

ERROR: tastytest.TestLogarithms failed: AssertionError 1 error at iteration 0:
AssertionError in TestLogarithms.`test`: assertion failed in 
  tastytest.Suite.runImpl(Suite.scala:59)
  tastytest.Suite.main(Suite.scala:40)
  tastytest.TestLogarithms.main(TestLogarithms.scala)
  java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
  java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
  java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
  java.base/java.lang.reflect.Method.invoke(Method.java:566)
  scala.tools.tastytest.internal.Runner$.$anonfun$run$2(Runner.scala:26)
  scala.util.DynamicVariable.withValue(DynamicVariable.scala:59)
  scala.Console$.withErr(Console.scala:193)
  ....................
  com.novocode.junit.JUnitTask.execute(JUnitTask.java:64)
  sbt.ForkMain$Run.lambda$runTest$1(ForkMain.java:413)
  java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
  java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
  java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
  java.base/java.lang.Thread.run(Thread.java:829)
[error] Test scala.tools.tastytest.TastyTestJUnit.run failed: java.lang.AssertionError: scala.tools.tastytest.TestFailure: 1 error. Fix tastytest.TestLogarithms., took 3.747 sec

My environment: MacOS M1 platform. openjdk version "11.0.18" 2023-01-17 OpenJDK Runtime Environment Homebrew (build 11.0.18+0) OpenJDK 64-Bit Server VM Homebrew (build 11.0.18+0, mixed mode)

I have done some investigation. The following codes have unexpected result:

scala> math.exp(math.log(math.exp(math.log(2)) + math.exp(math.log(3))))
val res0: Double = 5.0

In another platform(xx86_64), the result is:

scala> math.exp(math.log(math.exp(math.log(2)) + math.exp(math.log(3))))
val res0: Double = 4.999999999999999

I think it is M1 arm64 platform issue. Need to try it on other arm64 platform.

SethTisue commented 1 year ago

@bishabosha ?

bishabosha commented 1 year ago

This test was really to copy paste the example from the SIP for opaque types - if there are problems with double arithmetic then we should change the test - to literally anything as long as it exercises scala 2 calling some methods with opaque types in the signature

liang3zy22 commented 1 year ago

Ok, I will create a PR to update the test case.