summaryrefslogtreecommitdiff
path: root/test/files/run/bitsets.scala
diff options
context:
space:
mode:
authorHeejong Lee <heejong@gmail.com>2013-04-06 01:48:31 +0900
committerHeejong Lee <heejong@gmail.com>2013-04-07 02:11:14 +0900
commite8c85a37186b65561a3826b9889c9d06a69650da (patch)
treec76805e6700fd62e44d0435767506cfc8d70cb79 /test/files/run/bitsets.scala
parentd301a86488f944ae3a1a14ba578ac8c87e64f01d (diff)
downloadscala-e8c85a37186b65561a3826b9889c9d06a69650da.tar.gz
scala-e8c85a37186b65561a3826b9889c9d06a69650da.tar.bz2
scala-e8c85a37186b65561a3826b9889c9d06a69650da.zip
SI-7080 improve boundary value checking for BitSet
When BitSet accepts a very large integer such as Int.MaxValue, integer overflow possibly occurs in the calculation of boundary value "nwords * WordLength". This faulty boundary condition causes empty-iterator problem like following: scala> import collection.mutable.BitSet import collection.mutable.BitSet scala> val x = BitSet(Int.MaxValue) x: scala.collection.mutable.BitSet = BitSet() scala> x.iterator res0: Iterator[Int] = empty iterator
Diffstat (limited to 'test/files/run/bitsets.scala')
-rw-r--r--test/files/run/bitsets.scala14
1 files changed, 14 insertions, 0 deletions
diff --git a/test/files/run/bitsets.scala b/test/files/run/bitsets.scala
index d55f9e4e83..c88782cab7 100644
--- a/test/files/run/bitsets.scala
+++ b/test/files/run/bitsets.scala
@@ -115,6 +115,19 @@ object TestMutable3 {
println(s"b0:$b0")
}
+object TestMutable4 {
+ import scala.collection.mutable.BitSet
+
+ val bMax = BitSet(Int.MaxValue)
+ println(s"bMax:$bMax")
+ bMax.foreach(println)
+
+ val bLarge = BitSet(2000000001)
+ println(s"bLarge:$bLarge")
+
+ println(bMax == bLarge)
+}
+
object TestImmutable {
import scala.collection.immutable.BitSet
@@ -190,6 +203,7 @@ object Test extends App {
TestMutable
TestMutable2
TestMutable3
+ TestMutable4
TestImmutable
TestImmutable2
}