summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorRex Kerr <ichoran@gmail.com>2014-11-21 12:14:00 -0800
committerRex Kerr <ichoran@gmail.com>2014-11-21 12:36:56 -0800
commita151449afb247b08d470c91f090f683ebc7ba5a4 (patch)
tree53bf014be32eaf9cffebb7ae31f1dcde24ece642 /test
parentc4df20d29a8d15ef23cf0d10fad56da0791bbbf6 (diff)
downloadscala-a151449afb247b08d470c91f090f683ebc7ba5a4.tar.gz
scala-a151449afb247b08d470c91f090f683ebc7ba5a4.tar.bz2
scala-a151449afb247b08d470c91f090f683ebc7ba5a4.zip
SI-8970 hashCode of BigDecimal and Double do not match
Switched isValidDouble (binary equivalence) to isDecimalDouble (decimal expansion equivalence), as people generally do not care about the slew of extra decimal digits off the end of the binary approximation to a decimal fraction (decimal equivalence is the standard now). Added minimal unit test to verify behavior.
Diffstat (limited to 'test')
-rw-r--r--test/junit/scala/math/BigDecimalTest.scala6
1 files changed, 6 insertions, 0 deletions
diff --git a/test/junit/scala/math/BigDecimalTest.scala b/test/junit/scala/math/BigDecimalTest.scala
index d1ba96fcc8..c7a63da890 100644
--- a/test/junit/scala/math/BigDecimalTest.scala
+++ b/test/junit/scala/math/BigDecimalTest.scala
@@ -222,4 +222,10 @@ class BigDecimalTest {
for (a <- different; b <- different if (a ne b))
assert(a != b, "BigDecimal representations of Double mistakenly conflated")
}
+
+ // Make sure hash code agrees with decimal representation of Double
+ @Test
+ def test_SI8970() {
+ assert((0.1).## == BigDecimal(0.1).##)
+ }
}