diff options
author | Paul Phillips <paulp@improving.org> | 2010-11-01 14:26:28 +0000 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2010-11-01 14:26:28 +0000 |
commit | 00b42b18ed462db89956de881bbc13740cd8ba82 (patch) | |
tree | 6be826d0465cd687d17ac98daf08f5a945ef69b2 /test/files/run/bug3232.scala | |
parent | 6beaf28e6d25535ac9a1d4abe195bb32ebff8c15 (diff) | |
download | scala-00b42b18ed462db89956de881bbc13740cd8ba82.tar.gz scala-00b42b18ed462db89956de881bbc13740cd8ba82.tar.bz2 scala-00b42b18ed462db89956de881bbc13740cd8ba82.zip |
Took a step back and massively simplified Range.
all the boundary conditions I'm aware of, including not yet reported
ones such as
scala> 5 until 5 last
res0: Int = 4
and
scala> 1073741823 to Int.MaxValue by (1 << 24) size
res0: Int = 65
scala> 1073741823 to Int.MaxValue by (1 << 24) drop 100 size
res1: Int = 256
Also includes conformance improvements (e.g. 5 until 5 init should throw
an exception, not return empty) and general improvements (e.g. 1 to 10
tail should return a Range.) Will close associated tickets such as #3232
after I complete similar work on NumericRange. Review by community.
Diffstat (limited to 'test/files/run/bug3232.scala')
-rw-r--r-- | test/files/run/bug3232.scala | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/test/files/run/bug3232.scala b/test/files/run/bug3232.scala new file mode 100644 index 0000000000..acb1a1e0e9 --- /dev/null +++ b/test/files/run/bug3232.scala @@ -0,0 +1,21 @@ +object Test { + // some maximally sized ranges + val r1 = 0 until Int.MaxValue + val r2 = 1 to Int.MaxValue + val r3 = Int.MinValue to -2 + val r4 = Int.MinValue until -1 + + // some exceptional conditions + val e1 = () => (0 to Int.MaxValue).length + val e2 = () => (5 until 5).last + + def main(args: Array[String]): Unit = { + List(r1, r2, r3, r4) foreach (x => assert(x.length == Int.MaxValue)) + + // exception required + List(e1, e2) foreach { f => + try { f() ; assert(false) } + catch { case _ => () } + } + } +} |