From f3e7e98cc0f47eacb59400b2c56c6bd2cb8b2ebc Mon Sep 17 00:00:00 2001 From: Simon Ochsenreither Date: Wed, 7 Dec 2011 21:52:20 +0100 Subject: Clean up standard/swing library by deprecating/moving code examples Deprecate scala/xml/include/sax/Main.scala. Move scala/swing/test/* to docs/examples. Saves 160KB in scala-swing.jar. Fixes SI-4627. --- src/library/scala/xml/include/sax/Main.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/library') diff --git a/src/library/scala/xml/include/sax/Main.scala b/src/library/scala/xml/include/sax/Main.scala index 6b6f6c1593..f58097bcb9 100644 --- a/src/library/scala/xml/include/sax/Main.scala +++ b/src/library/scala/xml/include/sax/Main.scala @@ -10,11 +10,11 @@ package scala.xml package include.sax -import scala.xml.include._ import scala.util.control.Exception.{ catching, ignoring } import org.xml.sax.XMLReader import org.xml.sax.helpers.XMLReaderFactory +@deprecated("Code example will be moved to documentation.", "2.10.0") object Main { private val namespacePrefixes = "http://xml.org/sax/features/namespace-prefixes" private val lexicalHandler = "http://xml.org/sax/properties/lexical-handler" -- cgit v1.2.3 From d847278347e4c52b815920fe0e469927c3bbaaa9 Mon Sep 17 00:00:00 2001 From: Michael Schmitz Date: Mon, 9 Jan 2012 11:15:51 -0800 Subject: Added toString to Codec class (uses Codec.name). --- src/library/scala/io/Codec.scala | 3 +++ 1 file changed, 3 insertions(+) (limited to 'src/library') diff --git a/src/library/scala/io/Codec.scala b/src/library/scala/io/Codec.scala index 1a27df1c10..d9cef0edb1 100644 --- a/src/library/scala/io/Codec.scala +++ b/src/library/scala/io/Codec.scala @@ -38,6 +38,9 @@ class Codec(val charSet: Charset) { private[this] var _decodingReplacement: String = null private[this] var _onCodingException: Handler = e => throw e + /** The name of the Codec. */ + override def toString = name + // these methods can be chained to configure the variables above def onMalformedInput(newAction: Action): this.type = { _onMalformedInput = newAction ; this } def onUnmappableCharacter(newAction: Action): this.type = { _onUnmappableCharacter = newAction ; this } -- cgit v1.2.3 From b7bd309f0982df73bd2ac41c6cd8d2e399ff3ee4 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Tue, 10 Jan 2012 14:39:38 +0100 Subject: Fixing redundant type parameter in toIndexedSeq which causes suboptimal type inference --- src/library/scala/collection/GenTraversableOnce.scala | 2 +- src/library/scala/collection/TraversableOnce.scala | 2 +- src/library/scala/collection/TraversableProxyLike.scala | 2 +- src/library/scala/collection/generic/TraversableForwarder.scala | 2 +- src/library/scala/collection/immutable/IndexedSeq.scala | 2 +- src/library/scala/collection/interfaces/TraversableOnceMethods.scala | 2 +- src/library/scala/collection/parallel/ParIterableLike.scala | 2 +- 7 files changed, 7 insertions(+), 7 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/GenTraversableOnce.scala b/src/library/scala/collection/GenTraversableOnce.scala index 3e42e7812b..305f8d768d 100644 --- a/src/library/scala/collection/GenTraversableOnce.scala +++ b/src/library/scala/collection/GenTraversableOnce.scala @@ -471,7 +471,7 @@ trait GenTraversableOnce[+A] { * $willNotTerminateInf * @return an indexed sequence containing all elements of this $coll. */ - def toIndexedSeq[A1 >: A]: immutable.IndexedSeq[A1] + def toIndexedSeq: immutable.IndexedSeq[A] /** Converts this $coll to a stream. * $willNotTerminateInf diff --git a/src/library/scala/collection/TraversableOnce.scala b/src/library/scala/collection/TraversableOnce.scala index 908c4c808d..5bb2e563f6 100644 --- a/src/library/scala/collection/TraversableOnce.scala +++ b/src/library/scala/collection/TraversableOnce.scala @@ -245,7 +245,7 @@ trait TraversableOnce[+A] extends GenTraversableOnce[A] { def toSeq: Seq[A] = toStream - def toIndexedSeq[B >: A]: immutable.IndexedSeq[B] = immutable.IndexedSeq() ++ seq + def toIndexedSeq: immutable.IndexedSeq[A] = immutable.IndexedSeq() ++ seq def toBuffer[B >: A]: mutable.Buffer[B] = new ArrayBuffer[B] ++= seq diff --git a/src/library/scala/collection/TraversableProxyLike.scala b/src/library/scala/collection/TraversableProxyLike.scala index 15565e57c6..e7e797391e 100644 --- a/src/library/scala/collection/TraversableProxyLike.scala +++ b/src/library/scala/collection/TraversableProxyLike.scala @@ -77,7 +77,7 @@ trait TraversableProxyLike[+A, +Repr <: TraversableLike[A, Repr] with Traversabl override def toList: List[A] = self.toList override def toIterable: Iterable[A] = self.toIterable override def toSeq: Seq[A] = self.toSeq - override def toIndexedSeq[B >: A] = self.toIndexedSeq + override def toIndexedSeq: immutable.IndexedSeq[A] = self.toIndexedSeq override def toBuffer[B >: A] = self.toBuffer override def toStream: Stream[A] = self.toStream override def toSet[B >: A]: immutable.Set[B] = self.toSet diff --git a/src/library/scala/collection/generic/TraversableForwarder.scala b/src/library/scala/collection/generic/TraversableForwarder.scala index 6529fe4a79..3d723a1feb 100644 --- a/src/library/scala/collection/generic/TraversableForwarder.scala +++ b/src/library/scala/collection/generic/TraversableForwarder.scala @@ -61,7 +61,7 @@ trait TraversableForwarder[+A] extends Traversable[A] { override def toList: List[A] = underlying.toList override def toIterable: Iterable[A] = underlying.toIterable override def toSeq: Seq[A] = underlying.toSeq - override def toIndexedSeq[B >: A] = underlying.toIndexedSeq + override def toIndexedSeq = underlying.toIndexedSeq override def toBuffer[B >: A] = underlying.toBuffer override def toStream: Stream[A] = underlying.toStream override def toSet[B >: A]: immutable.Set[B] = underlying.toSet diff --git a/src/library/scala/collection/immutable/IndexedSeq.scala b/src/library/scala/collection/immutable/IndexedSeq.scala index bbbef158af..e3939001d8 100644 --- a/src/library/scala/collection/immutable/IndexedSeq.scala +++ b/src/library/scala/collection/immutable/IndexedSeq.scala @@ -22,7 +22,7 @@ trait IndexedSeq[+A] extends Seq[A] with GenericTraversableTemplate[A, IndexedSeq] with IndexedSeqLike[A, IndexedSeq[A]] { override def companion: GenericCompanion[IndexedSeq] = IndexedSeq - override def toIndexedSeq[B >: A]: IndexedSeq[B] = this + override def toIndexedSeq: IndexedSeq[A] = this override def seq: IndexedSeq[A] = this } diff --git a/src/library/scala/collection/interfaces/TraversableOnceMethods.scala b/src/library/scala/collection/interfaces/TraversableOnceMethods.scala index 5e1325fef6..471e977134 100644 --- a/src/library/scala/collection/interfaces/TraversableOnceMethods.scala +++ b/src/library/scala/collection/interfaces/TraversableOnceMethods.scala @@ -48,7 +48,7 @@ trait TraversableOnceMethods[+A] { // conversions def toArray[B >: A : ClassManifest]: Array[B] def toBuffer[B >: A]: mutable.Buffer[B] - def toIndexedSeq[B >: A]: immutable.IndexedSeq[B] + def toIndexedSeq: immutable.IndexedSeq[A] def toIterable: Iterable[A] def toIterator: Iterator[A] def toList: List[A] diff --git a/src/library/scala/collection/parallel/ParIterableLike.scala b/src/library/scala/collection/parallel/ParIterableLike.scala index f0d79ada9d..90b64c17f9 100644 --- a/src/library/scala/collection/parallel/ParIterableLike.scala +++ b/src/library/scala/collection/parallel/ParIterableLike.scala @@ -801,7 +801,7 @@ self: ParIterableLike[T, Repr, Sequential] => override def toList: List[T] = seq.toList - override def toIndexedSeq[U >: T]: collection.immutable.IndexedSeq[U] = seq.toIndexedSeq[U] + override def toIndexedSeq: collection.immutable.IndexedSeq[T] = seq.toIndexedSeq override def toStream: Stream[T] = seq.toStream -- cgit v1.2.3 From 5f2568e36b87d183fd4e4442d5c304db628846c4 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 10 Jan 2012 09:49:46 -0800 Subject: Revert "Accept prefixed xml attributes with null value" This reverts commit 51089b34a7a535498dee42e6465d4d577d65b7d5. A scaladoc test is failing and I have no time to look at it. --- src/library/scala/xml/PrefixedAttribute.scala | 15 ++++++--------- test/files/run/xml-attribute.scala | 25 +++---------------------- 2 files changed, 9 insertions(+), 31 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/xml/PrefixedAttribute.scala b/src/library/scala/xml/PrefixedAttribute.scala index b80d6a1c73..436dfcda43 100644 --- a/src/library/scala/xml/PrefixedAttribute.scala +++ b/src/library/scala/xml/PrefixedAttribute.scala @@ -13,25 +13,22 @@ package scala.xml * * @param pre ... * @param key ... - * @param value the attribute value + * @param value the attribute value, which may not be null * @param next ... */ class PrefixedAttribute( val pre: String, val key: String, val value: Seq[Node], - val next1: MetaData) + val next: MetaData) extends Attribute { - val next = if (value ne null) next1 else next1.remove(key) + if (value eq null) + throw new UnsupportedOperationException("value is null") - /** same as this(pre, key, Text(value), next), or no attribute if value is null */ + /** same as this(key, Utility.parseAttributeValue(value), next) */ def this(pre: String, key: String, value: String, next: MetaData) = - this(pre, key, if (value ne null) Text(value) else null: NodeSeq, next) - - /** same as this(pre, key, value.get, next), or no attribute if value is None */ - def this(pre: String, key: String, value: Option[Seq[Node]], next: MetaData) = - this(pre, key, value.orNull, next) + this(pre, key, Text(value), next) /** Returns a copy of this unprefixed attribute with the given * next field. diff --git a/test/files/run/xml-attribute.scala b/test/files/run/xml-attribute.scala index 8b261acc94..2b83f70b22 100644 --- a/test/files/run/xml-attribute.scala +++ b/test/files/run/xml-attribute.scala @@ -5,29 +5,10 @@ object Test { val noAttr = val attrNull = val attrNone = - val preAttrNull = - val preAttrNone = assert(noAttr == attrNull) assert(noAttr == attrNone) - assert(noAttr == preAttrNull) - assert(noAttr == preAttrNone) - - val noAttrStr = "" - assert(noAttr.toString() == noAttrStr) - assert(attrNull.toString() == noAttrStr) - assert(attrNone.toString() == noAttrStr) - assert(preAttrNull.toString() == noAttrStr) - assert(preAttrNone.toString() == noAttrStr) - - val xml1 = - val xml2 = - val xml3 = - assert(xml1 == xml2) - assert(xml1 == xml3) - - val xml1Str = "" - assert(xml1.toString() == xml1Str) - assert(xml2.toString() == xml1Str) - assert(xml3.toString() == xml1Str) + assert(noAttr.toString() == "") + assert(attrNull.toString() == "") + assert(attrNone.toString() == "") } } -- cgit v1.2.3 From 25fcbd7021cad1e3c7b50c2b8f5c586008579bf9 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Tue, 10 Jan 2012 11:18:59 -0800 Subject: Traitified JavaConverters. So it can be used as a mixin. --- src/library/scala/collection/JavaConverters.scala | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'src/library') diff --git a/src/library/scala/collection/JavaConverters.scala b/src/library/scala/collection/JavaConverters.scala index 94f7e9701b..d213e60112 100755 --- a/src/library/scala/collection/JavaConverters.scala +++ b/src/library/scala/collection/JavaConverters.scala @@ -48,7 +48,8 @@ package scala.collection * @author Martin Odersky * @since 2.8.1 */ -object JavaConverters { + +trait JavaConverters { import java.{ lang => jl, util => ju } import java.util.{ concurrent => juc } import JavaConversions._ @@ -536,3 +537,5 @@ object JavaConverters { propertiesAsScalaMapConverter(p) } + +object JavaConverters extends JavaConverters \ No newline at end of file -- cgit v1.2.3 From 51ddeb372b3f0b22041d9a51f3faee17acd7b749 Mon Sep 17 00:00:00 2001 From: aleksandar Date: Thu, 12 Jan 2012 15:28:25 +0100 Subject: Add mutable tree sets to the standard library. This implementation is based on AVL trees. The current implementation is contributed by Lucien Pereira. Fixes #4147. --- .gitignore | 2 + .../generic/MutableSortedSetFactory.scala | 33 ++++ src/library/scala/collection/mutable/AVLTree.scala | 206 +++++++++++++++++++++ .../scala/collection/mutable/SortedSet.scala | 49 +++++ src/library/scala/collection/mutable/TreeSet.scala | 130 +++++++++++++ test/benchmarking/AVL-insert-random.scala | 67 +++++++ test/benchmarking/AVL-insert.scala | 67 +++++++ test/files/jvm/serialization.check | 4 + test/files/jvm/serialization.scala | 7 +- test/files/run/si4147.scala | 36 ++++ test/files/scalacheck/si4147.scala | 67 +++++++ 11 files changed, 667 insertions(+), 1 deletion(-) create mode 100644 src/library/scala/collection/generic/MutableSortedSetFactory.scala create mode 100644 src/library/scala/collection/mutable/AVLTree.scala create mode 100644 src/library/scala/collection/mutable/SortedSet.scala create mode 100644 src/library/scala/collection/mutable/TreeSet.scala create mode 100644 test/benchmarking/AVL-insert-random.scala create mode 100644 test/benchmarking/AVL-insert.scala create mode 100644 test/files/run/si4147.scala create mode 100644 test/files/scalacheck/si4147.scala (limited to 'src/library') diff --git a/.gitignore b/.gitignore index d392f0e82c..2121e38a7e 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,3 @@ *.jar +build +*.*~ diff --git a/src/library/scala/collection/generic/MutableSortedSetFactory.scala b/src/library/scala/collection/generic/MutableSortedSetFactory.scala new file mode 100644 index 0000000000..b235379575 --- /dev/null +++ b/src/library/scala/collection/generic/MutableSortedSetFactory.scala @@ -0,0 +1,33 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.collection +package generic + +import scala.collection.mutable.{ Builder, GrowingBuilder } + +/** + * @define Coll mutable.SortedSet + * @define coll mutable sorted + * + * @author Lucien Pereira + * + */ +abstract class MutableSortedSetFactory[CC[A] <: mutable.SortedSet[A] with SortedSetLike[A, CC[A]] with mutable.Set[A] with mutable.SetLike[A, CC[A]]] extends SortedSetFactory[CC] { + + /** + * mutable.SetBuilder uses '+' which is not a primitive for anything extending mutable.SetLike, + * this causes serious perfomances issues since each time 'elems = elems + x' + * is evaluated elems is cloned (which is O(n)). + * + * Fortunately GrowingBuilder comes to rescue. + * + */ + override def newBuilder[A](implicit ord: Ordering[A]): Builder[A, CC[A]] = new GrowingBuilder[A, CC[A]](empty) + +} diff --git a/src/library/scala/collection/mutable/AVLTree.scala b/src/library/scala/collection/mutable/AVLTree.scala new file mode 100644 index 0000000000..0cf6cb06e5 --- /dev/null +++ b/src/library/scala/collection/mutable/AVLTree.scala @@ -0,0 +1,206 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.collection +package mutable + +import annotation.tailrec + +/** + * An immutable AVL Tree implementation used by mutable.TreeSet + * + * @author Lucien Pereira + * + */ +private[mutable] sealed trait AVLTree[+A] extends Serializable { + def balance: Int + + def depth: Int + +} + +private case class Node[A](val data: A, val left: AVLTree[A], val right: AVLTree[A]) extends AVLTree[A] { + override val balance: Int = right.depth - left.depth + + override val depth: Int = math.max(left.depth, right.depth) + 1 + +} + +private case object Leaf extends AVLTree[Nothing] { + override val balance: Int = 0 + + override val depth: Int = -1 + +} + +private[mutable] object AVLTree { + + /** + * Returns a new tree containing the given element. + * Thows an IllegalArgumentException if element is already present. + * + */ + def insert[A](value: A, tree: AVLTree[A], ordering: Ordering[A]): AVLTree[A] = { + @tailrec + def insertTC(value: A, tree: AVLTree[A], reassemble: AVLTree[A] => AVLTree[A]): AVLTree[A] = tree match { + case Leaf => reassemble(Node(value, Leaf, Leaf)) + + case Node(a, left, right) => if (0 == ordering.compare(value, a)) { + throw new IllegalArgumentException() + } else if (-1 == ordering.compare(value, a)) { + insertTC(value, left, x => reassemble(rebalance(Node(a, x, right)))) + } else { + insertTC(value, right, x => reassemble(rebalance(Node(a, left, x)))) + } + } + + insertTC(value, tree, x => rebalance(x)) + } + + def contains[A](value: A, tree: AVLTree[A], ordering: Ordering[A]): Boolean = tree match { + case Leaf => false + + case Node(a, left, right) => if (0 == ordering.compare(value, a)) { + true + } else if (-1 == ordering.compare(value, a)) { + contains(value, left, ordering) + } else { + contains(value, right, ordering) + } + } + + /** + * Return a new tree which not contains given element. + * + */ + def remove[A](value: A, tree: AVLTree[A], ordering: Ordering[A]): AVLTree[A] = tree match { + case Leaf => throw new NoSuchElementException() + + case Node(a, Leaf, Leaf) => if (0 == ordering.compare(value, a)) { + Leaf + } else { + throw new NoSuchElementException() + } + + case Node(a, left, right@Node(_, _, _)) => if (0 == ordering.compare(value, a)) { + val (min, newRight) = removeMin(right) + rebalance(Node(min, left, newRight)) + } else if (-1 == ordering.compare(value, a)) { + rebalance(Node(a, remove(value, left, ordering), right)) + } else { + rebalance(Node(a, left, remove(value, right, ordering))) + } + + case Node(a, left@Node(_, _, _), right) => if (0 == ordering.compare(value, a)) { + val (max, newLeft) = removeMax(left) + rebalance(Node(max, newLeft, right)) + } else if (-1 == ordering.compare(value, a)) { + rebalance(Node(a, remove(value, left, ordering), right)) + } else { + rebalance(Node(a, left, remove(value, right, ordering))) + } + } + + /** + * Return a tuple containing the biggest element of the provided tree + * and a new tree from which this element has been extracted. + * + */ + def removeMax[A](tree: Node[A]): (A, AVLTree[A]) = { + @tailrec + def removeMaxTC(tree: AVLTree[A], assemble: (A, AVLTree[A]) => (A, AVLTree[A])): (A, AVLTree[A]) = tree match { + case Node(a, Leaf, Leaf) => assemble(a, Leaf) + case Node(a, left, Leaf) => assemble(a, left) + case Node(a, left, right) => removeMaxTC(right, + (max: A, avl: AVLTree[A]) => assemble(max, rebalance(Node(a, left, avl)))) + case Leaf => sys.error("Should not happen.") + } + + removeMaxTC(tree, (a, b) => (a, b)) + } + + /** + * Return a tuple containing the smallest element of the provided tree + * and a new tree from which this element has been extracted. + * + */ + def removeMin[A](tree: Node[A]): (A, AVLTree[A]) = { + @tailrec + def removeMinTC(tree: AVLTree[A], assemble: (A, AVLTree[A]) => (A, AVLTree[A])): (A, AVLTree[A]) = tree match { + case Node(a, Leaf, Leaf) => assemble(a, Leaf) + case Node(a, Leaf, right) => assemble(a, right) + case Node(a, left, right) => removeMinTC(left, + (min: A, avl: AVLTree[A]) => assemble(min, rebalance(Node(a, avl, right)))) + case Leaf => sys.error("Should not happen.") + } + + removeMinTC(tree, (a, b) => (a, b)) + } + + /** + * Returns a bounded stream of elements in the tree. + * + */ + def toStream[A](tree: AVLTree[A], isLeftAcceptable: A => Boolean, isRightAcceptable: A => Boolean): Stream[A] = tree match { + case Leaf => Stream.empty + + case Node(a, left, right) => if (isLeftAcceptable(a)) { + if (isRightAcceptable(a)) { + toStream(left, isLeftAcceptable, isRightAcceptable) ++ Stream(a) ++ toStream(right, isLeftAcceptable, isRightAcceptable) + } else { + toStream(left, isLeftAcceptable, isRightAcceptable) + } + } else if (isRightAcceptable(a)) { + toStream(right, isLeftAcceptable, isRightAcceptable) + } else { + Stream.empty + } + } + + /** + * Returns a bounded iterator of elements in the tree. + * + */ + def iterator[A](tree: AVLTree[A], isLeftAcceptable: A => Boolean, isRightAcceptable: A => Boolean): Iterator[A] = + toStream(tree, isLeftAcceptable, isRightAcceptable).iterator + + def rebalance[A](tree: AVLTree[A]): AVLTree[A] = (tree, tree.balance) match { + case (node@Node(_, left, _), -2) => left.balance match { + case 1 => doubleRightRotation(node) + case _ => rightRotation(node) + } + + case (node@Node(_, _, right), 2) => right.balance match { + case -1 => doubleLeftRotation(node) + case _ => leftRotation(node) + } + + case _ => tree + } + + def leftRotation[A](tree: Node[A]): AVLTree[A] = tree.right match { + case Node(b, left, right) => Node(b, Node(tree.data, tree.left, left), right) + case _ => sys.error("Should not happen.") + } + + def rightRotation[A](tree: Node[A]): AVLTree[A] = tree.left match { + case Node(b, left, right) => Node(b, left, Node(tree.data, right, tree.right)) + case _ => sys.error("Should not happen.") + } + + def doubleLeftRotation[A](tree: Node[A]): AVLTree[A] = tree.right match { + case right@Node(b, l, r) => leftRotation(Node(tree.data, tree.left, rightRotation(right))) + case _ => sys.error("Should not happen.") + } + + def doubleRightRotation[A](tree: Node[A]): AVLTree[A] = tree.left match { + case left@Node(b, l, r) => rightRotation(Node(tree.data, leftRotation(left), tree.right)) + case _ => sys.error("Should not happen.") + } + +} diff --git a/src/library/scala/collection/mutable/SortedSet.scala b/src/library/scala/collection/mutable/SortedSet.scala new file mode 100644 index 0000000000..d87fc0b4a2 --- /dev/null +++ b/src/library/scala/collection/mutable/SortedSet.scala @@ -0,0 +1,49 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.collection +package mutable + +import generic._ + +/** + * Base trait for mutable sorted set. + * + * @define Coll mutable.SortedSet + * @define coll mutable sorted set + * + * @author Lucien Pereira + * + */ +trait SortedSet[A] extends collection.SortedSet[A] with collection.SortedSetLike[A,SortedSet[A]] + with mutable.Set[A] with mutable.SetLike[A, SortedSet[A]] { + + /** Needs to be overridden in subclasses. */ + override def empty: SortedSet[A] = SortedSet.empty[A] + +} + +/** + * A template for mutable sorted set companion objects. + * + * @define Coll mutable.SortedSet + * @define coll mutable sorted set + * @define factoryInfo + * This object provides a set of operations needed to create sorted sets of type mutable.SortedSet. + * @define sortedSetCanBuildFromInfo + * Standard `CanBuildFrom` instance for sorted sets. + * + * @author Lucien Pereira + * + */ +object SortedSet extends MutableSortedSetFactory[SortedSet] { + implicit def canBuildFrom[A](implicit ord: Ordering[A]): CanBuildFrom[Coll, A, SortedSet[A]] = new SortedSetCanBuildFrom[A] + + def empty[A](implicit ord: Ordering[A]): SortedSet[A] = TreeSet.empty[A] + +} diff --git a/src/library/scala/collection/mutable/TreeSet.scala b/src/library/scala/collection/mutable/TreeSet.scala new file mode 100644 index 0000000000..8039db7cc9 --- /dev/null +++ b/src/library/scala/collection/mutable/TreeSet.scala @@ -0,0 +1,130 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala.collection +package mutable + + + +import generic._ + + + +/** + * @define Coll mutable.TreeSet + * @define coll mutable tree set + * @factoryInfo + * Companion object of TreeSet providing factory related utilities. + * + * @author Lucien Pereira + * + */ +object TreeSet extends MutableSortedSetFactory[TreeSet] { + /** + * The empty set of this type + */ + def empty[A](implicit ordering: Ordering[A]) = new TreeSet[A]() + +} + +/** + * A mutable SortedSet using an immutable AVL Tree as underlying data structure. + * + * @author Lucien Pereira + * + */ +class TreeSet[A](implicit val ordering: Ordering[A]) extends SortedSet[A] with SetLike[A, TreeSet[A]] + with SortedSetLike[A, TreeSet[A]] with Set[A] with Serializable { + + // Projection constructor + private def this(base: Option[TreeSet[A]], from: Option[A], until: Option[A])(implicit ordering: Ordering[A]) { + this(); + this.base = base + this.from = from + this.until = until + } + + private var base: Option[TreeSet[A]] = None + + private var from: Option[A] = None + + private var until: Option[A] = None + + private var avl: AVLTree[A] = Leaf + + private var cardinality: Int = 0 + + def resolve: TreeSet[A] = base.getOrElse(this) + + private def isLeftAcceptable(from: Option[A], ordering: Ordering[A])(a: A): Boolean = + from.map(x => ordering.gteq(a, x)).getOrElse(true) + + private def isRightAcceptable(until: Option[A], ordering: Ordering[A])(a: A): Boolean = + until.map(x => ordering.lt(a, x)).getOrElse(true) + + /** + * Cardinality store the set size, unfortunately a + * set view (given by rangeImpl) + * cannot take advantage of this optimisation + * + */ + override def size: Int = base.map(_ => super.size).getOrElse(cardinality) + + override def stringPrefix = "TreeSet" + + override def empty: TreeSet[A] = TreeSet.empty + + override def rangeImpl(from: Option[A], until: Option[A]): TreeSet[A] = new TreeSet(Some(this), from, until) + + override def -=(elem: A): this.type = { + try { + resolve.avl = AVLTree.remove(elem, resolve.avl, ordering) + resolve.cardinality = resolve.cardinality - 1 + } catch { + case e: NoSuchElementException => () + case a: Any => a.printStackTrace + } + this + } + + override def +=(elem: A): this.type = { + try { + resolve.avl = AVLTree.insert(elem, resolve.avl, ordering) + resolve.cardinality = resolve.cardinality + 1 + } catch { + case e: IllegalArgumentException => () + case a: Any => a.printStackTrace + } + this + } + + /** + * Thanks to the nature immutable of the + * underlying AVL Tree, we can share it with + * the clone. So clone complexity in time is O(1). + * + */ + override def clone: TreeSet[A] = { + val clone = new TreeSet[A](base, from, until) + clone.avl = resolve.avl + clone.cardinality = resolve.cardinality + clone + } + + override def contains(elem: A): Boolean = { + isLeftAcceptable(from, ordering)(elem) && + isRightAcceptable(until, ordering)(elem) && + AVLTree.contains(elem, resolve.avl, ordering) + } + + override def iterator: Iterator[A] = + AVLTree.iterator(resolve.avl, + isLeftAcceptable(from, ordering), + isRightAcceptable(until, ordering)) + +} diff --git a/test/benchmarking/AVL-insert-random.scala b/test/benchmarking/AVL-insert-random.scala new file mode 100644 index 0000000000..7299e330f5 --- /dev/null +++ b/test/benchmarking/AVL-insert-random.scala @@ -0,0 +1,67 @@ +package scala.collection + + + + + +class Dummy(val a: Int) extends math.Ordered[Dummy] { + def compare(other: Dummy) = this.a - other.a + override def toString = a.toString +} + + +object RandomGlobal { + val sz = 500000 + val data = util.Random.shuffle((0 until sz) map { new Dummy(_) }) toArray; +} + + +import RandomGlobal._ + + +object RandomAVL extends testing.Benchmark { + + def run() { + val avl = new collection.mutable.TreeSet[Dummy] + + var i = 0 + while (i < sz) { + val elem = data(i) + avl += elem + i += 1 + } + } + +} + + +object RandomImmutableTreeSet extends testing.Benchmark { + + def run() { + var tree = new collection.immutable.TreeSet[Dummy] + + var i = 0 + while (i < sz) { + val elem = data(i) + tree += elem + i += 1 + } + } + +} + + +object RandomJavaTreeSet extends testing.Benchmark { + + def run() { + val tree = new java.util.TreeSet[Dummy] + + var i = 0 + while (i < sz) { + val elem = data(i) + tree add elem + i += 1 + } + } + +} diff --git a/test/benchmarking/AVL-insert.scala b/test/benchmarking/AVL-insert.scala new file mode 100644 index 0000000000..4f3ab390c9 --- /dev/null +++ b/test/benchmarking/AVL-insert.scala @@ -0,0 +1,67 @@ +package scala.collection + + + + + +class Dummy(val a: Int) extends math.Ordered[Dummy] { + def compare(other: Dummy) = this.a - other.a + override def toString = a.toString +} + + +object Global { + val sz = 500000 + val data = (0 until sz) map { new Dummy(_) } toArray +} + + +import Global._ + + +object AVL extends testing.Benchmark { + + def run() { + val avl = new collection.mutable.TreeSet[Dummy] + + var i = 0 + while (i < sz) { + val elem = data(i) + avl += elem + i += 1 + } + } + +} + + +object ImmutableTreeSet extends testing.Benchmark { + + def run() { + var tree = new collection.immutable.TreeSet[Dummy] + + var i = 0 + while (i < sz) { + val elem = data(i) + tree += elem + i += 1 + } + } + +} + + +object JavaTreeSet extends testing.Benchmark { + + def run() { + val tree = new java.util.TreeSet[Dummy] + + var i = 0 + while (i < sz) { + val elem = data(i) + tree add elem + i += 1 + } + } + +} diff --git a/test/files/jvm/serialization.check b/test/files/jvm/serialization.check index 15708f0c3b..bc56387f81 100644 --- a/test/files/jvm/serialization.check +++ b/test/files/jvm/serialization.check @@ -188,6 +188,10 @@ x = WrappedArray(1, 2, 3) y = WrappedArray(1, 2, 3) x equals y: true, y equals x: true +x = TreeSet(1, 2, 3) +y = TreeSet(1, 2, 3) +x equals y: true, y equals x: true + x = xml:src="hello" y = xml:src="hello" x equals y: true, y equals x: true diff --git a/test/files/jvm/serialization.scala b/test/files/jvm/serialization.scala index 9391b60e46..73bed2d46b 100644 --- a/test/files/jvm/serialization.scala +++ b/test/files/jvm/serialization.scala @@ -286,7 +286,7 @@ object Test3_mutable { import scala.collection.mutable.{ ArrayBuffer, ArrayBuilder, ArraySeq, ArrayStack, BitSet, DoubleLinkedList, HashMap, HashSet, History, LinkedList, ListBuffer, Publisher, Queue, - Stack, StringBuilder, WrappedArray} + Stack, StringBuilder, WrappedArray, TreeSet} // in alphabetic order try { @@ -380,6 +380,11 @@ object Test3_mutable { val wa1 = WrappedArray.make(Array(1, 2, 3)) val _wa1: WrappedArray[Int] = read(write(wa1)) check(wa1, _wa1) + + // TreeSet + val ts1 = TreeSet[Int]() ++= Array(1, 2, 3) + val _ts1: TreeSet[Int] = read(write(ts1)) + check(ts1, _ts1) } catch { case e: Exception => diff --git a/test/files/run/si4147.scala b/test/files/run/si4147.scala new file mode 100644 index 0000000000..c1e2d746a9 --- /dev/null +++ b/test/files/run/si4147.scala @@ -0,0 +1,36 @@ + + + +import scala.collection._ + + + +object Test { + + def main(args: Array[String]) { + checkElementsAreSorted() + checkRangedImpl() + } + + def checkElementsAreSorted() { + val tree = mutable.SortedSet[Int]() + tree ++= List(4, 3, 1, 6, 7, 5, 2) + assert(tree == immutable.SortedSet(1, 2, 3, 4, 5, 6, 7)) + assert(tree.size == 7) + } + + def checkRangedImpl() { + val tree = mutable.SortedSet[Int](3, 1, 6, 7, 5, 2) + val projection = tree.rangeImpl(Some(3), Some(6)) + assert(projection == immutable.SortedSet(3, 5)) + assert(projection.size == 2) + + // Let's check that modification are taken into account + tree add 4 + assert(tree == immutable.SortedSet(1, 2, 3, 4, 5, 6, 7)) + assert(projection == immutable.SortedSet(3, 4, 5)) + assert(tree.size == 7) + assert(projection.size == 3) + } + +} diff --git a/test/files/scalacheck/si4147.scala b/test/files/scalacheck/si4147.scala new file mode 100644 index 0000000000..1453440ef1 --- /dev/null +++ b/test/files/scalacheck/si4147.scala @@ -0,0 +1,67 @@ +import org.scalacheck.Prop.forAll +import org.scalacheck.Properties +import org.scalacheck.ConsoleReporter.testStatsEx +import org.scalacheck.Gen +import org.scalacheck.ConsoleReporter + + +import collection.mutable + + +object Test extends Properties("Mutable TreeSet") { + + val generator = Gen.listOfN(1000, Gen.chooseNum(0, 1000)) + + val denseGenerator = Gen.listOfN(1000, Gen.chooseNum(0, 200)) + + property("Insertion doesn't allow duplicates values.") = forAll(generator) { (s: List[Int]) => + { + val t = mutable.TreeSet[Int](s: _*) + t == s.toSet + } + } + + property("Verification of size method validity") = forAll(generator) { (s: List[Int]) => + { + val t = mutable.TreeSet[Int](s: _*) + for (a <- s) { + t -= a + } + t.size == 0 + } + } + + property("All inserted elements are removed") = forAll(generator) { (s: List[Int]) => + { + val t = mutable.TreeSet[Int](s: _*) + for (a <- s) { + t -= a + } + t == Set() + } + } + + property("Elements are sorted.") = forAll(generator) { (s: List[Int]) => + { + val t = mutable.TreeSet[Int](s: _*) + t.toList == s.distinct.sorted + } + } + + property("Implicit CanBuildFrom resolution succeeds as well as the \"same-result-type\" principle.") = + forAll(generator) { (s: List[Int]) => + { + val t = mutable.TreeSet[Int](s: _*) + val t2 = t.map(_ * 2) + t2.isInstanceOf[collection.mutable.TreeSet[Int]] + } + } + + property("A view doesn't expose off bounds elements") = forAll(denseGenerator) { (s: List[Int]) => + { + val t = mutable.TreeSet[Int](s: _*) + val view = t.rangeImpl(Some(50), Some(150)) + view.filter(_ < 50) == Set[Int]() && view.filter(_ >= 150) == Set[Int]() + } + } +} -- cgit v1.2.3 From 25da86a228a3ae7aecaacdfd094812d53209aece Mon Sep 17 00:00:00 2001 From: Szabolcs Berecz Date: Thu, 12 Jan 2012 21:48:02 +0100 Subject: Cleanup after "Fixed equality and string representation of xml attributes with null value" This commit reverts the following two commits: 5f2568e36b87d183fd4e4442d5c304db628846c4 - "Revert "Accept prefixed xml attributes with null value" b00002f9049c034510438881b4a4449d73fe2f54 - "Disabling some scaladoc tests." and fixes a scaladoc test broken by: 4787f883604d1344257c0b40c15790c3dde477f2 - "Fixed equality and string representation of xml attributes with null value" --- src/library/scala/xml/PrefixedAttribute.scala | 15 +++++++----- test/files/run/xml-attribute.scala | 25 ++++++++++++++++--- test/scaladoc/scala/html/HtmlFactoryTest.scala | 34 +++++++++++++------------- 3 files changed, 48 insertions(+), 26 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/xml/PrefixedAttribute.scala b/src/library/scala/xml/PrefixedAttribute.scala index 436dfcda43..b80d6a1c73 100644 --- a/src/library/scala/xml/PrefixedAttribute.scala +++ b/src/library/scala/xml/PrefixedAttribute.scala @@ -13,22 +13,25 @@ package scala.xml * * @param pre ... * @param key ... - * @param value the attribute value, which may not be null + * @param value the attribute value * @param next ... */ class PrefixedAttribute( val pre: String, val key: String, val value: Seq[Node], - val next: MetaData) + val next1: MetaData) extends Attribute { - if (value eq null) - throw new UnsupportedOperationException("value is null") + val next = if (value ne null) next1 else next1.remove(key) - /** same as this(key, Utility.parseAttributeValue(value), next) */ + /** same as this(pre, key, Text(value), next), or no attribute if value is null */ def this(pre: String, key: String, value: String, next: MetaData) = - this(pre, key, Text(value), next) + this(pre, key, if (value ne null) Text(value) else null: NodeSeq, next) + + /** same as this(pre, key, value.get, next), or no attribute if value is None */ + def this(pre: String, key: String, value: Option[Seq[Node]], next: MetaData) = + this(pre, key, value.orNull, next) /** Returns a copy of this unprefixed attribute with the given * next field. diff --git a/test/files/run/xml-attribute.scala b/test/files/run/xml-attribute.scala index 2b83f70b22..8b261acc94 100644 --- a/test/files/run/xml-attribute.scala +++ b/test/files/run/xml-attribute.scala @@ -5,10 +5,29 @@ object Test { val noAttr = val attrNull = val attrNone = + val preAttrNull = + val preAttrNone = assert(noAttr == attrNull) assert(noAttr == attrNone) - assert(noAttr.toString() == "") - assert(attrNull.toString() == "") - assert(attrNone.toString() == "") + assert(noAttr == preAttrNull) + assert(noAttr == preAttrNone) + + val noAttrStr = "" + assert(noAttr.toString() == noAttrStr) + assert(attrNull.toString() == noAttrStr) + assert(attrNone.toString() == noAttrStr) + assert(preAttrNull.toString() == noAttrStr) + assert(preAttrNone.toString() == noAttrStr) + + val xml1 = + val xml2 = + val xml3 = + assert(xml1 == xml2) + assert(xml1 == xml3) + + val xml1Str = "" + assert(xml1.toString() == xml1Str) + assert(xml2.toString() == xml1Str) + assert(xml3.toString() == xml1Str) } } diff --git a/test/scaladoc/scala/html/HtmlFactoryTest.scala b/test/scaladoc/scala/html/HtmlFactoryTest.scala index 7fed4ca027..d03094d0ab 100644 --- a/test/scaladoc/scala/html/HtmlFactoryTest.scala +++ b/test/scaladoc/scala/html/HtmlFactoryTest.scala @@ -185,18 +185,18 @@ object Test extends Properties("HtmlFactory") { property("Trac #4180") = { createTemplate("Trac4180.scala") != None } - // - // property("Trac #4372") = { - // createTemplate("Trac4372.scala") match { - // case node: scala.xml.Node => { - // val html = node.toString - // html.contains("+:") && - // html.contains("-:") && - // html.contains("""(n: Int): Int""") - // } - // case _ => false - // } - // } + + property("Trac #4372") = { + createTemplate("Trac4372.scala") match { + case node: scala.xml.Node => { + val html = node.toString + html.contains("+:") && + html.contains("-:") && + html.contains("""(n: Int): Int""") + } + case _ => false + } + } property("Trac #4374 - public") = { val files = createTemplates("Trac4374.scala") @@ -426,11 +426,11 @@ object Test extends Properties("HtmlFactory") { createTemplate("SI_4898.scala") true } - // - // property("Use cases should override their original members") = - // checkText1("SI_5054_q1.scala", """def test(): Int""") && - // !checkText1("SI_5054_q1.scala", """def test(implicit lost: Int): Int""") - // + + property("Use cases should override their original members") = + checkText1("SI_5054_q1.scala", """def test(): Int""") && + !checkText1("SI_5054_q1.scala", """def test(implicit lost: Int): Int""") + property("Use cases should keep their flags - final should not be lost") = checkText1("SI_5054_q2.scala", """final def test(): Int""") -- cgit v1.2.3 From b0de5f13329aa24752fae079c50cc0584471379e Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 13 Jan 2012 00:16:04 -0800 Subject: Removed some unsociable exception behavior. --- src/library/scala/collection/mutable/TreeSet.scala | 7 ------- 1 file changed, 7 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/mutable/TreeSet.scala b/src/library/scala/collection/mutable/TreeSet.scala index 8039db7cc9..38fa0c953f 100644 --- a/src/library/scala/collection/mutable/TreeSet.scala +++ b/src/library/scala/collection/mutable/TreeSet.scala @@ -9,12 +9,8 @@ package scala.collection package mutable - - import generic._ - - /** * @define Coll mutable.TreeSet * @define coll mutable tree set @@ -87,7 +83,6 @@ class TreeSet[A](implicit val ordering: Ordering[A]) extends SortedSet[A] with S resolve.cardinality = resolve.cardinality - 1 } catch { case e: NoSuchElementException => () - case a: Any => a.printStackTrace } this } @@ -98,7 +93,6 @@ class TreeSet[A](implicit val ordering: Ordering[A]) extends SortedSet[A] with S resolve.cardinality = resolve.cardinality + 1 } catch { case e: IllegalArgumentException => () - case a: Any => a.printStackTrace } this } @@ -126,5 +120,4 @@ class TreeSet[A](implicit val ordering: Ordering[A]) extends SortedSet[A] with S AVLTree.iterator(resolve.avl, isLeftAcceptable(from, ordering), isRightAcceptable(until, ordering)) - } -- cgit v1.2.3 From 545680b2746cc0c7ae658f6c66e68e763b0b58c9 Mon Sep 17 00:00:00 2001 From: "Daniel C. Sobral" Date: Fri, 13 Jan 2012 14:57:32 -0200 Subject: Explain Function1 vs PartialFunction Add an explanation in PartialFunction as to how it differs from Function1, with examples of what it can do that Function1 cannot. Make it explicit that calling apply may throw exceptions in both of them, even in the case where isDefinedAt returns true. Closes SI-5370. --- src/library/scala/Function1.scala | 10 +++++++++- src/library/scala/PartialFunction.scala | 26 ++++++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) (limited to 'src/library') diff --git a/src/library/scala/Function1.scala b/src/library/scala/Function1.scala index dc8e67bbb0..7517e6604b 100644 --- a/src/library/scala/Function1.scala +++ b/src/library/scala/Function1.scala @@ -24,10 +24,18 @@ package scala * assert(succ(0) == anonfun1(0)) * } * }}} + * + * Note that `Function1` does not define a total function, as might + * be suggested by the existence of [[scala.PartialFunction]]. The only + * distinction between `Function1` and `PartialFunction` is that the + * latter can specify inputs which it will not handle. + * */ @annotation.implicitNotFound(msg = "No implicit view available from ${T1} => ${R}.") trait Function1[@specialized(scala.Int, scala.Long, scala.Float, scala.Double) -T1, @specialized(scala.Unit, scala.Boolean, scala.Int, scala.Float, scala.Long, scala.Double) +R] extends AnyRef { self => - /** Apply the body of this function to the argument. + /** Apply the body of this function to the argument. It may throw an + * exception. + * * @return the result of function application. */ def apply(v1: T1): R diff --git a/src/library/scala/PartialFunction.scala b/src/library/scala/PartialFunction.scala index b2910c2278..ae2c343e0b 100644 --- a/src/library/scala/PartialFunction.scala +++ b/src/library/scala/PartialFunction.scala @@ -13,6 +13,32 @@ package scala * The function `isDefinedAt` allows to test dynamically if a value is in * the domain of the function. * + * Even if `isDefinedAt` returns true for an `a: A`, calling `apply(a)` may + * still throw an exception, so the following code is legal: + * + * {{{ + * val f: PartialFunction[Int, Any] = { case _ => 1/0 } + * }}} + * + * The main distinction between `PartialFunction` and [[scala.Function1]] is that + * an alternative behavior can be applied to those elements that are declared + * to be outside its domain. For example: + * + * {{{ + * val sample = 1 to 10 + * val isEven: PartialFunction[Int, String] = { case x if x % 2 == 0 => x+" is even" } + * + * // the method collect can use isDefinedAt to select which members to collect + * val evenNumbers = sample collect isEven + * + * val isOdd: PartialFunction[Int, String] = { case x if x % 2 == 1 => x+" is odd" } + * + * // the method orElse allows chaining another partial function to handle input + * // outside the declared domain + * val numbers = sample map (isEven orElse isOdd) + * }}} + * + * * @author Martin Odersky * @version 1.0, 16/07/2003 */ -- cgit v1.2.3 From 14138901500c0333ca199738cf80d2effde14279 Mon Sep 17 00:00:00 2001 From: "Daniel C. Sobral" Date: Fri, 13 Jan 2012 15:58:24 -0200 Subject: Improve description of flatten, flatMap Add examples and better explain the expected return type of the methods flatMap and flatten. Closes SI-5371. --- .../scala/collection/GenTraversableLike.scala | 23 +++++++++++++++++++++- src/library/scala/collection/TraversableLike.scala | 3 +++ .../generic/GenericTraversableTemplate.scala | 14 ++++++++++++- 3 files changed, 38 insertions(+), 2 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/GenTraversableLike.scala b/src/library/scala/collection/GenTraversableLike.scala index 122eec2d90..c837775cf9 100644 --- a/src/library/scala/collection/GenTraversableLike.scala +++ b/src/library/scala/collection/GenTraversableLike.scala @@ -177,7 +177,28 @@ trait GenTraversableLike[+A, +Repr] extends GenTraversableOnce[A] with Paralleli def collect[B, That](pf: PartialFunction[A, B])(implicit bf: CanBuildFrom[Repr, B, That]): That /** Builds a new collection by applying a function to all elements of this $coll - * and concatenating the results. + * and using the elements of the resulting collections. For example: + * + * {{{ + * def getWords(lines: Seq[String]): Seq[String] = lines flatMap (line => line split "\\W+") + * }}} + * + * The type of the resulting collection is guided by the static type of $coll. This might + * cause unexpected results sometimes. For example: + * + * {{{ + * // lettersOf will return a Seq[Char] of likely repeated letters, instead of a Set + * def lettersOf(words: Seq[String]) = words flatMap (word => word.toSet) + * + * // lettersOf will return a Set[Char], not a Seq + * def lettersOf(words: Seq[String]) = words.toSet flatMap (word => word.toSeq) + * + * // xs will be a an Iterable[Int] + * val xs = Map("a" -> List(11,111), "b" -> List(22,222)).flatMap(_._2) + * + * // ys will be a Map[Int, Int] + * val ys = Map("a" -> List(1 -> 11,1 -> 111), "b" -> List(2 -> 22,2 -> 222)).flatMap(_._2) + * }}} * * @param f the function to apply to each element. * @tparam B the element type of the returned collection. diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala index e2acc0b3e0..b4813e6341 100644 --- a/src/library/scala/collection/TraversableLike.scala +++ b/src/library/scala/collection/TraversableLike.scala @@ -709,6 +709,9 @@ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr] * outer $coll containing this `WithFilter` instance that satisfy * predicate `p` and concatenating the results. * + * The type of the resulting collection will be guided by the static type + * of the outer $coll. + * * @param f the function to apply to each element. * @tparam B the element type of the returned collection. * @tparam That $thatinfo diff --git a/src/library/scala/collection/generic/GenericTraversableTemplate.scala b/src/library/scala/collection/generic/GenericTraversableTemplate.scala index 12c1a75c7a..7333074778 100644 --- a/src/library/scala/collection/generic/GenericTraversableTemplate.scala +++ b/src/library/scala/collection/generic/GenericTraversableTemplate.scala @@ -116,7 +116,19 @@ trait GenericTraversableTemplate[+A, +CC[X] <: GenTraversable[X]] extends HasNew } /** Converts this $coll of traversable collections into - * a $coll in which all element collections are concatenated. + * a $coll formed by the elements of these traversable + * collections. + * + * The resulting collection's type will be guided by the + * static type of $coll. For example: + * + * {{{ + * val xs = List(Set(1, 2, 3), Set(1, 2, 3)) + * // xs == List(1, 2, 3, 1, 2, 3) + * + * val ys = Set(List(1, 2, 3), List(3, 2, 1)) + * // ys == Set(1, 2, 3) + * }}} * * @tparam B the type of the elements of each traversable collection. * @param asTraversable an implicit conversion which asserts that the element -- cgit v1.2.3 From ec11e47567404c95dc1ee5dd4ddbcd9e7de69779 Mon Sep 17 00:00:00 2001 From: "Daniel C. Sobral" Date: Sat, 14 Jan 2012 13:17:26 -0200 Subject: Reword confusing explanation --- src/library/scala/PartialFunction.scala | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/PartialFunction.scala b/src/library/scala/PartialFunction.scala index ae2c343e0b..70caff0221 100644 --- a/src/library/scala/PartialFunction.scala +++ b/src/library/scala/PartialFunction.scala @@ -20,21 +20,25 @@ package scala * val f: PartialFunction[Int, Any] = { case _ => 1/0 } * }}} * - * The main distinction between `PartialFunction` and [[scala.Function1]] is that - * an alternative behavior can be applied to those elements that are declared - * to be outside its domain. For example: + * The main distinction between `PartialFunction` and [[scala.Function1]] is + * that the user of a `PartialFunction` may choose to do something different + * with input that is declared to be outside its domain. For example: * * {{{ * val sample = 1 to 10 - * val isEven: PartialFunction[Int, String] = { case x if x % 2 == 0 => x+" is even" } + * val isEven: PartialFunction[Int, String] = { + * case x if x % 2 == 0 => x+" is even" + * } * * // the method collect can use isDefinedAt to select which members to collect * val evenNumbers = sample collect isEven * - * val isOdd: PartialFunction[Int, String] = { case x if x % 2 == 1 => x+" is odd" } + * val isOdd: PartialFunction[Int, String] = { + * case x if x % 2 == 1 => x+" is odd" + * } * - * // the method orElse allows chaining another partial function to handle input - * // outside the declared domain + * // the method orElse allows chaining another partial function to handle + * // input outside the declared domain * val numbers = sample map (isEven orElse isOdd) * }}} * -- cgit v1.2.3 From 964fc6ee55dec031b5d697114db84a365425baf8 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sat, 14 Jan 2012 10:59:53 -0800 Subject: Toward the elimination of setInternalFlags. Modifications in LiftCode to avoid upsetting the happy world upon which I am converging where flags change in an almost predictable fashion. --- src/compiler/scala/reflect/internal/Symbols.scala | 6 ++-- .../scala/tools/nsc/transform/LiftCode.scala | 37 +++++++++++----------- src/library/scala/reflect/api/Symbols.scala | 4 +-- 3 files changed, 24 insertions(+), 23 deletions(-) (limited to 'src/library') diff --git a/src/compiler/scala/reflect/internal/Symbols.scala b/src/compiler/scala/reflect/internal/Symbols.scala index e34189657e..a73ab32960 100644 --- a/src/compiler/scala/reflect/internal/Symbols.scala +++ b/src/compiler/scala/reflect/internal/Symbols.scala @@ -49,9 +49,9 @@ trait Symbols extends api.Symbols { self: SymbolTable => val originalOwner = perRunCaches.newMap[Symbol, Symbol]() abstract class AbsSymbolImpl extends AbsSymbol { this: Symbol => - def newNestedSymbol(pos: Position, name: Name) = name match { - case n: TermName => newTermSymbol(n, pos) - case n: TypeName => newTypeSymbol(n, pos) + def newNestedSymbol(name: Name, pos: Position, flags: Long) = name match { + case n: TermName => newTermSymbol(n, pos, flags) + case n: TypeName => newTypeSymbol(n, pos, flags) } def typeSig: Type = info def typeSigIn(site: Type): Type = site.memberInfo(this) diff --git a/src/compiler/scala/tools/nsc/transform/LiftCode.scala b/src/compiler/scala/tools/nsc/transform/LiftCode.scala index bc7d1754d4..c5475fa0f2 100644 --- a/src/compiler/scala/tools/nsc/transform/LiftCode.scala +++ b/src/compiler/scala/tools/nsc/transform/LiftCode.scala @@ -71,6 +71,8 @@ abstract class LiftCode extends Transform with TypingTransformers { case mod => mod.toString } + // I fervently hope this is a test case or something, not anything being + // depended upon. Of more fragile code I cannot conceive. for (line <- (tree.toString.split(Properties.lineSeparator) drop 2 dropRight 1)) { var s = line.trim s = s.replace("$mr.", "") @@ -81,24 +83,23 @@ abstract class LiftCode extends Transform with TypingTransformers { s = s.replace("immutable.this.Nil", "List()") s = s.replace("modifiersFromInternalFlags", "Modifiers") s = s.replace("Modifiers(0L, newTypeName(\"\"), List())", "Modifiers()") - s = """Modifiers\((\d+)L, newTypeName\("(.*?)"\), List\((.*?)\)\)""".r.replaceAllIn(s, m => { - val buf = new StringBuffer() + s = """Modifiers\((\d+)[lL], newTypeName\("(.*?)"\), List\((.*?)\)\)""".r.replaceAllIn(s, m => { + val buf = new StringBuilder val flags = m.group(1).toLong - var s_flags = Flags.modifiersOfFlags(flags) map copypasteModifier - buf.append("Set(" + s_flags.mkString(", ") + ")") + val s_flags = Flags.modifiersOfFlags(flags) map copypasteModifier mkString ", " + if (s_flags != "") + buf.append("Set(" + s_flags + ")") - var privateWithin = m.group(2) - buf.append(", " + "newTypeName(\"" + privateWithin + "\")") + val privateWithin = "" + m.group(2) + if (privateWithin != "") + buf.append(", newTypeName(\"" + privateWithin + "\")") - var annotations = m.group(3) - buf.append(", " + "List(" + annotations + ")") + val annotations = m.group(3) + if (annotations.nonEmpty) + buf.append(", List(" + annotations + ")") - var s = buf.toString - if (s.endsWith(", List()")) s = s.substring(0, s.length - ", List()".length) - if (s.endsWith(", newTypeName(\"\")")) s = s.substring(0, s.length - ", newTypeName(\"\")".length) - if (s.endsWith("Set()")) s = s.substring(0, s.length - "Set()".length) - "Modifiers(" + s + ")" + "Modifiers(" + buf.toString + ")" }) s = """setInternalFlags\((\d+)L\)""".r.replaceAllIn(s, m => { val flags = m.group(1).toLong @@ -310,13 +311,13 @@ abstract class LiftCode extends Transform with TypingTransformers { */ private def reifySymbolDef(sym: Symbol): Tree = { if (reifyDebug) println("reify sym def " + sym) - var rsym: Tree = + + ValDef(NoMods, localName(sym), TypeTree(), Apply( Select(reify(sym.owner), "newNestedSymbol"), - List(reify(sym.pos), reify(sym.name))) - if (sym.flags != 0L) - rsym = Apply(Select(rsym, "setInternalFlags"), List(Literal(Constant(sym.flags)))) - ValDef(NoMods, localName(sym), TypeTree(), rsym) + List(reify(sym.name), reify(sym.pos), Literal(Constant(sym.flags))) + ) + ) } /** diff --git a/src/library/scala/reflect/api/Symbols.scala b/src/library/scala/reflect/api/Symbols.scala index 31bcdebe7e..8b4b170847 100755 --- a/src/library/scala/reflect/api/Symbols.scala +++ b/src/library/scala/reflect/api/Symbols.scala @@ -150,10 +150,10 @@ trait Symbols { self: Universe => */ def asTypeIn(site: Type): Type - /** A fresh symbol with given position `pos` and name `name` that has + /** A fresh symbol with given name `name`, position `pos` and flags `flags` that has * the current symbol as its owner. */ - def newNestedSymbol(pos: Position, name: Name): Symbol // needed by LiftCode + def newNestedSymbol(name: Name, pos: Position, flags: Long): Symbol // needed by LiftCode /** Low-level operation to set the symbol's flags * @return the symbol itself -- cgit v1.2.3 From cebc49b9f37ec8c8a3befcee6142f9c0590c41e2 Mon Sep 17 00:00:00 2001 From: Grzegorz Kossakowski Date: Sun, 15 Jan 2012 21:41:11 +0100 Subject: Make AnyValManifest not a sealed class. Scala+GWT has a whole new hierarchy of Manifests that does not use reflection. Every type in new hierarchy is a subtype of a type from old hierarchy. Sealed modifier introduced in 2e92de4cd66532404081eec6b9e82c6f85b51434 breaks this scheme. Removing it so Scala+GWT can compile again. --- src/library/scala/reflect/Manifest.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/library') diff --git a/src/library/scala/reflect/Manifest.scala b/src/library/scala/reflect/Manifest.scala index be08409636..8bd45c0e33 100644 --- a/src/library/scala/reflect/Manifest.scala +++ b/src/library/scala/reflect/Manifest.scala @@ -60,7 +60,7 @@ trait Manifest[T] extends ClassManifest[T] with Equals { override def hashCode = this.erasure.## } -sealed abstract class AnyValManifest[T <: AnyVal](override val toString: String) extends Manifest[T] with Equals { +abstract class AnyValManifest[T <: AnyVal](override val toString: String) extends Manifest[T] with Equals { override def <:<(that: ClassManifest[_]): Boolean = (that eq this) || (that eq Manifest.Any) || (that eq Manifest.AnyVal) override def canEqual(other: Any) = other match { -- cgit v1.2.3 From 6ea9f72ffd0e1b606cb5ad4670b4db8330fa29b9 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Mon, 16 Jan 2012 17:49:12 +0100 Subject: A string interpolation implementation of SIP-11. This is the complete implementation of SIP-11, in its version of 15-Jan-2012. For now, the interpolations are enabled only under the -Xexperimental flag. --- src/compiler/scala/reflect/internal/StdNames.scala | 2 +- .../scala/tools/nsc/ast/parser/Parsers.scala | 63 +++--- .../scala/tools/nsc/ast/parser/Scanners.scala | 245 +++++++++++++-------- .../scala/tools/nsc/ast/parser/Tokens.scala | 10 +- src/library/scala/StringContext.scala | 191 ++++++++++++++++ test/files/run/interpolation.check | 20 ++ test/files/run/interpolation.flags | 1 + test/files/run/interpolation.scala | 24 ++ test/files/run/stringInterpolation.check | 2 - test/files/run/stringInterpolation.flags | 1 - test/files/run/stringInterpolation.scala | 7 - 11 files changed, 428 insertions(+), 138 deletions(-) create mode 100644 src/library/scala/StringContext.scala create mode 100644 test/files/run/interpolation.check create mode 100644 test/files/run/interpolation.flags create mode 100644 test/files/run/interpolation.scala delete mode 100644 test/files/run/stringInterpolation.check delete mode 100644 test/files/run/stringInterpolation.flags delete mode 100644 test/files/run/stringInterpolation.scala (limited to 'src/library') diff --git a/src/compiler/scala/reflect/internal/StdNames.scala b/src/compiler/scala/reflect/internal/StdNames.scala index 2871ba59f6..507621ea42 100644 --- a/src/compiler/scala/reflect/internal/StdNames.scala +++ b/src/compiler/scala/reflect/internal/StdNames.scala @@ -271,6 +271,7 @@ trait StdNames extends NameManglers { self: SymbolTable => // Compiler utilized names // val productElementName: NameType = "productElementName" val Ident: NameType = "Ident" + val StringContext: NameType = "StringContext" val TYPE_ : NameType = "TYPE" val TypeTree: NameType = "TypeTree" val UNIT : NameType = "UNIT" @@ -320,7 +321,6 @@ trait StdNames extends NameManglers { self: SymbolTable => val find_ : NameType = "find" val flatMap: NameType = "flatMap" val foreach: NameType = "foreach" - val formatted: NameType = "formatted" val freeValue : NameType = "freeValue" val genericArrayOps: NameType = "genericArrayOps" val get: NameType = "get" diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index 580b2a16eb..ce41bc456e 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -617,7 +617,7 @@ self => def isLiteralToken(token: Int) = token match { case CHARLIT | INTLIT | LONGLIT | FLOATLIT | DOUBLELIT | - STRINGLIT | STRINGPART | SYMBOLLIT | TRUE | FALSE | NULL => true + STRINGLIT | INTERPOLATIONID | SYMBOLLIT | TRUE | FALSE | NULL => true case _ => false } def isLiteral = isLiteralToken(in.token) @@ -1103,7 +1103,7 @@ self => * }}} * @note The returned tree does not yet have a position */ - def literal(isNegated: Boolean): Tree = { + def literal(isNegated: Boolean = false): Tree = { def finish(value: Any): Tree = { val t = Literal(Constant(value)) in.nextToken() @@ -1111,19 +1111,19 @@ self => } if (in.token == SYMBOLLIT) Apply(scalaDot(nme.Symbol), List(finish(in.strVal))) - else if (in.token == STRINGPART) + else if (in.token == INTERPOLATIONID) interpolatedString() else finish(in.token match { - case CHARLIT => in.charVal - case INTLIT => in.intVal(isNegated).toInt - case LONGLIT => in.intVal(isNegated) - case FLOATLIT => in.floatVal(isNegated).toFloat - case DOUBLELIT => in.floatVal(isNegated) - case STRINGLIT => in.strVal.intern() - case TRUE => true - case FALSE => false - case NULL => null - case _ => + case CHARLIT => in.charVal + case INTLIT => in.intVal(isNegated).toInt + case LONGLIT => in.intVal(isNegated) + case FLOATLIT => in.floatVal(isNegated).toFloat + case DOUBLELIT => in.floatVal(isNegated) + case STRINGLIT | STRINGPART => in.strVal.intern() + case TRUE => true + case FALSE => false + case NULL => null + case _ => syntaxErrorOrIncomplete("illegal literal", true) null }) @@ -1138,16 +1138,27 @@ self => } } - private def interpolatedString(): Tree = { - var t = atPos(o2p(in.offset))(New(TypeTree(definitions.StringBuilderClass.tpe), List(List()))) + private def interpolatedString(): Tree = atPos(in.offset) { + val start = in.offset + val interpolator = in.name + + val partsBuf = new ListBuffer[Tree] + val exprBuf = new ListBuffer[Tree] + in.nextToken() while (in.token == STRINGPART) { - t = stringOp(t, nme.append) - var e = expr() - if (in.token == STRINGFMT) e = stringOp(e, nme.formatted) - t = atPos(t.pos.startOrPoint)(Apply(Select(t, nme.append), List(e))) + partsBuf += literal() + exprBuf += { + if (in.token == IDENTIFIER) atPos(in.offset)(Ident(ident())) + else expr() + } } - if (in.token == STRINGLIT) t = stringOp(t, nme.append) - atPos(t.pos)(Select(t, nme.toString_)) + if (in.token == STRINGLIT) partsBuf += literal() + + val t1 = atPos(o2p(start)) { Ident(nme.StringContext) } + val t2 = atPos(start) { Apply(t1, partsBuf.toList) } + t2 setPos t2.pos.makeTransparent + val t3 = Select(t2, interpolator) setPos t2.pos + atPos(start) { Apply(t3, exprBuf.toList) } } /* ------------- NEW LINES ------------------------------------------------- */ @@ -1469,7 +1480,7 @@ self => atPos(in.offset) { val name = nme.toUnaryName(rawIdent()) // val name = nme.toUnaryName(ident()) // val name: Name = "unary_" + ident() - if (name == nme.UNARY_- && isNumericLit) simpleExprRest(atPos(in.offset)(literal(true)), true) + if (name == nme.UNARY_- && isNumericLit) simpleExprRest(atPos(in.offset)(literal(isNegated = true)), true) else Select(stripParens(simpleExpr()), name) } } @@ -1493,7 +1504,7 @@ self => def simpleExpr(): Tree = { var canApply = true val t = - if (isLiteral) atPos(in.offset)(literal(false)) + if (isLiteral) atPos(in.offset)(literal()) else in.token match { case XMLSTART => xmlLiteral() @@ -1827,7 +1838,7 @@ self => case INTLIT | LONGLIT | FLOATLIT | DOUBLELIT => t match { case Ident(nme.MINUS) => - return atPos(start) { literal(true) } + return atPos(start) { literal(isNegated = true) } case _ => } case _ => @@ -1844,8 +1855,8 @@ self => in.nextToken() atPos(start, start) { Ident(nme.WILDCARD) } case CHARLIT | INTLIT | LONGLIT | FLOATLIT | DOUBLELIT | - STRINGLIT | STRINGPART | SYMBOLLIT | TRUE | FALSE | NULL => - atPos(start) { literal(false) } + STRINGLIT | INTERPOLATIONID | SYMBOLLIT | TRUE | FALSE | NULL => + atPos(start) { literal() } case LPAREN => atPos(start)(makeParens(noSeq.patterns())) case XMLSTART => diff --git a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala index a25b3afbc6..a2a577a7ab 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Scanners.scala @@ -161,12 +161,25 @@ trait Scanners extends ScannersCommon { * RBRACKET if region starts with '[' * RBRACE if region starts with '{' * ARROW if region starts with `case' - * STRINGFMT if region is a string interpolation expression starting with '\{' + * STRINGLIT if region is a string interpolation expression starting with '${' + * (the STRINGLIT appears twice in succession on the stack iff the + * expression is a multiline string literal). */ var sepRegions: List[Int] = List() // Get next token ------------------------------------------------------------ + /** Are we directly in a string interpolation expression? + */ + @inline private def inStringInterpolation = + sepRegions.nonEmpty && sepRegions.head == STRINGLIT + + /** Are we directly in a multiline string interpolation expression? + * @pre: inStringInterpolation + */ + @inline private def inMultiLineInterpolation = + sepRegions.tail.nonEmpty && sepRegions.tail.head == STRINGPART + /** read next token and return last offset */ def skipToken(): Offset = { @@ -189,29 +202,31 @@ trait Scanners extends ScannersCommon { sepRegions = RBRACE :: sepRegions case CASE => sepRegions = ARROW :: sepRegions - case STRINGPART => - sepRegions = STRINGFMT :: sepRegions case RBRACE => - sepRegions = sepRegions dropWhile (_ != RBRACE) + while (!sepRegions.isEmpty && sepRegions.head != RBRACE) + sepRegions = sepRegions.tail if (!sepRegions.isEmpty) sepRegions = sepRegions.tail - case RBRACKET | RPAREN | ARROW | STRINGFMT => + docBuffer = null + case RBRACKET | RPAREN => if (!sepRegions.isEmpty && sepRegions.head == lastToken) sepRegions = sepRegions.tail - case _ => - } - (lastToken: @switch) match { - case RBRACE | RBRACKET | RPAREN => docBuffer = null + case ARROW => + if (!sepRegions.isEmpty && sepRegions.head == lastToken) + sepRegions = sepRegions.tail + case STRINGLIT => + if (inStringInterpolation) + sepRegions = sepRegions.tail case _ => } - + // Read a token or copy it from `next` tokenData if (next.token == EMPTY) { lastOffset = charOffset - 1 - if(lastOffset > 0 && buf(lastOffset) == '\n' && buf(lastOffset - 1) == '\r') { + if (lastOffset > 0 && buf(lastOffset) == '\n' && buf(lastOffset - 1) == '\r') { lastOffset -= 1 } - fetchToken() + if (inStringInterpolation) fetchStringPart() else fetchToken() } else { this copyFrom next next.token = EMPTY @@ -308,7 +323,9 @@ trait Scanners extends ScannersCommon { 'z' => putChar(ch) nextChar() - getIdentRest() // scala-mode: wrong indent for multi-line case blocks + getIdentRest() + if (ch == '"' && token == IDENTIFIER && settings.Xexperimental.value) + token = INTERPOLATIONID case '<' => // is XMLSTART? val last = if (charOffset >= 2) buf(charOffset - 2) else ' ' nextChar() @@ -360,18 +377,37 @@ trait Scanners extends ScannersCommon { case '`' => getBackquotedIdent() case '\"' => - nextChar() - if (ch == '\"') { - nextChar() + if (token == INTERPOLATIONID) { + nextRawChar() if (ch == '\"') { nextRawChar() - getMultiLineStringLit() + if (ch == '\"') { + nextRawChar() + getStringPart(multiLine = true) + sepRegions = STRINGLIT :: sepRegions // indicate string part + sepRegions = STRINGLIT :: sepRegions // once more to indicate multi line string part + } else { + token = STRINGLIT + strVal = "" + } } else { - token = STRINGLIT - strVal = "" + getStringPart(multiLine = false) + sepRegions = STRINGLIT :: sepRegions // indicate single line string part } } else { - getStringPart() + nextChar() + if (ch == '\"') { + nextChar() + if (ch == '\"') { + nextRawChar() + getRawStringLit() + } else { + token = STRINGLIT + strVal = "" + } + } else { + getStringLit() + } } case '\'' => nextChar() @@ -397,9 +433,7 @@ trait Scanners extends ScannersCommon { token = DOT } case ';' => - nextChar() - if (inStringInterpolation) getFormatString() - else token = SEMI + nextChar(); token = SEMI case ',' => nextChar(); token = COMMA case '(' => @@ -409,16 +443,7 @@ trait Scanners extends ScannersCommon { case ')' => nextChar(); token = RPAREN case '}' => - if (token == STRINGFMT) { - nextChar() - getStringPart() - } else if (inStringInterpolation) { - strVal = ""; - token = STRINGFMT - } else { - nextChar(); - token = RBRACE - } + nextChar(); token = RBRACE case '[' => nextChar(); token = LBRACKET case ']' => @@ -506,11 +531,6 @@ trait Scanners extends ScannersCommon { } } - /** Are we directly in a string interpolation expression? - */ - private def inStringInterpolation = - sepRegions.nonEmpty && sepRegions.head == STRINGFMT - /** Can token start a statement? */ def inFirstOfStat(token: Int) = token match { case EOF | CATCH | ELSE | EXTENDS | FINALLY | FORSOME | MATCH | WITH | YIELD | @@ -608,71 +628,110 @@ trait Scanners extends ScannersCommon { else finishNamed() } } + + +// Literals ----------------------------------------------------------------- - def getFormatString() = { - getLitChars('}', '"', ' ', '\t') - if (ch == '}') { - setStrVal() - if (strVal.length > 0) strVal = "%" + strVal - token = STRINGFMT - } else { - syntaxError("unclosed format string") - } - } - - def getStringPart() = { - while (ch != '"' && (ch != CR && ch != LF && ch != SU || isUnicodeEscape) && maybeGetLitChar()) {} + private def getStringLit() = { + getLitChars('"') if (ch == '"') { setStrVal() nextChar() token = STRINGLIT - } else if (ch == '{' && settings.Xexperimental.value) { - setStrVal() - nextChar() - token = STRINGPART - } else { - syntaxError("unclosed string literal") - } + } else syntaxError("unclosed string literal") } - private def getMultiLineStringLit() { + private def getRawStringLit(): Unit = { if (ch == '\"') { nextRawChar() - if (ch == '\"') { + if (isTripleQuote()) { + setStrVal() + token = STRINGLIT + } else + getRawStringLit() + } else if (ch == SU) { + incompleteInputError("unclosed multi-line string literal") + } else { + putChar(ch) + nextRawChar() + getRawStringLit() + } + } + + @annotation.tailrec private def getStringPart(multiLine: Boolean): Unit = { + def finishStringPart() = { + setStrVal() + token = STRINGPART + next.lastOffset = charOffset - 1 + next.offset = charOffset - 1 + } + if (ch == '"') { + nextRawChar() + if (!multiLine || isTripleQuote()) { + setStrVal() + token = STRINGLIT + } else + getStringPart(multiLine) + } else if (ch == '$') { + nextRawChar() + if (ch == '$') { + putChar(ch) nextRawChar() - if (ch == '\"') { - nextChar() - while (ch == '\"') { - putChar('\"') - nextChar() - } - token = STRINGLIT - setStrVal() - } else { - putChar('\"') - putChar('\"') - getMultiLineStringLit() - } + getStringPart(multiLine) + } else if (ch == '{') { + finishStringPart() + nextRawChar() + next.token = LBRACE + } else if (Character.isUnicodeIdentifierStart(ch)) { + finishStringPart() + do { + putChar(ch) + nextRawChar() + } while (Character.isUnicodeIdentifierPart(ch)) + next.token = IDENTIFIER + next.name = newTermName(cbuf.toString) + cbuf.clear() } else { - putChar('\"') - getMultiLineStringLit() + syntaxError("invalid string interpolation") } - } else if (ch == SU) { - incompleteInputError("unclosed multi-line string literal") + } else if ((ch == CR || ch == LF || ch == SU) && !isUnicodeEscape) { + syntaxError("unclosed string literal") } else { putChar(ch) nextRawChar() - getMultiLineStringLit() + getStringPart(multiLine) } } + + private def fetchStringPart() = { + offset = charOffset - 1 + getStringPart(multiLine = inMultiLineInterpolation) + } + + private def isTripleQuote(): Boolean = + if (ch == '"') { + nextRawChar() + if (ch == '"') { + nextChar() + while (ch == '"') { + putChar('"') + nextChar() + } + true + } else { + putChar('"') + putChar('"') + false + } + } else { + putChar('"') + false + } -// Literals ----------------------------------------------------------------- - - /** read next character in character or string literal: - * if character sequence is a \{ escape, do not copy it into the string and return false. - * otherwise return true. + /** copy current character into cbuf, interpreting any escape sequences, + * and advance to next character. */ - protected def maybeGetLitChar(): Boolean = { + protected def getLitChar(): Unit = if (ch == '\\') { nextChar() if ('0' <= ch && ch <= '7') { @@ -698,7 +757,6 @@ trait Scanners extends ScannersCommon { case '\"' => putChar('\"') case '\'' => putChar('\'') case '\\' => putChar('\\') - case '{' => return false case _ => invalidEscape() } nextChar() @@ -707,22 +765,16 @@ trait Scanners extends ScannersCommon { putChar(ch) nextChar() } - true - } protected def invalidEscape(): Unit = { syntaxError(charOffset - 1, "invalid escape character") putChar(ch) } - protected def getLitChar(): Unit = - if (!maybeGetLitChar()) invalidEscape() - - private def getLitChars(delimiters: Char*) { - while (!(delimiters contains ch) && (ch != CR && ch != LF && ch != SU || isUnicodeEscape)) { + private def getLitChars(delimiter: Char) = + while (ch != delimiter && (ch != CR && ch != LF && ch != SU || isUnicodeEscape)) { getLitChar() } - } /** read fractional part and exponent of floating point number * if one is present. @@ -971,8 +1023,8 @@ trait Scanners extends ScannersCommon { "string(" + strVal + ")" case STRINGPART => "stringpart(" + strVal + ")" - case STRINGFMT => - "stringfmt(" + strVal + ")" + case INTERPOLATIONID => + "interpolationid(" + name + ")" case SEMI => ";" case NEWLINE => @@ -1088,8 +1140,7 @@ trait Scanners extends ScannersCommon { case LONGLIT => "long literal" case FLOATLIT => "float literal" case DOUBLELIT => "double literal" - case STRINGLIT | STRINGPART => "string literal" - case STRINGFMT => "format string" + case STRINGLIT | STRINGPART | INTERPOLATIONID => "string literal" case SYMBOLLIT => "symbol literal" case LPAREN => "'('" case RPAREN => "')'" diff --git a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala index 07970bb36e..091f333c27 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Tokens.scala @@ -45,18 +45,20 @@ abstract class Tokens { } object Tokens extends Tokens { - final val STRINGPART = 7 + final val STRINGPART = 7 // a part of an interpolated string final val SYMBOLLIT = 8 - final val STRINGFMT = 9 + final val INTERPOLATIONID = 9 // the lead identifier of an interpolated string + def isLiteral(code: Int) = - code >= CHARLIT && code <= SYMBOLLIT + code >= CHARLIT && code <= INTERPOLATIONID + /** identifiers */ final val IDENTIFIER = 10 final val BACKQUOTED_IDENT = 11 def isIdentifier(code: Int) = code >= IDENTIFIER && code <= BACKQUOTED_IDENT - + @switch def canBeginExpression(code: Int) = code match { case IDENTIFIER|BACKQUOTED_IDENT|USCORE => true case LBRACE|LPAREN|LBRACKET|COMMENT => true diff --git a/src/library/scala/StringContext.scala b/src/library/scala/StringContext.scala new file mode 100644 index 0000000000..1f0b4c766e --- /dev/null +++ b/src/library/scala/StringContext.scala @@ -0,0 +1,191 @@ +/* __ *\ +** ________ ___ / / ___ Scala API ** +** / __/ __// _ | / / / _ | (c) 2002-2012, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +package scala + +import collection.mutable.ArrayBuffer + +/** A class to support string interpolation. + * This class supports string interpolation as outlined in Scala SIP-11. + * It needs to be fully documented once the SIP is accepted. + * + * @param parts The parts that make up the interpolated string, + * without the expressions that get inserted by interpolation. + */ +case class StringContext(parts: String*) { + + import StringContext._ + + /** Checks that the given arguments `args` number one less than the number + * of `parts` supplied to the enclosing `StringContext`. + * @param `args` The arguments to be checked. + * @throws An `IllegalArgumentException` if this is not the case. + */ + def checkLengths(args: Any*): Unit = + if (parts.length != args.length + 1) + throw new IllegalArgumentException("wrong number of arguments for interpolated string") + + + /** The simple string interpolator. + * + * It inserts its arguments between corresponding parts of the string context. + * It also treats standard escape sequences as defined in the Scala specification. + * @param `args` The arguments to be inserted into the resulting string. + * @throws An `IllegalArgumentException` + * if the number of `parts` in the enclosing `StringContext` does not exceed + * the number of arguments `arg` by exactly 1. + * @throws A `StringContext.InvalidEscapeException` if if a `parts` string contains a backslash (`\`) character + * that does not start a valid escape sequence. + */ + def s(args: Any*) = { + checkLengths(args) + val pi = parts.iterator + val ai = args.iterator + val bldr = new java.lang.StringBuilder(treatEscapes(pi.next)) + while (ai.hasNext) { + bldr append ai.next + bldr append treatEscapes(pi.next) + } + bldr.toString + } + + /** The formatted string interpolator. + * + * It inserts its arguments between corresponding parts of the string context. + * It also treats standard escape sequences as defined in the Scala specification. + * Finally, if an interpolated expression is followed by a `parts` string + * that starts with a formatting specifier, the expression is formatted according to that + * specifier. All specifiers allowed in Java format strings are handled, and in the same + * way they are treated in Java. + * + * @param `args` The arguments to be inserted into the resulting string. + * @throws An `IllegalArgumentException` + * if the number of `parts` in the enclosing `StringContext` does not exceed + * the number of arguments `arg` by exactly 1. + * @throws A `StringContext.InvalidEscapeException` if a `parts` string contains a backslash (`\`) character + * that does not start a valid escape sequence. + * + * Note: The `f` method works by assembling a format string from all the `parts` strings and using + * `java.lang.String.format` to format all arguments with that format string. The format string is + * obtained by concatenating all `parts` strings, and performing two transformations: + * + * 1. Let a _formatting position_ be a start of any `parts` string except the first one. + * If a formatting position does not refer to a `%` character (which is assumed to + * start a format specifier), then the string format specifier `%s` is inserted. + * + * 2. Any `%` characters not in formatting positions are left in the resulting + * string literally. This is achieved by replacing each such occurrence by a string + * format specifier `%s` and adding a corresponding argument string `"%"`. + */ + def f(args: Any*) = { + checkLengths(args) + val pi = parts.iterator + val ai = args.iterator + val bldr = new java.lang.StringBuilder + val args1 = new ArrayBuffer[Any] + def copyString(first: Boolean): Unit = { + val str = treatEscapes(pi.next) + var start = 0 + var idx = 0 + if (!first) { + if ((str charAt 0) != '%') + bldr append "%s" + idx = 1 + } + val len = str.length + while (idx < len) { + if (str(idx) == '%') { + bldr append (str substring (start, idx)) append "%s" + args1 += "%" + start = idx + 1 + } + idx += 1 + } + bldr append (str substring (start, idx)) + } + copyString(first = true) + while (pi.hasNext) { + args1 += ai.next + copyString(first = false) + } + bldr.toString format (args1: _*) + } +} + +object StringContext { + + /** An exception that is thrown if a string contains a backslash (`\`) character that + * that does not start a valid escape sequence. + * @param str The offending string + * @param idx The index of the offending backslash character in `str`. + */ + class InvalidEscapeException(str: String, idx: Int) + extends IllegalArgumentException("invalid escape character at index "+idx+" in \""+str+"\"") + + /** Expands standard Scala escape sequences in a string. + * Escape sequences are: + * control: `\b`, `\t`, `\n`, `\f`, `\r` + * escape: `\\`, `\"`, `\'` + * octal: `\d` `\dd` `\ddd` where `d` is an octal digit between `0` and `7`. + * + * @param A string that may contain escape sequences + * @return The string with all escape sequences expanded. + */ + def treatEscapes(str: String): String = { + lazy val bldr = new java.lang.StringBuilder + val len = str.length + var start = 0 + var cur = 0 + var idx = 0 + def output(ch: Char) = { + bldr append str substring (start, cur) + bldr append ch + start = idx + } + while (idx < len) { + cur = idx + if (str(idx) == '\\') { + idx += 1 + if ('0' <= str(idx) && str(idx) <= '7') { + val leadch = str(idx) + var oct = leadch - '0' + idx += 1 + if ('0' <= str(idx) && str(idx) <= '7') { + oct = oct * 8 + str(idx) - '0' + idx += 1 + if (leadch <= '3' && '0' <= str(idx) && str(idx) <= '7') { + oct = oct * 8 + str(idx) - '0' + idx += 1 + } + } + output(oct.toChar) + } else { + val ch = str(idx) + idx += 1 + output { + ch match { + case 'b' => '\b' + case 't' => '\t' + case 'n' => '\n' + case 'f' => '\f' + case 'r' => '\r' + case '\"' => '\"' + case '\'' => '\'' + case '\\' => '\\' + case _ => throw new InvalidEscapeException(str, cur) + } + } + } + } else { + idx += 1 + } + } + if (start == 0) str + else (bldr append str.substring(start, idx)).toString + } +} diff --git a/test/files/run/interpolation.check b/test/files/run/interpolation.check new file mode 100644 index 0000000000..4c34e4c8c8 --- /dev/null +++ b/test/files/run/interpolation.check @@ -0,0 +1,20 @@ +Bob is 1 years old +Bob is 1 years old +Bob will be 2 years old +Bob will be 2 years old +Bob is 12 years old +Bob is 12 years old +Bob will be 13 years old +Bob will be 13 years old +Bob is 123 years old +Bob is 123 years old +Bob will be 124 years old +Bob will be 124 years old +Best price: 10.0 +Best price: 10.00 +10.0% discount included +10.00% discount included +Best price: 13.345 +Best price: 13.35 +13.345% discount included +13.35% discount included diff --git a/test/files/run/interpolation.flags b/test/files/run/interpolation.flags new file mode 100644 index 0000000000..48fd867160 --- /dev/null +++ b/test/files/run/interpolation.flags @@ -0,0 +1 @@ +-Xexperimental diff --git a/test/files/run/interpolation.scala b/test/files/run/interpolation.scala new file mode 100644 index 0000000000..232a180bcd --- /dev/null +++ b/test/files/run/interpolation.scala @@ -0,0 +1,24 @@ +object Test extends App { + + def test1(n: Int) = { + println(s"Bob is $n years old") + println(f"Bob is $n%2d years old") + println(s"Bob will be ${n+1} years old") + println(f"Bob will be ${n+1}%2d years old") + } + + def test2(f: Float) = { + println(s"Best price: $f") + println(f"Best price: $f%.2f") + println(s"$f% discount included") + println(f"$f%3.2f% discount included") + } + + test1(1) + test1(12) + test1(123) + + test2(10.0f) + test2(13.345f) + +} diff --git a/test/files/run/stringInterpolation.check b/test/files/run/stringInterpolation.check deleted file mode 100644 index b5b63343a8..0000000000 --- a/test/files/run/stringInterpolation.check +++ /dev/null @@ -1,2 +0,0 @@ -1 plus 1 is 2 -We have a 1.10% chance of success diff --git a/test/files/run/stringInterpolation.flags b/test/files/run/stringInterpolation.flags deleted file mode 100644 index 48fd867160..0000000000 --- a/test/files/run/stringInterpolation.flags +++ /dev/null @@ -1 +0,0 @@ --Xexperimental diff --git a/test/files/run/stringInterpolation.scala b/test/files/run/stringInterpolation.scala deleted file mode 100644 index d88f5f6889..0000000000 --- a/test/files/run/stringInterpolation.scala +++ /dev/null @@ -1,7 +0,0 @@ -object Test { - def main(args : Array[String]) : Unit = { - println("\{1} plus \{1} is \{1 + 1}") - val x = 1.1 - println("We have a \{ x ;2.2f}% chance of success") - } -} -- cgit v1.2.3 From 76caa37f22b70b126563df8a5eeab1b8bf693fc9 Mon Sep 17 00:00:00 2001 From: "Daniel C. Sobral" Date: Tue, 17 Jan 2012 17:26:59 -0200 Subject: Fix check for number of arguments Fix the test for number of arguments by passing all arguments instead of passing the argument list as a single argument. Add positive and negative tests for it. --- src/library/scala/StringContext.scala | 4 ++-- test/files/run/interpolation.check | 6 ++++++ test/files/run/interpolation.scala | 2 ++ test/files/run/interpolationArgs.check | 2 ++ test/files/run/interpolationArgs.flags | 1 + test/files/run/interpolationArgs.scala | 5 +++++ 6 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 test/files/run/interpolationArgs.check create mode 100644 test/files/run/interpolationArgs.flags create mode 100644 test/files/run/interpolationArgs.scala (limited to 'src/library') diff --git a/src/library/scala/StringContext.scala b/src/library/scala/StringContext.scala index 1f0b4c766e..6116547aa2 100644 --- a/src/library/scala/StringContext.scala +++ b/src/library/scala/StringContext.scala @@ -43,7 +43,7 @@ case class StringContext(parts: String*) { * that does not start a valid escape sequence. */ def s(args: Any*) = { - checkLengths(args) + checkLengths(args: _*) val pi = parts.iterator val ai = args.iterator val bldr = new java.lang.StringBuilder(treatEscapes(pi.next)) @@ -83,7 +83,7 @@ case class StringContext(parts: String*) { * format specifier `%s` and adding a corresponding argument string `"%"`. */ def f(args: Any*) = { - checkLengths(args) + checkLengths(args: _*) val pi = parts.iterator val ai = args.iterator val bldr = new java.lang.StringBuilder diff --git a/test/files/run/interpolation.check b/test/files/run/interpolation.check index 4c34e4c8c8..09579a800a 100644 --- a/test/files/run/interpolation.check +++ b/test/files/run/interpolation.check @@ -2,14 +2,20 @@ Bob is 1 years old Bob is 1 years old Bob will be 2 years old Bob will be 2 years old +1+1 = 2 +1+1 = 2 Bob is 12 years old Bob is 12 years old Bob will be 13 years old Bob will be 13 years old +12+1 = 13 +12+1 = 13 Bob is 123 years old Bob is 123 years old Bob will be 124 years old Bob will be 124 years old +123+1 = 124 +123+1 = 124 Best price: 10.0 Best price: 10.00 10.0% discount included diff --git a/test/files/run/interpolation.scala b/test/files/run/interpolation.scala index 232a180bcd..a0a185eaab 100644 --- a/test/files/run/interpolation.scala +++ b/test/files/run/interpolation.scala @@ -5,6 +5,8 @@ object Test extends App { println(f"Bob is $n%2d years old") println(s"Bob will be ${n+1} years old") println(f"Bob will be ${n+1}%2d years old") + println(s"$n+1 = ${n+1}") + println(f"$n%d+1 = ${n+1}%d") } def test2(f: Float) = { diff --git a/test/files/run/interpolationArgs.check b/test/files/run/interpolationArgs.check new file mode 100644 index 0000000000..155991e618 --- /dev/null +++ b/test/files/run/interpolationArgs.check @@ -0,0 +1,2 @@ +java.lang.IllegalArgumentException: wrong number of arguments for interpolated string +java.lang.IllegalArgumentException: wrong number of arguments for interpolated string diff --git a/test/files/run/interpolationArgs.flags b/test/files/run/interpolationArgs.flags new file mode 100644 index 0000000000..e1b37447c9 --- /dev/null +++ b/test/files/run/interpolationArgs.flags @@ -0,0 +1 @@ +-Xexperimental \ No newline at end of file diff --git a/test/files/run/interpolationArgs.scala b/test/files/run/interpolationArgs.scala new file mode 100644 index 0000000000..eb13767907 --- /dev/null +++ b/test/files/run/interpolationArgs.scala @@ -0,0 +1,5 @@ +object Test extends App { + try { scala.StringContext("p1", "p2", "p3").s("e1") } catch { case ex => println(ex) } + try { scala.StringContext("p1").s("e1") } catch { case ex => println(ex) } +} + -- cgit v1.2.3 From 7be585a0a29ba70845c2a5ed2f52d50db06a8189 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sat, 24 Dec 2011 16:57:43 +0100 Subject: Upgraded the implementation of showRaw Now showRaw no longer significantly lags behind -Yreify-copypaste. Didn't put very much effort into it, since quite soon LiftCode will become a macro and we'll be able to reuse it in RawTreePrinter. --- src/library/scala/reflect/api/TreePrinters.scala | 41 +++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'src/library') diff --git a/src/library/scala/reflect/api/TreePrinters.scala b/src/library/scala/reflect/api/TreePrinters.scala index 15fba0e418..88ef450ed9 100644 --- a/src/library/scala/reflect/api/TreePrinters.scala +++ b/src/library/scala/reflect/api/TreePrinters.scala @@ -28,7 +28,21 @@ trait TreePrinters { self: Universe => */ def newTreePrinter(out: PrintWriter): TreePrinter + // emits more or less verbatim representation of the provided tree + // todo. when LiftCode becomes a macro, throw this code away and use that macro class RawTreePrinter(out: PrintWriter) extends TreePrinter { + import scala.reflect.api.Modifier + import scala.reflect.api.Modifier._ + + def copypasteModifier(mod: Modifier.Value): String = mod match { + case mod @ ( + `protected` | `private` | `override` | + `abstract` | `final` | `sealed` | + `implicit` | `lazy` | `macro` | + `case` | `trait`) => "`" + mod.toString + "`" + case mod => mod.toString + } + def print(args: Any*): Unit = args foreach { case EmptyTree => print("EmptyTree") @@ -48,10 +62,35 @@ trait TreePrinters { self: Universe => case arg => print(arg) } - print(if (it.hasNext) ", " else ")") + print(if (it.hasNext) ", " else "") } + print(")") if (typesPrinted) print(".setType(", tree.tpe, ")") + case list: List[_] => + print("List(") + val it = list.iterator + while (it.hasNext) { + print(it.next()) + print(if (it.hasNext) ", " else "") + } + print(")") + case mods: Modifiers => + val parts = collection.mutable.ListBuffer[String]() + parts += "Set(" + mods.allModifiers.map{copypasteModifier}.mkString(", ") + ")" + parts += "newTypeName(\"" + mods.privateWithin.toString + "\")" + parts += "List(" + mods.annotations.map{showRaw}.mkString(", ") + ")" + + var keep = 3 + if (keep == 3 && mods.annotations.isEmpty) keep -= 1 + if (keep == 2 && mods.privateWithin == EmptyTypeName) keep -= 1 + if (keep == 1 && mods.allModifiers.isEmpty) keep -= 1 + + print("Modifiers(", parts.take(keep).mkString(", "), ")") + case name: Name => + if (name.isTermName) print("newTermName(\"") else print("newTypeName(\"") + print(name.toString) + print("\")") case arg => out.print(arg) } -- cgit v1.2.3 From 26afbf85bf17e3839f03cb9e2d981cdccdd2ee69 Mon Sep 17 00:00:00 2001 From: Kota Mizushima Date: Mon, 16 Jan 2012 23:20:07 +0900 Subject: Fixed a bug SI-5377 (https://issues.scala-lang.org/browse/SI-5377). Added test cases for SI-5377. --- src/library/scala/collection/SeqLike.scala | 2 +- test/files/run/t5377.check | 18 ++++++++++++ test/files/run/t5377.scala | 47 ++++++++++++++++++++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 test/files/run/t5377.check create mode 100644 test/files/run/t5377.scala (limited to 'src/library') diff --git a/src/library/scala/collection/SeqLike.scala b/src/library/scala/collection/SeqLike.scala index b6b4bfb96d..6d84b4276b 100644 --- a/src/library/scala/collection/SeqLike.scala +++ b/src/library/scala/collection/SeqLike.scala @@ -152,7 +152,7 @@ trait SeqLike[+A, +Repr] extends IterableLike[A, Repr] with GenSeqLike[A, Repr] if (!hasNext) Iterator.empty.next - val result = (self.newBuilder ++= elms).result + val result = (self.newBuilder ++= elms.toList).result var i = idxs.length - 2 while(i >= 0 && idxs(i) >= idxs(i+1)) i -= 1 diff --git a/test/files/run/t5377.check b/test/files/run/t5377.check new file mode 100644 index 0000000000..7bd0e297bf --- /dev/null +++ b/test/files/run/t5377.check @@ -0,0 +1,18 @@ +1 List(1) +1 List(1) +2 List(1, 2) List(2, 1) +2 List(1, 2) List(2, 1) +2 List(2, 1) List(1, 2) +2 List(2, 1) List(1, 2) +3 List(1, 2, 3) List(1, 3, 2) List(2, 1, 3) List(2, 3, 1) List(3, 1, 2) List(3, 2, 1) +3 List(1, 2, 3) List(1, 3, 2) List(2, 1, 3) List(2, 3, 1) List(3, 1, 2) List(3, 2, 1) +3 List(1, 3, 2) List(1, 2, 3) List(3, 1, 2) List(3, 2, 1) List(2, 1, 3) List(2, 3, 1) +3 List(1, 3, 2) List(1, 2, 3) List(3, 1, 2) List(3, 2, 1) List(2, 1, 3) List(2, 3, 1) +3 List(2, 1, 3) List(2, 3, 1) List(1, 2, 3) List(1, 3, 2) List(3, 2, 1) List(3, 1, 2) +3 List(2, 1, 3) List(2, 3, 1) List(1, 2, 3) List(1, 3, 2) List(3, 2, 1) List(3, 1, 2) +3 List(2, 3, 1) List(2, 1, 3) List(3, 2, 1) List(3, 1, 2) List(1, 2, 3) List(1, 3, 2) +3 List(2, 3, 1) List(2, 1, 3) List(3, 2, 1) List(3, 1, 2) List(1, 2, 3) List(1, 3, 2) +3 List(3, 1, 2) List(3, 2, 1) List(1, 3, 2) List(1, 2, 3) List(2, 3, 1) List(2, 1, 3) +3 List(3, 1, 2) List(3, 2, 1) List(1, 3, 2) List(1, 2, 3) List(2, 3, 1) List(2, 1, 3) +3 List(3, 2, 1) List(3, 1, 2) List(2, 3, 1) List(2, 1, 3) List(1, 3, 2) List(1, 2, 3) +3 List(3, 2, 1) List(3, 1, 2) List(2, 3, 1) List(2, 1, 3) List(1, 3, 2) List(1, 2, 3) diff --git a/test/files/run/t5377.scala b/test/files/run/t5377.scala new file mode 100644 index 0000000000..2e8fb1a6af --- /dev/null +++ b/test/files/run/t5377.scala @@ -0,0 +1,47 @@ +object Test { + def testPermutations1(num: Int, stream: Stream[Int]): Unit = { + val perm = stream.permutations + print(num) + while(perm.hasNext) { + print(" " + perm.next().toList) + } + println() + } + def testPermutations2(num: Int, stream: List[Int]): Unit = { + val perm = stream.permutations + print(num) + while(perm.hasNext) { + print(" " + perm.next().toList) + } + println() + } + + def main(args: Array[String]): Unit = { + testPermutations1(1, Stream(1)) + testPermutations2(1, List(1)) + + testPermutations1(2, Stream(1, 2)) + testPermutations2(2, List(1, 2)) + + testPermutations1(2, Stream(2, 1)) + testPermutations2(2, List(2, 1)) + + testPermutations1(3, Stream(1, 2, 3)) + testPermutations2(3, List(1, 2, 3)) + + testPermutations1(3, Stream(1, 3, 2)) + testPermutations2(3, List(1, 3, 2)) + + testPermutations1(3, Stream(2, 1, 3)) + testPermutations2(3, List(2, 1, 3)) + + testPermutations1(3, Stream(2, 3, 1)) + testPermutations2(3, List(2, 3, 1)) + + testPermutations1(3, Stream(3, 1, 2)) + testPermutations2(3, List(3, 1, 2)) + + testPermutations1(3, Stream(3, 2, 1)) + testPermutations2(3, List(3, 2, 1)) + } +} -- cgit v1.2.3 From 5d782f24fcb339dfeb9250c329e99ad11983f89d Mon Sep 17 00:00:00 2001 From: Szabolcs Berecz Date: Fri, 20 Jan 2012 00:16:14 +0100 Subject: Closes SI-5066 readLine("%s", "prompt") printed "WrappedArray(prompt)" readLine("%s%s", "pro", "mpt") threw a MissingFormatArgumentException --- src/library/scala/Predef.scala | 2 +- test/files/run/Predef.readLine.check | 3 +++ test/files/run/Predef.readLine.scala | 10 ++++++++++ 3 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/files/run/Predef.readLine.check create mode 100644 test/files/run/Predef.readLine.scala (limited to 'src/library') diff --git a/src/library/scala/Predef.scala b/src/library/scala/Predef.scala index b175fb9e1d..824e048e73 100644 --- a/src/library/scala/Predef.scala +++ b/src/library/scala/Predef.scala @@ -269,7 +269,7 @@ object Predef extends LowPriorityImplicits { def printf(text: String, xs: Any*) = Console.print(text.format(xs: _*)) def readLine(): String = Console.readLine() - def readLine(text: String, args: Any*) = Console.readLine(text, args) + def readLine(text: String, args: Any*) = Console.readLine(text, args: _*) def readBoolean() = Console.readBoolean() def readByte() = Console.readByte() def readShort() = Console.readShort() diff --git a/test/files/run/Predef.readLine.check b/test/files/run/Predef.readLine.check new file mode 100644 index 0000000000..4fb2bc4c6a --- /dev/null +++ b/test/files/run/Predef.readLine.check @@ -0,0 +1,3 @@ +prompt +fancy prompt +immensely fancy prompt \ No newline at end of file diff --git a/test/files/run/Predef.readLine.scala b/test/files/run/Predef.readLine.scala new file mode 100644 index 0000000000..9f07936638 --- /dev/null +++ b/test/files/run/Predef.readLine.scala @@ -0,0 +1,10 @@ +import java.io.StringReader + +object Test extends App { + Console.withIn(new StringReader("")) { + readLine() + readLine("prompt\n") + readLine("%s prompt\n", "fancy") + readLine("%s %s prompt\n", "immensely", "fancy") + } +} \ No newline at end of file -- cgit v1.2.3 From beeac27cb480399eb787b47ef83906dd91935640 Mon Sep 17 00:00:00 2001 From: Christopher Vogt Date: Fri, 20 Jan 2012 00:30:11 +0100 Subject: Improved performance of TraversableLike.dropWhile, which now stops re-evaluating the predicate after it once evaluated to true. Closes SI-5387. --- src/library/scala/collection/TraversableLike.scala | 2 +- test/files/run/t5387.scala | 15 +++++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 test/files/run/t5387.scala (limited to 'src/library') diff --git a/src/library/scala/collection/TraversableLike.scala b/src/library/scala/collection/TraversableLike.scala index b4813e6341..36d45c0c8a 100644 --- a/src/library/scala/collection/TraversableLike.scala +++ b/src/library/scala/collection/TraversableLike.scala @@ -535,7 +535,7 @@ trait TraversableLike[+A, +Repr] extends HasNewBuilder[A, Repr] val b = newBuilder var go = false for (x <- this) { - if (!p(x)) go = true + if (!go && !p(x)) go = true if (go) b += x } b.result diff --git a/test/files/run/t5387.scala b/test/files/run/t5387.scala new file mode 100644 index 0000000000..5d62a005a9 --- /dev/null +++ b/test/files/run/t5387.scala @@ -0,0 +1,15 @@ +/* + * This tests that the predicate of dropWhile is only evaluated as often as needed, see https://issues.scala-lang.org/browse/SI-5387 + */ +import scala.collection.immutable.ListMap +object Test extends App{ + val subject = ListMap(1->1,2->2,3->3,4->4,5->5) + val result = ListMap(3->3,4->4,5->5) + assert( result == subject.dropWhile{ + case (key, value) => { + assert( key <= 3, "predicate evaluated more often than needed, key "+key ) + key < 3 + } + } + ) +} -- cgit v1.2.3 From 35e676ded0f9bfd006a5f090841abdea3ff1759c Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Fri, 20 Jan 2012 01:52:40 +0100 Subject: Progress with macros A short recap: * Macro expansion now works finely for instance macro invocations * Macros are now hidden behind -Xmacros * Bodies of macros now have "import _context._" in their preamble * Macros are now loaded from classpath, much like regular libraries * Macros can now override methods (in that case macro expansion does not crash if macro is not found, it just falls back to super) Review by @odersky. --- .../scala/reflect/internal/Definitions.scala | 1 + src/compiler/scala/reflect/internal/StdNames.scala | 29 ++--- .../scala/reflect/runtime/JavaToScala.scala | 2 +- src/compiler/scala/reflect/runtime/Mirror.scala | 15 ++- src/compiler/scala/tools/nsc/Global.scala | 6 + src/compiler/scala/tools/nsc/MacroContext.scala | 2 +- .../scala/tools/nsc/ast/parser/Parsers.scala | 7 +- .../scala/tools/nsc/settings/ScalaSettings.scala | 1 + .../scala/tools/nsc/typechecker/Macros.scala | 136 +++++++++++++++++++-- .../scala/tools/nsc/typechecker/Namers.scala | 4 +- .../scala/tools/nsc/typechecker/Typers.scala | 20 ++- src/library/scala/reflect/ReflectionUtils.scala | 12 +- src/library/scala/reflect/api/MacroContext.scala | 15 --- src/library/scala/reflect/api/Mirror.scala | 6 +- src/library/scala/reflect/macro/Context.scala | 15 +++ src/library/scala/reflect/package.scala | 2 +- test/files/macros/Printf.scala | 39 ++++++ test/files/macros/Test.scala | 8 ++ test/files/macros/macros_v0001.bat | 40 ++++++ test/files/macros/macros_v0001.sh | 30 +++++ test/files/pos/macros.flags | 2 +- test/files/run/macro-range.check | 9 ++ test/files/run/macro-range.flags | 1 + test/files/run/macro-range/macro_range_1.scala | 94 ++++++++++++++ test/files/run/macro-range/macro_range_2.scala | 94 ++++++++++++++ 25 files changed, 528 insertions(+), 62 deletions(-) delete mode 100644 src/library/scala/reflect/api/MacroContext.scala create mode 100644 src/library/scala/reflect/macro/Context.scala create mode 100644 test/files/macros/Printf.scala create mode 100644 test/files/macros/Test.scala create mode 100644 test/files/macros/macros_v0001.bat create mode 100644 test/files/macros/macros_v0001.sh create mode 100644 test/files/run/macro-range.check create mode 100644 test/files/run/macro-range.flags create mode 100644 test/files/run/macro-range/macro_range_1.scala create mode 100644 test/files/run/macro-range/macro_range_2.scala (limited to 'src/library') diff --git a/src/compiler/scala/reflect/internal/Definitions.scala b/src/compiler/scala/reflect/internal/Definitions.scala index d38b62cbb4..f7e276fdab 100644 --- a/src/compiler/scala/reflect/internal/Definitions.scala +++ b/src/compiler/scala/reflect/internal/Definitions.scala @@ -393,6 +393,7 @@ trait Definitions extends reflect.api.StandardDefinitions { // scala.reflect lazy val ReflectApiUniverse = getRequiredClass("scala.reflect.api.Universe") + lazy val ReflectMacroContext = getRequiredClass("scala.reflect.macro.Context") lazy val ReflectRuntimeMirror = getRequiredModule("scala.reflect.runtime.Mirror") def freeValueMethod = getMember(ReflectRuntimeMirror, nme.freeValue) lazy val ReflectPackage = getPackageObject("scala.reflect") diff --git a/src/compiler/scala/reflect/internal/StdNames.scala b/src/compiler/scala/reflect/internal/StdNames.scala index 507621ea42..aba00088f9 100644 --- a/src/compiler/scala/reflect/internal/StdNames.scala +++ b/src/compiler/scala/reflect/internal/StdNames.scala @@ -13,7 +13,7 @@ import annotation.switch trait StdNames extends NameManglers { self: SymbolTable => def encode(str: String): TermName = newTermNameCached(NameTransformer.encode(str)) - + implicit def lowerTermNames(n: TermName): String = "" + n // implicit def stringToTermName(s: String): TermName = newTermName(s) @@ -182,7 +182,7 @@ trait StdNames extends NameManglers { self: SymbolTable => trait TermNames extends Keywords with CommonNames { // Compiler internal names val EXPAND_SEPARATOR_STRING = "$$" - + val ANYNAME: NameType = "" val CONSTRUCTOR: NameType = "" val FAKE_LOCAL_THIS: NameType = "this$" @@ -207,7 +207,7 @@ trait StdNames extends NameManglers { self: SymbolTable => final val Predef: NameType = "Predef" final val ScalaRunTime: NameType = "ScalaRunTime" final val Some: NameType = "Some" - + val _1 : NameType = "_1" val _2 : NameType = "_2" val _3 : NameType = "_3" @@ -301,6 +301,8 @@ trait StdNames extends NameManglers { self: SymbolTable => val classOf: NameType = "classOf" val clone_ : NameType = if (forMSIL) "MemberwiseClone" else "clone" // sn.OClone causes checkinit failure val conforms: NameType = "conforms" + val context : NameType = "_context" + val contextImplicit : NameType = "$context" val copy: NameType = "copy" val delayedInit: NameType = "delayedInit" val delayedInitArg: NameType = "delayedInit$body" @@ -324,7 +326,6 @@ trait StdNames extends NameManglers { self: SymbolTable => val freeValue : NameType = "freeValue" val genericArrayOps: NameType = "genericArrayOps" val get: NameType = "get" - val glob : NameType = "glob" val hasNext: NameType = "hasNext" val hashCode_ : NameType = if (forMSIL) "GetHashCode" else "hashCode" val hash_ : NameType = "hash" @@ -430,7 +431,7 @@ trait StdNames extends NameManglers { self: SymbolTable => val REFINE_CLASS_NAME: NameType = "" val ANON_CLASS_NAME: NameType = "$anon" } - + /** For fully qualified type names. */ object fulltpnme extends TypeNames { @@ -450,11 +451,11 @@ trait StdNames extends NameManglers { self: SymbolTable => val RuntimeNothing = toBinary(fulltpnme.RuntimeNothing).toTypeName val RuntimeNull = toBinary(fulltpnme.RuntimeNull).toTypeName } - + object fullnme extends TermNames { type NameType = TermName protected implicit def createNameType(name: String): TermName = newTermNameCached(name) - + val MirrorPackage: NameType = "scala.reflect.mirror" } @@ -516,7 +517,7 @@ trait StdNames extends NameManglers { self: SymbolTable => def moduleVarName(name: TermName): TermName = newTermNameCached("" + name + MODULE_VAR_SUFFIX) - + val ROOTPKG: TermName = "_root_" /** Base strings from which synthetic names are derived. */ @@ -531,7 +532,7 @@ trait StdNames extends NameManglers { self: SymbolTable => val INTERPRETER_VAR_PREFIX = "res" val INTERPRETER_WRAPPER_SUFFIX = "$object" val WHILE_PREFIX = "while$" - + val EQEQ_LOCAL_VAR: TermName = newTermName(EQEQ_LOCAL_VAR_STRING) def getCause = sn.GetCause @@ -568,18 +569,18 @@ trait StdNames extends NameManglers { self: SymbolTable => val UNARY_+ = encode("unary_+") val UNARY_- = encode("unary_-") val UNARY_! = encode("unary_!") - + // Grouped here so Cleanup knows what tests to perform. val CommonOpNames = Set[Name](OR, XOR, AND, EQ, NE) val ConversionNames = Set[Name](toByte, toChar, toDouble, toFloat, toInt, toLong, toShort) val BooleanOpNames = Set[Name](ZOR, ZAND, UNARY_!) ++ CommonOpNames val NumberOpNames = ( - Set[Name](ADD, SUB, MUL, DIV, MOD, LSL, LSR, ASR, LT, LE, GE, GT) - ++ Set(UNARY_+, UNARY_-, UNARY_!) + Set[Name](ADD, SUB, MUL, DIV, MOD, LSL, LSR, ASR, LT, LE, GE, GT) + ++ Set(UNARY_+, UNARY_-, UNARY_!) ++ ConversionNames ++ CommonOpNames ) - + val add: NameType = "add" val complement: NameType = "complement" val divide: NameType = "divide" @@ -670,7 +671,7 @@ trait StdNames extends NameManglers { self: SymbolTable => reflMethodName ) def isReflectionCacheName(name: Name) = reflectionCacheNames exists (name startsWith _) - + @switch def productAccessorName(j: Int): TermName = j match { case 1 => nme._1 case 2 => nme._2 diff --git a/src/compiler/scala/reflect/runtime/JavaToScala.scala b/src/compiler/scala/reflect/runtime/JavaToScala.scala index 61b03a9a29..bc5d616ae3 100644 --- a/src/compiler/scala/reflect/runtime/JavaToScala.scala +++ b/src/compiler/scala/reflect/runtime/JavaToScala.scala @@ -45,7 +45,7 @@ trait JavaToScala extends ConversionUtil { self: SymbolTable => def javaClass(path: String): jClass[_] = javaClass(path, defaultReflectiveClassLoader()) def javaClass(path: String, classLoader: JClassLoader): jClass[_] = - classLoader.loadClass(path) + Class.forName(path, true, classLoader) /** Does `path` correspond to a Java class with that fully qualified name? */ def isJavaClass(path: String): Boolean = diff --git a/src/compiler/scala/reflect/runtime/Mirror.scala b/src/compiler/scala/reflect/runtime/Mirror.scala index 9490dc4ad7..09a4bbe198 100644 --- a/src/compiler/scala/reflect/runtime/Mirror.scala +++ b/src/compiler/scala/reflect/runtime/Mirror.scala @@ -12,7 +12,16 @@ class Mirror extends Universe with RuntimeTypes with TreeBuildUtil with ToolBoxe import definitions._ - def classWithName(name: String): Symbol = classToScala(javaClass(name)) + def classWithName(name: String): Symbol = { + val clazz = javaClass(name, defaultReflectiveClassLoader()) + classToScala(clazz) + } + + def getCompanionObject(clazz: Symbol): AnyRef = { + val singleton = ReflectionUtils.singletonInstance(clazz.fullName, defaultReflectiveClassLoader()) + singleton + } + def getClass(obj: AnyRef): Symbol = classToScala(obj.getClass) def getType(obj: AnyRef): Type = typeToScala(obj.getClass) // to do add getClass/getType for instances of primitive types, probably like this: @@ -32,7 +41,9 @@ class Mirror extends Universe with RuntimeTypes with TreeBuildUtil with ToolBoxe case nme.update => return Array.set(receiver, args(0).asInstanceOf[Int], args(1)) } } - methodToJava(meth).invoke(receiver, args.asInstanceOf[Seq[AnyRef]]: _*) + + val jmeth = methodToJava(meth) + jmeth.invoke(receiver, args.asInstanceOf[Seq[AnyRef]]: _*) } override def classToType(jclazz: java.lang.Class[_]): Type = typeToScala(jclazz) diff --git a/src/compiler/scala/tools/nsc/Global.scala b/src/compiler/scala/tools/nsc/Global.scala index c8db996de2..e805b4e75e 100644 --- a/src/compiler/scala/tools/nsc/Global.scala +++ b/src/compiler/scala/tools/nsc/Global.scala @@ -901,6 +901,9 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb /** Counts for certain classes of warnings during this run. */ var deprecationWarnings: List[(Position, String)] = Nil var uncheckedWarnings: List[(Position, String)] = Nil + + /** A flag whether macro expansions failed */ + var macroExpansionFailed = false /** Progress tracking. Measured in "progress units" which are 1 per * compilation unit per phase completed. @@ -1083,6 +1086,9 @@ class Global(var currentSettings: Settings, var reporter: Reporter) extends Symb ) warn(deprecationWarnings.size, "deprecation", settings.deprecation) warn(uncheckedWarnings.size, "unchecked", settings.unchecked) + if (macroExpansionFailed) + warning("some macros could not be expanded and code fell back to overridden methods;"+ + "\nrecompiling with generated classfiles on the classpath might help.") // todo: migrationWarnings } } diff --git a/src/compiler/scala/tools/nsc/MacroContext.scala b/src/compiler/scala/tools/nsc/MacroContext.scala index e739eade3a..72662291f8 100644 --- a/src/compiler/scala/tools/nsc/MacroContext.scala +++ b/src/compiler/scala/tools/nsc/MacroContext.scala @@ -2,7 +2,7 @@ package scala.tools.nsc import symtab.Flags._ -trait MacroContext extends reflect.api.MacroContext { self: Global => +trait MacroContext extends reflect.macro.Context { self: Global => def captureVariable(vble: Symbol): Unit = vble setFlag CAPTURED diff --git a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala index ce41bc456e..fe6dcc9138 100644 --- a/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala +++ b/src/compiler/scala/tools/nsc/ast/parser/Parsers.scala @@ -2449,7 +2449,7 @@ self => else { val nameOffset = in.offset val name = ident() - if (name == nme.macro_ && isIdent && settings.Xexperimental.value) + if (name == nme.macro_ && isIdent && settings.Xmacros.value) funDefRest(start, in.offset, mods | Flags.MACRO, ident()) else funDefRest(start, nameOffset, mods, name) @@ -2480,6 +2480,9 @@ self => restype = scalaUnitConstr blockExpr() } else { + if (name == nme.macro_ && isIdent && in.token != EQUALS) { + warning("this syntactically invalid code resembles a macro definition. have you forgotten to enable -Xmacros?") + } equalsExpr() } DefDef(newmods, name, tparams, vparamss, restype, rhs) @@ -2539,7 +2542,7 @@ self => newLinesOpt() atPos(start, in.offset) { val name = identForType() - if (name == nme.macro_.toTypeName && isIdent && settings.Xexperimental.value) { + if (name == nme.macro_.toTypeName && isIdent && settings.Xmacros.value) { funDefRest(start, in.offset, mods | Flags.MACRO, identForType()) } else { // @M! a type alias as well as an abstract type may declare type parameters diff --git a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala index efd5323ce2..6806ca03ba 100644 --- a/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala +++ b/src/compiler/scala/tools/nsc/settings/ScalaSettings.scala @@ -96,6 +96,7 @@ trait ScalaSettings extends AbsScalaSettings val Xexperimental = BooleanSetting ("-Xexperimental", "Enable experimental extensions.") . withPostSetHook(set => List(YmethodInfer, overrideObjects) foreach (_.value = set.value)) // YdepMethTpes, YvirtClasses, + val Xmacros = BooleanSetting ("-Xmacros", "Enable macros.") /** Compatibility stubs for options whose value name did * not previously match the option name. diff --git a/src/compiler/scala/tools/nsc/typechecker/Macros.scala b/src/compiler/scala/tools/nsc/typechecker/Macros.scala index b9264aae55..7f9e56a926 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Macros.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Macros.scala @@ -2,6 +2,8 @@ package scala.tools.nsc package typechecker import symtab.Flags._ +import scala.tools.nsc.util._ +import scala.reflect.ReflectionUtils trait Macros { self: Analyzer => import global._ @@ -13,6 +15,20 @@ trait Macros { self: Analyzer => owner.info.decl(nme.macroMethodName(mac.name)) } + def macroArgs(tree: Tree): (List[List[Tree]]) = tree match { + case Apply(fn, args) => + macroArgs(fn) :+ args + case TypeApply(fn, args) => + macroArgs(fn) :+ args + case Select(qual, name) if !isStaticMacro(tree.symbol) => + List(List(qual)) + case _ => + List(List()) + } + + private def isStaticMacro(mac: Symbol): Boolean = + mac.owner.isModuleClass + /** * The definition of the method implementing a macro. Example: * Say we have in a class C @@ -33,25 +49,32 @@ trait Macros { self: Analyzer => */ def macroMethDef(mdef: DefDef): Tree = { def paramDef(name: Name, tpt: Tree) = ValDef(Modifiers(PARAM), name, tpt, EmptyTree) - val universeType = TypeTree(ReflectApiUniverse.tpe) - val globParamSec = List(paramDef(nme.glob, universeType)) - def globSelect(name: Name) = Select(Ident(nme.glob), name) + val contextType = TypeTree(ReflectMacroContext.tpe) + val globParamSec = List(paramDef(nme.context, contextType)) + def globSelect(name: Name) = Select(Ident(nme.context), name) def globTree = globSelect(newTypeName("Tree")) def globType = globSelect(newTypeName("Type")) - val thisParamSec = if (mdef.symbol.owner.isModuleClass) List() else List(paramDef(newTermName("_this"), globTree)) + val thisParamSec = if (isStaticMacro(mdef.symbol)) List() else List(paramDef(newTermName("_this"), globTree)) def tparamInMacro(tdef: TypeDef) = paramDef(tdef.name.toTermName, globType) - def vparamInMacro(vdef: ValDef): ValDef = paramDef(vdef.name, globTree) + def vparamInMacro(vdef: ValDef): ValDef = paramDef(vdef.name, vdef.tpt match { + case tpt @ AppliedTypeTree(hk, _) if treeInfo.isRepeatedParamType(tpt) => AppliedTypeTree(hk, List(globTree)) + case _ => globTree + }) def wrapImplicit(tree: Tree) = atPos(tree.pos) { - Block(List(ValDef(Modifiers(IMPLICIT), newTermName("$" + nme.glob), universeType, Ident(nme.glob))), tree) + // implicit hasn't proven useful so far, so I'm disabling it + //val implicitDecl = ValDef(Modifiers(IMPLICIT), nme.contextImplicit, SingletonTypeTree(Ident(nme.context)), Ident(nme.context)) + val importGlob = Import(Ident(nme.context), List(ImportSelector(nme.WILDCARD, -1, null, -1))) + Block(List(importGlob), tree) } + var formals = (mdef.vparamss map (_ map vparamInMacro)) + if (mdef.tparams.nonEmpty) formals = (mdef.tparams map tparamInMacro) :: formals atPos(mdef.pos) { new DefDef( // can't call DefDef here; need to find out why - mods = mdef.mods &~ MACRO, + mods = mdef.mods &~ MACRO &~ OVERRIDE, name = nme.macroMethodName(mdef.name), tparams = List(), - vparamss = globParamSec :: thisParamSec :: (mdef.tparams map tparamInMacro) :: - (mdef.vparamss map (_ map vparamInMacro)), + vparamss = globParamSec :: thisParamSec :: formals, tpt = globTree, wrapImplicit(mdef.rhs)) } @@ -59,11 +82,98 @@ trait Macros { self: Analyzer => def addMacroMethods(templ: Template, namer: Namer): Unit = { for (ddef @ DefDef(mods, _, _, _, _, _) <- templ.body if mods hasFlag MACRO) { - val sym = namer.enterSyntheticSym(util.trace("macro def: ")(macroMethDef(ddef))) - println("added to "+namer.context.owner.enclClass+": "+sym) + val trace = scala.tools.nsc.util.trace when settings.debug.value + val sym = namer.enterSyntheticSym(trace("macro def: ")(macroMethDef(ddef))) + trace("added to "+namer.context.owner.enclClass+": ")(sym) } } - def macroExpand(tree: Tree): Tree = ??? + lazy val mirror = new scala.reflect.runtime.Mirror { + lazy val libraryClassLoader = { + val classpath = global.classPath.asURLs + ScalaClassLoader.fromURLs(classpath, self.getClass.getClassLoader) + } + + override def defaultReflectiveClassLoader() = libraryClassLoader + } + + class MacroExpandError(val msg: String) extends Exception(msg) -} \ No newline at end of file + /** Return optionally address of companion object and implementation method symbol + * of given macro; or None if implementation classfile cannot be loaded or does + * not contain the macro implementation. + */ + def macroImpl(mac: Symbol): Option[(AnyRef, mirror.Symbol)] = { + try { + val mmeth = macroMeth(mac) + if (mmeth == NoSymbol) None + else { + val receiverClass: mirror.Symbol = mirror.classWithName(mmeth.owner.fullName) + val receiverObj = receiverClass.companionModule + if (receiverObj == NoSymbol) None + else { + val receiver = mirror.getCompanionObject(receiverClass) + val rmeth = receiverObj.info.member(mirror.newTermName(mmeth.name.toString)) + Some((receiver, rmeth)) + } + } + } catch { + case ex: ClassNotFoundException => + None + } + } + + /** Return result of macro expansion. + * Or, if that fails, and the macro overrides a method return + * tree that calls this method instead of the macro. + */ + def macroExpand(tree: Tree): Any = { + val macroDef = tree.symbol + macroImpl(macroDef) match { + case Some((receiver, rmeth)) => + val argss = List(global) :: macroArgs(tree) + val paramss = macroMeth(macroDef).paramss + val rawArgss = for ((as, ps) <- argss zip paramss) yield { + if (isVarArgsList(ps)) as.take(ps.length - 1) :+ as.drop(ps.length - 1) + else as + } + val rawArgs: Seq[Any] = rawArgss.flatten + try { + mirror.invoke(receiver, rmeth, rawArgs: _*) + } catch { + case ex => + val realex = ReflectionUtils.unwrapThrowable(ex) + val stacktrace = new java.io.StringWriter() + realex.printStackTrace(new java.io.PrintWriter(stacktrace)) + val msg = System.getProperty("line.separator") + stacktrace + throw new MacroExpandError("exception during macro expansion: " + msg) + } + case None => + val trace = scala.tools.nsc.util.trace when settings.debug.value + def notFound() = throw new MacroExpandError("macro implementation not found: " + macroDef.name) + def fallBackToOverridden(tree: Tree): Tree = { + tree match { + case Select(qual, name) if (macroDef.isMacro) => + macroDef.allOverriddenSymbols match { + case first :: others => + return Select(qual, name) setPos tree.pos setSymbol first + case _ => + trace("macro is not overridden: ")(tree) + notFound() + } + case Apply(fn, args) => + Apply(fallBackToOverridden(fn), args) setPos tree.pos + case TypeApply(fn, args) => + TypeApply(fallBackToOverridden(fn), args) setPos tree.pos + case _ => + trace("unexpected tree in fallback: ")(tree) + notFound() + } + } + val tree1 = fallBackToOverridden(tree) + trace("falling back to ")(tree1) + currentRun.macroExpansionFailed = true + tree1 + } + } +} diff --git a/src/compiler/scala/tools/nsc/typechecker/Namers.scala b/src/compiler/scala/tools/nsc/typechecker/Namers.scala index 354b8caaa3..e04d89047b 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Namers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Namers.scala @@ -842,10 +842,10 @@ trait Namers extends MethodSynthesis { Namers.this.classOfModuleClass get clazz foreach { cdefRef => val cdef = cdefRef() if (cdef.mods.isCase) addApplyUnapply(cdef, templateNamer) - addMacroMethods(cdef.impl, templateNamer) + if (settings.Xmacros.value) addMacroMethods(cdef.impl, templateNamer) classOfModuleClass -= clazz } - addMacroMethods(templ, templateNamer) + if (settings.Xmacros.value) addMacroMethods(templ, templateNamer) } // add the copy method to case classes; this needs to be done here, not in SyntheticMethods, because diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 884ad7af3d..5aaad9da2f 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -911,7 +911,10 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { } if (tree.isType) adaptType() - else if ((mode & (PATTERNmode | FUNmode)) == (PATTERNmode | FUNmode)) + else if (inExprModeButNot(mode, FUNmode) && tree.symbol != null && tree.symbol.isMacro && !tree.isDef) { + val tree1 = expandMacro(tree) + if (tree1.isErroneous) tree1 else typed(tree1, mode, pt) + } else if ((mode & (PATTERNmode | FUNmode)) == (PATTERNmode | FUNmode)) adaptConstrPattern() else if (inAllModes(mode, EXPRmode | FUNmode) && !tree.tpe.isInstanceOf[MethodType] && @@ -3471,9 +3474,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { // (calling typed1 more than once for the same tree) if (checked ne res) typed { atPos(tree.pos)(checked) } else res - } else if ((mode & FUNmode) == 0 && fun2.hasSymbol && fun2.symbol.isMacro) - typed1(macroExpand(res), mode, pt) - else + } else res case ex: TypeError => fun match { @@ -3483,7 +3484,7 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { if (treeInfo.isVariableOrGetter(qual1)) { stopTimer(failedOpEqNanos, opeqStart) convertToAssignment(fun, qual1, name, args, ex) - } + } else { stopTimer(failedApplyNanos, appStart) reportTypeError(fun.pos, ex) @@ -4430,6 +4431,15 @@ trait Typers extends Modes with Adaptations with PatMatVirtualiser { } } + def expandMacro(tree: Tree): Tree = try { + macroExpand(tree) match { + case t: Tree => t + case t => errorTree(tree, "macros must return a compiler-specific tree; returned class is: " + t.getClass) + } + } catch { + case ex: MacroExpandError => errorTree(tree, ex.msg) + } + def atOwner(owner: Symbol): Typer = newTyper(context.make(context.tree, owner)) diff --git a/src/library/scala/reflect/ReflectionUtils.scala b/src/library/scala/reflect/ReflectionUtils.scala index b63a8645de..dfadfb4976 100644 --- a/src/library/scala/reflect/ReflectionUtils.scala +++ b/src/library/scala/reflect/ReflectionUtils.scala @@ -27,11 +27,15 @@ object ReflectionUtils { case ex if pf isDefinedAt unwrapThrowable(ex) => pf(unwrapThrowable(ex)) } - // Retrieves the MODULE$ field for the given class name. - def singletonInstance(className: String, cl: ClassLoader = getClass.getClassLoader): Option[AnyRef] = { + def singletonInstance(className: String, cl: ClassLoader = getClass.getClassLoader): AnyRef = { val name = if (className endsWith "$") className else className + "$" + val clazz = java.lang.Class.forName(name, true, cl) + val singleton = clazz getField "MODULE$" get null + singleton + } - try Some(java.lang.Class.forName(name, true, cl) getField "MODULE$" get null) + // Retrieves the MODULE$ field for the given class name. + def singletonInstanceOpt(className: String, cl: ClassLoader = getClass.getClassLoader): Option[AnyRef] = + try Some(singletonInstance(className, cl)) catch { case _: ClassNotFoundException => None } - } } diff --git a/src/library/scala/reflect/api/MacroContext.scala b/src/library/scala/reflect/api/MacroContext.scala deleted file mode 100644 index e23357d26e..0000000000 --- a/src/library/scala/reflect/api/MacroContext.scala +++ /dev/null @@ -1,15 +0,0 @@ -package scala.reflect -package api - -trait MacroContext extends Universe { - - /** Mark a variable as captured; i.e. force boxing in a *Ref type. - */ - def captureVariable(vble: Symbol): Unit - - /** Mark given identifier as a reference to a captured variable itself - * suppressing dereferencing with the `elem` field. - */ - def referenceCapturedVariable(id: Ident): Tree - -} \ No newline at end of file diff --git a/src/library/scala/reflect/api/Mirror.scala b/src/library/scala/reflect/api/Mirror.scala index 53ac84f8cb..136f52b05f 100644 --- a/src/library/scala/reflect/api/Mirror.scala +++ b/src/library/scala/reflect/api/Mirror.scala @@ -13,7 +13,11 @@ trait Mirror extends Universe with RuntimeTypes with TreeBuildUtil { * to do: throws anything else? */ def classWithName(name: String): Symbol - + + /** Return a reference to the companion object of this class symbol + */ + def getCompanionObject(clazz: Symbol): AnyRef + /** The Scala class symbol corresponding to the runtime class of given object * @param The object from which the class is returned * @throws ? diff --git a/src/library/scala/reflect/macro/Context.scala b/src/library/scala/reflect/macro/Context.scala new file mode 100644 index 0000000000..d0a2787fdf --- /dev/null +++ b/src/library/scala/reflect/macro/Context.scala @@ -0,0 +1,15 @@ +package scala.reflect +package macro + +trait Context extends api.Universe { + + /** Mark a variable as captured; i.e. force boxing in a *Ref type. + */ + def captureVariable(vble: Symbol): Unit + + /** Mark given identifier as a reference to a captured variable itself + * suppressing dereferencing with the `elem` field. + */ + def referenceCapturedVariable(id: Ident): Tree + +} diff --git a/src/library/scala/reflect/package.scala b/src/library/scala/reflect/package.scala index 62592baa27..1c3e618520 100644 --- a/src/library/scala/reflect/package.scala +++ b/src/library/scala/reflect/package.scala @@ -8,7 +8,7 @@ package object reflect { // initialization, but in response to a doomed attempt to utilize it. lazy val mirror: api.Mirror = { // we use (Java) reflection here so that we can keep reflect.runtime and reflect.internals in a seperate jar - ReflectionUtils.singletonInstance("scala.reflect.runtime.Mirror") collect { case x: api.Mirror => x } getOrElse { + ReflectionUtils.singletonInstanceOpt("scala.reflect.runtime.Mirror") collect { case x: api.Mirror => x } getOrElse { throw new UnsupportedOperationException("Scala reflection not available on this platform") } } diff --git a/test/files/macros/Printf.scala b/test/files/macros/Printf.scala new file mode 100644 index 0000000000..4a88e5b069 --- /dev/null +++ b/test/files/macros/Printf.scala @@ -0,0 +1,39 @@ +// macros should be built separately from their clients, so simple "scalac Printf.scala Test.scala" won't work +// 1) first build this file with "scalac -Xmacros Printf.scala" +// 2) the build the test with "scalac -cp Test.scala" + +object Printf extends App { + def macro printf(format: String, params: Any*) : String = { + var i = 0 + def gensym(name: String) = { i += 1; newTermName(name + i) } + + def createTempValDef(value: Tree, clazz: Class[_]): (Option[Tree], Tree) = { + val local = gensym("temp") + val tpe = if (clazz == classOf[Int]) Ident(newTypeName("Int")) + else if (clazz == classOf[String]) Select(Select(Ident(newTermName("java")), newTermName("lang")), newTypeName("String")) + else throw new Exception("unknown class " + clazz.toString) + (Some(ValDef(Modifiers(), local, tpe, value)), Ident(local)) + } + + def tree_printf(format: Tree, params: Tree*) = { + val Literal(Constant(s_format: String)) = format + val paramsStack = scala.collection.mutable.Stack(params: _*) + val parsed = s_format.split("(?<=%[\\w%])|(?=%[\\w%])") map { + case "%d" => createTempValDef(paramsStack.pop, classOf[Int]) + case "%s" => createTempValDef(paramsStack.pop, classOf[String]) + case "%%" => (None, Literal(Constant("%"))) + case part => (None, Literal(Constant(part))) + } + + val evals = for ((Some(eval), _) <- parsed if eval != None) yield eval + val prints = for ((_, ref) <- parsed) yield { + val print = Select(Select(Ident(newTermName("scala")), newTermName("Predef")), newTermName("print")) + Apply(print, List(ref)) + } + + Block((evals ++ prints).toList, Literal(Constant(()))) + } + + tree_printf(format, params: _*) + } +} diff --git a/test/files/macros/Test.scala b/test/files/macros/Test.scala new file mode 100644 index 0000000000..d8cdcf6756 --- /dev/null +++ b/test/files/macros/Test.scala @@ -0,0 +1,8 @@ +// macros should be built separately from their clients, so simple "scalac Printf.scala Test.scala" won't work +// 1) first build the printf macro with "scalac -Xmacros Printf.scala" +// 2) the build this file with "scalac -cp Test.scala" + +object Test extends App { + import Printf._ + printf("hello %s", "world") +} \ No newline at end of file diff --git a/test/files/macros/macros_v0001.bat b/test/files/macros/macros_v0001.bat new file mode 100644 index 0000000000..3395d2e3c1 --- /dev/null +++ b/test/files/macros/macros_v0001.bat @@ -0,0 +1,40 @@ +@echo off + +set scalahome=%~dp0\..\..\.. +set scaladeps=%scalahome%\lib\jline.jar;%scalahome%\lib\fjbg.jar +set scalalib=%scalahome%\build\pack\lib\scala-library.jar +if not exist "%scalalib%" set scalalib=%scalahome%\build\locker\classes\library +set scalacomp="%scalahome%\build\pack\lib\scala-compiler.jar" +if not exist "%scalacomp%" set scalacomp=%scalahome%\build\locker\classes\compiler +set stdcp=%scaladeps%;%scalalib%;%scalacomp% + +echo Compiling macros... +set cp=%stdcp% +call :scalac -Xmacros "%~dp0\Printf.scala" + +echo Compiling the program... +set cp=%stdcp%;%~dp0. +call :scalac "%~dp0\Test.scala" + +echo. +echo NOW LOOK!!! +echo =============================================== +set cp=%stdcp%;%~dp0. +call :scala Test +echo. +echo =============================================== +goto :eof + +:scalac +setlocal +call set args=%* +rem echo java -cp "%cp%" -Dscala.usejavacp=true scala.tools.nsc.Main %args% +java -cp "%cp%" -Dscala.usejavacp=true scala.tools.nsc.Main %args% +endlocal&goto :eof + +:scala +setlocal +call set args=%* +rem echo java -cp "%cp%" -Dscala.usejavacp=true scala.tools.nsc.MainGenericRunner %args% +java -cp "%cp%" -Dscala.usejavacp=true scala.tools.nsc.MainGenericRunner %args% +endlocal&goto :eof diff --git a/test/files/macros/macros_v0001.sh b/test/files/macros/macros_v0001.sh new file mode 100644 index 0000000000..abe09836bb --- /dev/null +++ b/test/files/macros/macros_v0001.sh @@ -0,0 +1,30 @@ +#!/bin/bash +set -o errexit + +if [[ $(uname -s) == CYGWIN* ]]; then cpsep=";"; else cpsep=":"; fi +scripthome="$(dirname "$0")" +scalahome="$scripthome/../../.." +scaladeps="$scalahome/lib/jline.jar;$scalahome/lib/fjbg.jar" +scalalib="$scalahome/build/pack/lib/scala-library.jar" +if [ ! -f "$scalalib" ]; then scalalib="$scalahome/build/locker/classes/library"; fi +scalacomp="$scalahome/build/pack/lib/scala-compiler.jar" +if [ ! -f "$scalacomp" ]; then scalacomp="$scalahome/build/locker/classes/compiler"; fi +stdcp="$scaladeps$cpsep$scalalib$cpsep$scalacomp" +function scalac { java -cp "$cp" -Dscala.usejavacp=true scala.tools.nsc.Main $*; } +function scala { java -cp "$cp" -Dscala.usejavacp=true scala.tools.nsc.MainGenericRunner $*; } + +echo "Compiling macros..." +cp="$stdcp" +scalac -Xmacros "$scripthome/Printf.scala" + +echo "Compiling the program..." +cp="$stdcp$cpsep$scripthome" +scalac "$scripthome/Test.scala" + +echo "" +echo "NOW LOOK" +echo "===============================================" +cp="$stdcp$cpsep$scripthome" +scala Test +echo "" +echo "===============================================" diff --git a/test/files/pos/macros.flags b/test/files/pos/macros.flags index e1b37447c9..7fea2ff901 100644 --- a/test/files/pos/macros.flags +++ b/test/files/pos/macros.flags @@ -1 +1 @@ --Xexperimental \ No newline at end of file +-Xmacros \ No newline at end of file diff --git a/test/files/run/macro-range.check b/test/files/run/macro-range.check new file mode 100644 index 0000000000..0719398930 --- /dev/null +++ b/test/files/run/macro-range.check @@ -0,0 +1,9 @@ +1 +2 +3 +4 +5 +6 +7 +8 +9 diff --git a/test/files/run/macro-range.flags b/test/files/run/macro-range.flags new file mode 100644 index 0000000000..06a7b31f11 --- /dev/null +++ b/test/files/run/macro-range.flags @@ -0,0 +1 @@ +-Xmacros diff --git a/test/files/run/macro-range/macro_range_1.scala b/test/files/run/macro-range/macro_range_1.scala new file mode 100644 index 0000000000..15a018fcff --- /dev/null +++ b/test/files/run/macro-range/macro_range_1.scala @@ -0,0 +1,94 @@ +import reflect.api.Modifier +import reflect.macro.Context + +abstract class RangeDefault { + val from, to: Int + def foreach(f: Int => Unit) = { + var i = from + while (i < to) { f(i); i += 1 } + } +} + +/** This class should go into reflect.macro once it is a bit more stable. */ +abstract class Utils { + val context: Context + import context._ + + class TreeSubstituter(from: List[Symbol], to: List[Tree]) extends Transformer { + override def transform(tree: Tree): Tree = tree match { + case Ident(_) => + def subst(from: List[Symbol], to: List[Tree]): Tree = + if (from.isEmpty) tree + else if (tree.symbol == from.head) to.head.duplicate // TODO: does it ever make sense *not* to perform a shallowDuplicate on `to.head`? + else subst(from.tail, to.tail); + subst(from, to) + case _ => + val tree1 = super.transform(tree) + if (tree1 ne tree) tree1.tpe = null + tree1 + } + } + def makeApply(fn: Tree, args: List[Tree]): Tree = fn match { + case Function(vparams, body) => + new TreeSubstituter(vparams map (_.symbol), args) transform body + case Block(stats, expr) => + Block(stats, makeApply(expr, args)) + case _ => + println("no beta on "+fn+" "+fn.getClass) + Apply(fn, args) + } + def makeWhile(lname: TermName, cond: Tree, body: Tree): Tree = { + val continu = Apply(Ident(lname), Nil) + val rhs = If(cond, Block(List(body), continu), Literal(Constant())) + LabelDef(lname, Nil, rhs) + } + def makeBinop(left: Tree, op: String, right: Tree): Tree = + Apply(Select(left, newTermName(op)), List(right)) +} + +class Range(val from: Int, val to: Int) extends RangeDefault { + override def macro foreach(f: Int => Unit): Unit = { + println("macro-expand, _this = "+ _this) + import _context._ + object utils extends Utils { + val context: _context.type = _context + } + import utils._ + + val initName = newTermName("") + // Either: + // scala"{ var i = $low; val h = $hi; while (i < h) { $f(i); i = i + 1 } } + // or: + // scala"($_this: RangeDefault).foreach($f)" + _this match { + case Apply(Select(New(tpt), initName), List(lo, hi)) if tpt.symbol.fullName == "Range" => + val iname = newTermName("$i") + val hname = newTermName("$h") + def iref = Ident(iname) + def href = Ident(hname) + val labelname = newTermName("$while") + val cond = makeBinop(iref, "$less", href) + val body = Block( + List(makeApply(f, List(iref))), + Assign(iref, makeBinop(iref, "$plus", Literal(Constant(1))))) + tools.nsc.util.trace("generated: ")( + Block( + List( + ValDef(Modifiers(Set(Modifier.mutable)), iname, TypeTree(), lo), + ValDef(Modifiers(), hname, TypeTree(), hi)), + makeWhile(labelname, cond, body))) + case _ => + Apply( + Select( + Typed(_this, Ident(newTypeName("RangeDefault"))), + newTermName("foreach")), + List(f)) + } + } +} + +object Test extends App { + + new Range(1, 10) foreach println + +} diff --git a/test/files/run/macro-range/macro_range_2.scala b/test/files/run/macro-range/macro_range_2.scala new file mode 100644 index 0000000000..15a018fcff --- /dev/null +++ b/test/files/run/macro-range/macro_range_2.scala @@ -0,0 +1,94 @@ +import reflect.api.Modifier +import reflect.macro.Context + +abstract class RangeDefault { + val from, to: Int + def foreach(f: Int => Unit) = { + var i = from + while (i < to) { f(i); i += 1 } + } +} + +/** This class should go into reflect.macro once it is a bit more stable. */ +abstract class Utils { + val context: Context + import context._ + + class TreeSubstituter(from: List[Symbol], to: List[Tree]) extends Transformer { + override def transform(tree: Tree): Tree = tree match { + case Ident(_) => + def subst(from: List[Symbol], to: List[Tree]): Tree = + if (from.isEmpty) tree + else if (tree.symbol == from.head) to.head.duplicate // TODO: does it ever make sense *not* to perform a shallowDuplicate on `to.head`? + else subst(from.tail, to.tail); + subst(from, to) + case _ => + val tree1 = super.transform(tree) + if (tree1 ne tree) tree1.tpe = null + tree1 + } + } + def makeApply(fn: Tree, args: List[Tree]): Tree = fn match { + case Function(vparams, body) => + new TreeSubstituter(vparams map (_.symbol), args) transform body + case Block(stats, expr) => + Block(stats, makeApply(expr, args)) + case _ => + println("no beta on "+fn+" "+fn.getClass) + Apply(fn, args) + } + def makeWhile(lname: TermName, cond: Tree, body: Tree): Tree = { + val continu = Apply(Ident(lname), Nil) + val rhs = If(cond, Block(List(body), continu), Literal(Constant())) + LabelDef(lname, Nil, rhs) + } + def makeBinop(left: Tree, op: String, right: Tree): Tree = + Apply(Select(left, newTermName(op)), List(right)) +} + +class Range(val from: Int, val to: Int) extends RangeDefault { + override def macro foreach(f: Int => Unit): Unit = { + println("macro-expand, _this = "+ _this) + import _context._ + object utils extends Utils { + val context: _context.type = _context + } + import utils._ + + val initName = newTermName("") + // Either: + // scala"{ var i = $low; val h = $hi; while (i < h) { $f(i); i = i + 1 } } + // or: + // scala"($_this: RangeDefault).foreach($f)" + _this match { + case Apply(Select(New(tpt), initName), List(lo, hi)) if tpt.symbol.fullName == "Range" => + val iname = newTermName("$i") + val hname = newTermName("$h") + def iref = Ident(iname) + def href = Ident(hname) + val labelname = newTermName("$while") + val cond = makeBinop(iref, "$less", href) + val body = Block( + List(makeApply(f, List(iref))), + Assign(iref, makeBinop(iref, "$plus", Literal(Constant(1))))) + tools.nsc.util.trace("generated: ")( + Block( + List( + ValDef(Modifiers(Set(Modifier.mutable)), iname, TypeTree(), lo), + ValDef(Modifiers(), hname, TypeTree(), hi)), + makeWhile(labelname, cond, body))) + case _ => + Apply( + Select( + Typed(_this, Ident(newTypeName("RangeDefault"))), + newTermName("foreach")), + List(f)) + } + } +} + +object Test extends App { + + new Range(1, 10) foreach println + +} -- cgit v1.2.3 From eadc8db056ee5165cefbf221c0d8e2e67ba147cf Mon Sep 17 00:00:00 2001 From: Kota Mizushima Date: Mon, 23 Jan 2012 17:57:00 +0900 Subject: * Fixed SI-4835 (https://issues.scala-lang.org/browse/SI-4835). --- src/library/scala/collection/immutable/Stream.scala | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/Stream.scala b/src/library/scala/collection/immutable/Stream.scala index e6587f9615..2eb2f8eb09 100644 --- a/src/library/scala/collection/immutable/Stream.scala +++ b/src/library/scala/collection/immutable/Stream.scala @@ -929,13 +929,19 @@ self => /** A specialized, extra-lazy implementation of a stream iterator, so it can * iterate as lazily as it traverses the tail. */ -final class StreamIterator[+A](self: Stream[A]) extends AbstractIterator[A] with Iterator[A] { +final class StreamIterator[+A] private() extends AbstractIterator[A] with Iterator[A] { + def this(self: Stream[A]) { + this() + these = new LazyCell(self) + } + // A call-by-need cell. class LazyCell(st: => Stream[A]) { lazy val v = st } - private var these = new LazyCell(self) + private var these: LazyCell = _ + def hasNext: Boolean = these.v.nonEmpty def next(): A = if (isEmpty) Iterator.empty.next -- cgit v1.2.3 From a6fcd70b6047ab56cb3415f378ffc8d72a524a8d Mon Sep 17 00:00:00 2001 From: aleksandar Date: Mon, 23 Jan 2012 18:47:04 +0100 Subject: Fix for SI-5374. Lists are now serialized so that the entire list structure is serialized, including list nodes. This is different from the previous behaviour where only the elements were serialized. List buffers are now optimized so that only the elements of the list are serialized, and not the nodes of the internally maintained list. --- src/library/scala/collection/immutable/List.scala | 21 ---------- .../scala/collection/mutable/ListBuffer.scala | 46 +++++++++++++++++++++- test/files/run/si5374.check | 3 ++ test/files/run/si5374.scala | 42 ++++++++++++++++++++ 4 files changed, 90 insertions(+), 22 deletions(-) create mode 100644 test/files/run/si5374.check create mode 100644 test/files/run/si5374.scala (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/List.scala b/src/library/scala/collection/immutable/List.scala index c6f056bd81..e9ecc75e0f 100644 --- a/src/library/scala/collection/immutable/List.scala +++ b/src/library/scala/collection/immutable/List.scala @@ -316,28 +316,7 @@ final case class ::[B](private var hd: B, private[scala] var tl: List[B]) extend override def tail : List[B] = tl override def isEmpty: Boolean = false - import java.io._ - private def writeObject(out: ObjectOutputStream) { - var xs: List[B] = this - while (!xs.isEmpty) { out.writeObject(xs.head); xs = xs.tail } - out.writeObject(ListSerializeEnd) - } - - private def readObject(in: ObjectInputStream) { - hd = in.readObject.asInstanceOf[B] - assert(hd != ListSerializeEnd) - var current: ::[B] = this - while (true) in.readObject match { - case ListSerializeEnd => - current.tl = Nil - return - case a : Any => - val list : ::[B] = new ::(a.asInstanceOf[B], Nil) - current.tl = list - current = list - } - } } /** $factoryInfo diff --git a/src/library/scala/collection/mutable/ListBuffer.scala b/src/library/scala/collection/mutable/ListBuffer.scala index 131cdd0005..eb871135df 100644 --- a/src/library/scala/collection/mutable/ListBuffer.scala +++ b/src/library/scala/collection/mutable/ListBuffer.scala @@ -13,6 +13,7 @@ package mutable import generic._ import immutable.{List, Nil, ::} +import java.io._ /** A `Buffer` implementation back up by a list. It provides constant time * prepend and append. Most other operations are linear. @@ -53,6 +54,7 @@ final class ListBuffer[A] override def companion: GenericCompanion[ListBuffer] = ListBuffer import scala.collection.Traversable + import scala.collection.immutable.ListSerializeEnd private var start: List[A] = Nil private var last0: ::[A] = _ @@ -60,7 +62,49 @@ final class ListBuffer[A] private var len = 0 protected def underlying: immutable.Seq[A] = start - + + private def writeObject(out: ObjectOutputStream) { + // write start + var xs: List[A] = start + while (!xs.isEmpty) { out.writeObject(xs.head); xs = xs.tail } + out.writeObject(ListSerializeEnd) + + // no need to write last0 + + // write if exported + out.writeBoolean(exported) + + // write the length + out.writeInt(len) + } + + private def readObject(in: ObjectInputStream) { + // read start, set last0 appropriately + var elem: A = in.readObject.asInstanceOf[A] + if (elem == ListSerializeEnd) { + start = Nil + last0 = null + } else { + var current = new ::(elem, Nil) + start = current + elem = in.readObject.asInstanceOf[A] + while (elem != ListSerializeEnd) { + val list = new ::(elem, Nil) + current.tl = list + current = list + elem = in.readObject.asInstanceOf[A] + } + last0 = current + start + } + + // read if exported + exported = in.readBoolean() + + // read the length + len = in.readInt() + } + /** The current length of the buffer. * * This operation takes constant time. diff --git a/test/files/run/si5374.check b/test/files/run/si5374.check new file mode 100644 index 0000000000..cdf0bc7e5b --- /dev/null +++ b/test/files/run/si5374.check @@ -0,0 +1,3 @@ +ListBuffer(1, 2, 3, 1) +ListBuffer(1, 2, 3, 1) +ListBuffer() \ No newline at end of file diff --git a/test/files/run/si5374.scala b/test/files/run/si5374.scala new file mode 100644 index 0000000000..a5678c3a81 --- /dev/null +++ b/test/files/run/si5374.scala @@ -0,0 +1,42 @@ + + + +import collection.mutable.ListBuffer +import java.io._ + + + +object Test { + + def main(args: Array[String]) { + ticketExample() + emptyListBuffer() + } + + def ticketExample() { + val baos = new ByteArrayOutputStream + val oos = new ObjectOutputStream(baos) + oos.writeObject( ListBuffer(1,2,3) ) + val bais = new ByteArrayInputStream( baos.toByteArray ) + val ois = new ObjectInputStream(bais) + val lb = ois.readObject.asInstanceOf[ListBuffer[Int]] + val lb2 = ListBuffer[Int]() ++= lb + + lb2 ++= List(1) + lb ++= List(1) + println(lb) + println(lb2) + } + + def emptyListBuffer() { + val baos = new ByteArrayOutputStream + val oos = new ObjectOutputStream(baos) + oos.writeObject( ListBuffer() ) + val bais = new ByteArrayInputStream( baos.toByteArray ) + val ois = new ObjectInputStream(bais) + val lb = ois.readObject.asInstanceOf[ListBuffer[Int]] + + println(lb) + } + +} -- cgit v1.2.3 From 969e2587c2d6c5f5c17d550d3192f68c4b342f45 Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Fri, 30 Dec 2011 11:01:41 -0800 Subject: Cleaner range counting. Plus a big unit test I had lying around. --- src/library/scala/collection/immutable/Range.scala | 36 +- test/files/run/range-unit.check | 4178 ++++++++++++++++++++ test/files/run/range-unit.scala | 55 + 3 files changed, 4260 insertions(+), 9 deletions(-) create mode 100644 test/files/run/range-unit.check create mode 100644 test/files/run/range-unit.scala (limited to 'src/library') diff --git a/src/library/scala/collection/immutable/Range.scala b/src/library/scala/collection/immutable/Range.scala index c92c0268b6..7537558f0b 100644 --- a/src/library/scala/collection/immutable/Range.scala +++ b/src/library/scala/collection/immutable/Range.scala @@ -286,18 +286,36 @@ extends collection.AbstractSeq[Int] object Range { private[immutable] val MAX_PRINT = 512 // some arbitrary value - /** Counts in "Long arithmetic" so we can recognize overflow. + /** Counts the number of range elements. + * @pre step != 0 + * If the size of the range exceeds Int.MaxValue, the + * result will be negative. */ - def count(start: Int, end: Int, step: Int): Int = - count(start, end, step, false) - def count(start: Int, end: Int, step: Int, isInclusive: Boolean): Int = { - // faster path for the common counting range - if (start >= 0 && end > start && end < scala.Int.MaxValue && step == 1) - (end - start) + ( if (isInclusive) 1 else 0 ) - else - NumericRange.count[Long](start, end, step, isInclusive) + if (step == 0) + throw new IllegalArgumentException("step cannot be 0.") + + val isEmpty = ( + if (start == end) !isInclusive + else if (start < end) step < 0 + else step > 0 + ) + if (isEmpty) 0 + else { + // Counts with Longs so we can recognize too-large ranges. + val gap: Long = end.toLong - start.toLong + val jumps: Long = gap / step + // Whether the size of this range is one larger than the + // number of full-sized jumps. + val hasStub = isInclusive || (gap % step != 0) + val result: Long = jumps + ( if (hasStub) 1 else 0 ) + + if (result > scala.Int.MaxValue) -1 + else result.toInt + } } + def count(start: Int, end: Int, step: Int): Int = + count(start, end, step, false) class Inclusive(start: Int, end: Int, step: Int) extends Range(start, end, step) { // override def par = new ParRange(this) diff --git a/test/files/run/range-unit.check b/test/files/run/range-unit.check new file mode 100644 index 0000000000..3daf91cd64 --- /dev/null +++ b/test/files/run/range-unit.check @@ -0,0 +1,4178 @@ +>>> Range.inclusive <<< + +start end step length/first/last +----------------------------------------- +0 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 0 -1 1/0/0 +0 0 1 1/0/0 +0 0 -2 1/0/0 +0 0 2 1/0/0 +0 0 -3 1/0/0 +0 0 3 1/0/0 +0 0 17 1/0/0 +0 0 127 1/0/0 +0 0 MIN+1 1/0/0 +0 0 MAX 1/0/0 +0 0 MIN 1/0/0 +0 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 -1 -1 2/0/-1 +0 -1 1 0 +0 -1 -2 1/0/0 +0 -1 2 0 +0 -1 -3 1/0/0 +0 -1 3 0 +0 -1 17 0 +0 -1 127 0 +0 -1 MIN+1 1/0/0 +0 -1 MAX 0 +0 -1 MIN 1/0/0 +0 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 1 -1 0 +0 1 1 2/0/1 +0 1 -2 0 +0 1 2 1/0/0 +0 1 -3 0 +0 1 3 1/0/0 +0 1 17 1/0/0 +0 1 127 1/0/0 +0 1 MIN+1 0 +0 1 MAX 1/0/0 +0 1 MIN 0 +0 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 3 -1 0 +0 3 1 4/0/3 +0 3 -2 0 +0 3 2 2/0/2 +0 3 -3 0 +0 3 3 2/0/3 +0 3 17 1/0/0 +0 3 127 1/0/0 +0 3 MIN+1 0 +0 3 MAX 1/0/0 +0 3 MIN 0 +0 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MIN+1 -1 --- + java.lang.IllegalArgumentException: 0 to -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +0 MIN+1 1 0 +0 MIN+1 -2 1073741824/0/MIN+2 +0 MIN+1 2 0 +0 MIN+1 -3 715827883/0/MIN+2 +0 MIN+1 3 0 +0 MIN+1 17 0 +0 MIN+1 127 0 +0 MIN+1 MIN+1 2/0/MIN+1 +0 MIN+1 MAX 0 +0 MIN+1 MIN 1/0/0 +0 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MAX -1 0 +0 MAX 1 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX -2 0 +0 MAX 2 1073741824/0/MAX-1 +0 MAX -3 0 +0 MAX 3 715827883/0/MAX-1 +0 MAX 17 126322568/0/MAX-8 +0 MAX 127 16909321/0/MAX-7 +0 MAX MIN+1 0 +0 MAX MAX 2/0/MAX +0 MAX MIN 0 +0 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MIN -1 --- + java.lang.IllegalArgumentException: 0 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +0 MIN 1 0 +0 MIN -2 1073741825/0/MIN +0 MIN 2 0 +0 MIN -3 715827883/0/MIN+2 +0 MIN 3 0 +0 MIN 17 0 +0 MIN 127 0 +0 MIN MIN+1 2/0/MIN+1 +0 MIN MAX 0 +0 MIN MIN 2/0/MIN + +start end step length/first/last +----------------------------------------- +-1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 0 -1 0 +-1 0 1 2/-1/0 +-1 0 -2 0 +-1 0 2 1/-1/-1 +-1 0 -3 0 +-1 0 3 1/-1/-1 +-1 0 17 1/-1/-1 +-1 0 127 1/-1/-1 +-1 0 MIN+1 0 +-1 0 MAX 1/-1/-1 +-1 0 MIN 0 +-1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 -1 -1 1/-1/-1 +-1 -1 1 1/-1/-1 +-1 -1 -2 1/-1/-1 +-1 -1 2 1/-1/-1 +-1 -1 -3 1/-1/-1 +-1 -1 3 1/-1/-1 +-1 -1 17 1/-1/-1 +-1 -1 127 1/-1/-1 +-1 -1 MIN+1 1/-1/-1 +-1 -1 MAX 1/-1/-1 +-1 -1 MIN 1/-1/-1 +-1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 1 -1 0 +-1 1 1 3/-1/1 +-1 1 -2 0 +-1 1 2 2/-1/1 +-1 1 -3 0 +-1 1 3 1/-1/-1 +-1 1 17 1/-1/-1 +-1 1 127 1/-1/-1 +-1 1 MIN+1 0 +-1 1 MAX 1/-1/-1 +-1 1 MIN 0 +-1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 3 -1 0 +-1 3 1 5/-1/3 +-1 3 -2 0 +-1 3 2 3/-1/3 +-1 3 -3 0 +-1 3 3 2/-1/2 +-1 3 17 1/-1/-1 +-1 3 127 1/-1/-1 +-1 3 MIN+1 0 +-1 3 MAX 1/-1/-1 +-1 3 MIN 0 +-1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MIN+1 -1 MAX/-1/MIN+1 +-1 MIN+1 1 0 +-1 MIN+1 -2 1073741824/-1/MIN+1 +-1 MIN+1 2 0 +-1 MIN+1 -3 715827883/-1/MIN+1 +-1 MIN+1 3 0 +-1 MIN+1 17 0 +-1 MIN+1 127 0 +-1 MIN+1 MIN+1 1/-1/-1 +-1 MIN+1 MAX 0 +-1 MIN+1 MIN 1/-1/-1 +-1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MAX -1 0 +-1 MAX 1 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -2 0 +-1 MAX 2 1073741825/-1/MAX +-1 MAX -3 0 +-1 MAX 3 715827883/-1/MAX-2 +-1 MAX 17 126322568/-1/MAX-9 +-1 MAX 127 16909321/-1/MAX-8 +-1 MAX MIN+1 0 +-1 MAX MAX 2/-1/MAX-1 +-1 MAX MIN 0 +-1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MIN -1 --- + java.lang.IllegalArgumentException: -1 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +-1 MIN 1 0 +-1 MIN -2 1073741824/-1/MIN+1 +-1 MIN 2 0 +-1 MIN -3 715827883/-1/MIN+1 +-1 MIN 3 0 +-1 MIN 17 0 +-1 MIN 127 0 +-1 MIN MIN+1 2/-1/MIN +-1 MIN MAX 0 +-1 MIN MIN 1/-1/-1 + +start end step length/first/last +----------------------------------------- +1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 0 -1 2/1/0 +1 0 1 0 +1 0 -2 1/1/1 +1 0 2 0 +1 0 -3 1/1/1 +1 0 3 0 +1 0 17 0 +1 0 127 0 +1 0 MIN+1 1/1/1 +1 0 MAX 0 +1 0 MIN 1/1/1 +1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 -1 -1 3/1/-1 +1 -1 1 0 +1 -1 -2 2/1/-1 +1 -1 2 0 +1 -1 -3 1/1/1 +1 -1 3 0 +1 -1 17 0 +1 -1 127 0 +1 -1 MIN+1 1/1/1 +1 -1 MAX 0 +1 -1 MIN 1/1/1 +1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 1 -1 1/1/1 +1 1 1 1/1/1 +1 1 -2 1/1/1 +1 1 2 1/1/1 +1 1 -3 1/1/1 +1 1 3 1/1/1 +1 1 17 1/1/1 +1 1 127 1/1/1 +1 1 MIN+1 1/1/1 +1 1 MAX 1/1/1 +1 1 MIN 1/1/1 +1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 3 -1 0 +1 3 1 3/1/3 +1 3 -2 0 +1 3 2 2/1/3 +1 3 -3 0 +1 3 3 1/1/1 +1 3 17 1/1/1 +1 3 127 1/1/1 +1 3 MIN+1 0 +1 3 MAX 1/1/1 +1 3 MIN 0 +1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MIN+1 -1 --- + java.lang.IllegalArgumentException: 1 to -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +1 MIN+1 1 0 +1 MIN+1 -2 1073741825/1/MIN+1 +1 MIN+1 2 0 +1 MIN+1 -3 715827883/1/MIN+3 +1 MIN+1 3 0 +1 MIN+1 17 0 +1 MIN+1 127 0 +1 MIN+1 MIN+1 2/1/MIN+2 +1 MIN+1 MAX 0 +1 MIN+1 MIN 2/1/MIN+1 +1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MAX -1 0 +1 MAX 1 MAX/1/MAX +1 MAX -2 0 +1 MAX 2 1073741824/1/MAX +1 MAX -3 0 +1 MAX 3 715827883/1/MAX +1 MAX 17 126322568/1/MAX-7 +1 MAX 127 16909321/1/MAX-6 +1 MAX MIN+1 0 +1 MAX MAX 1/1/1 +1 MAX MIN 0 +1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MIN -1 --- + java.lang.IllegalArgumentException: 1 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +1 MIN 1 0 +1 MIN -2 1073741825/1/MIN+1 +1 MIN 2 0 +1 MIN -3 715827884/1/MIN +1 MIN 3 0 +1 MIN 17 0 +1 MIN 127 0 +1 MIN MIN+1 2/1/MIN+2 +1 MIN MAX 0 +1 MIN MIN 2/1/MIN+1 + +start end step length/first/last +----------------------------------------- +3 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 0 -1 4/3/0 +3 0 1 0 +3 0 -2 2/3/1 +3 0 2 0 +3 0 -3 2/3/0 +3 0 3 0 +3 0 17 0 +3 0 127 0 +3 0 MIN+1 1/3/3 +3 0 MAX 0 +3 0 MIN 1/3/3 +3 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 -1 -1 5/3/-1 +3 -1 1 0 +3 -1 -2 3/3/-1 +3 -1 2 0 +3 -1 -3 2/3/0 +3 -1 3 0 +3 -1 17 0 +3 -1 127 0 +3 -1 MIN+1 1/3/3 +3 -1 MAX 0 +3 -1 MIN 1/3/3 +3 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 1 -1 3/3/1 +3 1 1 0 +3 1 -2 2/3/1 +3 1 2 0 +3 1 -3 1/3/3 +3 1 3 0 +3 1 17 0 +3 1 127 0 +3 1 MIN+1 1/3/3 +3 1 MAX 0 +3 1 MIN 1/3/3 +3 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 3 -1 1/3/3 +3 3 1 1/3/3 +3 3 -2 1/3/3 +3 3 2 1/3/3 +3 3 -3 1/3/3 +3 3 3 1/3/3 +3 3 17 1/3/3 +3 3 127 1/3/3 +3 3 MIN+1 1/3/3 +3 3 MAX 1/3/3 +3 3 MIN 1/3/3 +3 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MIN+1 -1 --- + java.lang.IllegalArgumentException: 3 to -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +3 MIN+1 1 0 +3 MIN+1 -2 1073741826/3/MIN+1 +3 MIN+1 2 0 +3 MIN+1 -3 715827884/3/MIN+2 +3 MIN+1 3 0 +3 MIN+1 17 0 +3 MIN+1 127 0 +3 MIN+1 MIN+1 2/3/MIN+4 +3 MIN+1 MAX 0 +3 MIN+1 MIN 2/3/MIN+3 +3 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MAX -1 0 +3 MAX 1 MAX-2/3/MAX +3 MAX -2 0 +3 MAX 2 1073741823/3/MAX +3 MAX -3 0 +3 MAX 3 715827882/3/MAX-1 +3 MAX 17 126322568/3/MAX-5 +3 MAX 127 16909321/3/MAX-4 +3 MAX MIN+1 0 +3 MAX MAX 1/3/3 +3 MAX MIN 0 +3 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MIN -1 --- + java.lang.IllegalArgumentException: 3 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +3 MIN 1 0 +3 MIN -2 1073741826/3/MIN+1 +3 MIN 2 0 +3 MIN -3 715827884/3/MIN+2 +3 MIN 3 0 +3 MIN 17 0 +3 MIN 127 0 +3 MIN MIN+1 2/3/MIN+4 +3 MIN MAX 0 +3 MIN MIN 2/3/MIN+3 + +start end step length/first/last +----------------------------------------- +MIN+1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 0 -1 0 +MIN+1 0 1 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 -2 0 +MIN+1 0 2 1073741824/MIN+1/-1 +MIN+1 0 -3 0 +MIN+1 0 3 715827883/MIN+1/-1 +MIN+1 0 17 126322568/MIN+1/-8 +MIN+1 0 127 16909321/MIN+1/-7 +MIN+1 0 MIN+1 0 +MIN+1 0 MAX 2/MIN+1/0 +MIN+1 0 MIN 0 +MIN+1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 -1 -1 0 +MIN+1 -1 1 MAX/MIN+1/-1 +MIN+1 -1 -2 0 +MIN+1 -1 2 1073741824/MIN+1/-1 +MIN+1 -1 -3 0 +MIN+1 -1 3 715827883/MIN+1/-1 +MIN+1 -1 17 126322568/MIN+1/-8 +MIN+1 -1 127 16909321/MIN+1/-7 +MIN+1 -1 MIN+1 0 +MIN+1 -1 MAX 1/MIN+1/MIN+1 +MIN+1 -1 MIN 0 +MIN+1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 1 -1 0 +MIN+1 1 1 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -2 0 +MIN+1 1 2 1073741825/MIN+1/1 +MIN+1 1 -3 0 +MIN+1 1 3 715827883/MIN+1/-1 +MIN+1 1 17 126322568/MIN+1/-8 +MIN+1 1 127 16909321/MIN+1/-7 +MIN+1 1 MIN+1 0 +MIN+1 1 MAX 2/MIN+1/0 +MIN+1 1 MIN 0 +MIN+1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 3 -1 0 +MIN+1 3 1 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -2 0 +MIN+1 3 2 1073741826/MIN+1/3 +MIN+1 3 -3 0 +MIN+1 3 3 715827884/MIN+1/2 +MIN+1 3 17 126322568/MIN+1/-8 +MIN+1 3 127 16909321/MIN+1/-7 +MIN+1 3 MIN+1 0 +MIN+1 3 MAX 2/MIN+1/0 +MIN+1 3 MIN 0 +MIN+1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MIN+1 -1 1/MIN+1/MIN+1 +MIN+1 MIN+1 1 1/MIN+1/MIN+1 +MIN+1 MIN+1 -2 1/MIN+1/MIN+1 +MIN+1 MIN+1 2 1/MIN+1/MIN+1 +MIN+1 MIN+1 -3 1/MIN+1/MIN+1 +MIN+1 MIN+1 3 1/MIN+1/MIN+1 +MIN+1 MIN+1 17 1/MIN+1/MIN+1 +MIN+1 MIN+1 127 1/MIN+1/MIN+1 +MIN+1 MIN+1 MIN+1 1/MIN+1/MIN+1 +MIN+1 MIN+1 MAX 1/MIN+1/MIN+1 +MIN+1 MIN+1 MIN 1/MIN+1/MIN+1 +MIN+1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MAX -1 0 +MIN+1 MAX 1 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -2 0 +MIN+1 MAX 2 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 2: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -3 0 +MIN+1 MAX 3 1431655765/MIN+1/MAX-2 +MIN+1 MAX 17 252645135/MIN+1/MAX-16 +MIN+1 MAX 127 33818641/MIN+1/MAX-14 +MIN+1 MAX MIN+1 0 +MIN+1 MAX MAX 3/MIN+1/MAX +MIN+1 MAX MIN 0 +MIN+1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MIN -1 2/MIN+1/MIN +MIN+1 MIN 1 0 +MIN+1 MIN -2 1/MIN+1/MIN+1 +MIN+1 MIN 2 0 +MIN+1 MIN -3 1/MIN+1/MIN+1 +MIN+1 MIN 3 0 +MIN+1 MIN 17 0 +MIN+1 MIN 127 0 +MIN+1 MIN MIN+1 1/MIN+1/MIN+1 +MIN+1 MIN MAX 0 +MIN+1 MIN MIN 1/MIN+1/MIN+1 + +start end step length/first/last +----------------------------------------- +MAX 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 0 -1 --- + java.lang.IllegalArgumentException: 2147483647 to 0 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX 0 1 0 +MAX 0 -2 1073741824/MAX/1 +MAX 0 2 0 +MAX 0 -3 715827883/MAX/1 +MAX 0 3 0 +MAX 0 17 0 +MAX 0 127 0 +MAX 0 MIN+1 2/MAX/0 +MAX 0 MAX 0 +MAX 0 MIN 1/MAX/MAX +MAX -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX -1 -1 --- + java.lang.IllegalArgumentException: 2147483647 to -1 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX -1 1 0 +MAX -1 -2 1073741825/MAX/-1 +MAX -1 2 0 +MAX -1 -3 715827883/MAX/1 +MAX -1 3 0 +MAX -1 17 0 +MAX -1 127 0 +MAX -1 MIN+1 2/MAX/0 +MAX -1 MAX 0 +MAX -1 MIN 2/MAX/-1 +MAX 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 1 -1 MAX/MAX/1 +MAX 1 1 0 +MAX 1 -2 1073741824/MAX/1 +MAX 1 2 0 +MAX 1 -3 715827883/MAX/1 +MAX 1 3 0 +MAX 1 17 0 +MAX 1 127 0 +MAX 1 MIN+1 1/MAX/MAX +MAX 1 MAX 0 +MAX 1 MIN 1/MAX/MAX +MAX 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 3 -1 MAX-2/MAX/3 +MAX 3 1 0 +MAX 3 -2 1073741823/MAX/3 +MAX 3 2 0 +MAX 3 -3 715827882/MAX/4 +MAX 3 3 0 +MAX 3 17 0 +MAX 3 127 0 +MAX 3 MIN+1 1/MAX/MAX +MAX 3 MAX 0 +MAX 3 MIN 1/MAX/MAX +MAX MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MIN+1 -1 --- + java.lang.IllegalArgumentException: 2147483647 to -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX MIN+1 1 0 +MAX MIN+1 -2 --- + java.lang.IllegalArgumentException: 2147483647 to -2147483647 by -2: seqs cannot contain more than Int.MaxValue elements. +MAX MIN+1 2 0 +MAX MIN+1 -3 1431655765/MAX/MIN+3 +MAX MIN+1 3 0 +MAX MIN+1 17 0 +MAX MIN+1 127 0 +MAX MIN+1 MIN+1 3/MAX/MIN+1 +MAX MIN+1 MAX 0 +MAX MIN+1 MIN 2/MAX/-1 +MAX MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MAX -1 1/MAX/MAX +MAX MAX 1 1/MAX/MAX +MAX MAX -2 1/MAX/MAX +MAX MAX 2 1/MAX/MAX +MAX MAX -3 1/MAX/MAX +MAX MAX 3 1/MAX/MAX +MAX MAX 17 1/MAX/MAX +MAX MAX 127 1/MAX/MAX +MAX MAX MIN+1 1/MAX/MAX +MAX MAX MAX 1/MAX/MAX +MAX MAX MIN 1/MAX/MAX +MAX MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MIN -1 --- + java.lang.IllegalArgumentException: 2147483647 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX MIN 1 0 +MAX MIN -2 --- + java.lang.IllegalArgumentException: 2147483647 to -2147483648 by -2: seqs cannot contain more than Int.MaxValue elements. +MAX MIN 2 0 +MAX MIN -3 1431655766/MAX/MIN +MAX MIN 3 0 +MAX MIN 17 0 +MAX MIN 127 0 +MAX MIN MIN+1 3/MAX/MIN+1 +MAX MIN MAX 0 +MAX MIN MIN 2/MAX/-1 + +start end step length/first/last +----------------------------------------- +MIN 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 0 -1 0 +MIN 0 1 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -2 0 +MIN 0 2 1073741825/MIN/0 +MIN 0 -3 0 +MIN 0 3 715827883/MIN/-2 +MIN 0 17 126322568/MIN/-9 +MIN 0 127 16909321/MIN/-8 +MIN 0 MIN+1 0 +MIN 0 MAX 2/MIN/-1 +MIN 0 MIN 0 +MIN -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN -1 -1 0 +MIN -1 1 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 -2 0 +MIN -1 2 1073741824/MIN/-2 +MIN -1 -3 0 +MIN -1 3 715827883/MIN/-2 +MIN -1 17 126322568/MIN/-9 +MIN -1 127 16909321/MIN/-8 +MIN -1 MIN+1 0 +MIN -1 MAX 2/MIN/-1 +MIN -1 MIN 0 +MIN 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 1 -1 0 +MIN 1 1 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -2 0 +MIN 1 2 1073741825/MIN/0 +MIN 1 -3 0 +MIN 1 3 715827884/MIN/1 +MIN 1 17 126322568/MIN/-9 +MIN 1 127 16909321/MIN/-8 +MIN 1 MIN+1 0 +MIN 1 MAX 2/MIN/-1 +MIN 1 MIN 0 +MIN 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 3 -1 0 +MIN 3 1 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -2 0 +MIN 3 2 1073741826/MIN/2 +MIN 3 -3 0 +MIN 3 3 715827884/MIN/1 +MIN 3 17 126322568/MIN/-9 +MIN 3 127 16909321/MIN/-8 +MIN 3 MIN+1 0 +MIN 3 MAX 2/MIN/-1 +MIN 3 MIN 0 +MIN MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MIN+1 -1 0 +MIN MIN+1 1 2/MIN/MIN+1 +MIN MIN+1 -2 0 +MIN MIN+1 2 1/MIN/MIN +MIN MIN+1 -3 0 +MIN MIN+1 3 1/MIN/MIN +MIN MIN+1 17 1/MIN/MIN +MIN MIN+1 127 1/MIN/MIN +MIN MIN+1 MIN+1 0 +MIN MIN+1 MAX 1/MIN/MIN +MIN MIN+1 MIN 0 +MIN MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MAX -1 0 +MIN MAX 1 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -2 0 +MIN MAX 2 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 2: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -3 0 +MIN MAX 3 1431655766/MIN/MAX +MIN MAX 17 252645136/MIN/MAX +MIN MAX 127 33818641/MIN/MAX-15 +MIN MAX MIN+1 0 +MIN MAX MAX 3/MIN/MAX-1 +MIN MAX MIN 0 +MIN MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MIN -1 1/MIN/MIN +MIN MIN 1 1/MIN/MIN +MIN MIN -2 1/MIN/MIN +MIN MIN 2 1/MIN/MIN +MIN MIN -3 1/MIN/MIN +MIN MIN 3 1/MIN/MIN +MIN MIN 17 1/MIN/MIN +MIN MIN 127 1/MIN/MIN +MIN MIN MIN+1 1/MIN/MIN +MIN MIN MAX 1/MIN/MIN +MIN MIN MIN 1/MIN/MIN + +>>> Range.apply <<< + +start end step length/first/last +----------------------------------------- +0 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 0 -1 0 +0 0 1 0 +0 0 -2 0 +0 0 2 0 +0 0 -3 0 +0 0 3 0 +0 0 17 0 +0 0 127 0 +0 0 MIN+1 0 +0 0 MAX 0 +0 0 MIN 0 +0 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 -1 -1 1/0/0 +0 -1 1 0 +0 -1 -2 1/0/0 +0 -1 2 0 +0 -1 -3 1/0/0 +0 -1 3 0 +0 -1 17 0 +0 -1 127 0 +0 -1 MIN+1 1/0/0 +0 -1 MAX 0 +0 -1 MIN 1/0/0 +0 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 1 -1 0 +0 1 1 1/0/0 +0 1 -2 0 +0 1 2 1/0/0 +0 1 -3 0 +0 1 3 1/0/0 +0 1 17 1/0/0 +0 1 127 1/0/0 +0 1 MIN+1 0 +0 1 MAX 1/0/0 +0 1 MIN 0 +0 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 3 -1 0 +0 3 1 3/0/2 +0 3 -2 0 +0 3 2 2/0/2 +0 3 -3 0 +0 3 3 1/0/0 +0 3 17 1/0/0 +0 3 127 1/0/0 +0 3 MIN+1 0 +0 3 MAX 1/0/0 +0 3 MIN 0 +0 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MIN+1 -1 MAX/0/MIN+2 +0 MIN+1 1 0 +0 MIN+1 -2 1073741824/0/MIN+2 +0 MIN+1 2 0 +0 MIN+1 -3 715827883/0/MIN+2 +0 MIN+1 3 0 +0 MIN+1 17 0 +0 MIN+1 127 0 +0 MIN+1 MIN+1 1/0/0 +0 MIN+1 MAX 0 +0 MIN+1 MIN 1/0/0 +0 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MAX -1 0 +0 MAX 1 MAX/0/MAX-1 +0 MAX -2 0 +0 MAX 2 1073741824/0/MAX-1 +0 MAX -3 0 +0 MAX 3 715827883/0/MAX-1 +0 MAX 17 126322568/0/MAX-8 +0 MAX 127 16909321/0/MAX-7 +0 MAX MIN+1 0 +0 MAX MAX 1/0/0 +0 MAX MIN 0 +0 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MIN -1 --- + java.lang.IllegalArgumentException: 0 until -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +0 MIN 1 0 +0 MIN -2 1073741824/0/MIN+2 +0 MIN 2 0 +0 MIN -3 715827883/0/MIN+2 +0 MIN 3 0 +0 MIN 17 0 +0 MIN 127 0 +0 MIN MIN+1 2/0/MIN+1 +0 MIN MAX 0 +0 MIN MIN 1/0/0 + +start end step length/first/last +----------------------------------------- +-1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 0 -1 0 +-1 0 1 1/-1/-1 +-1 0 -2 0 +-1 0 2 1/-1/-1 +-1 0 -3 0 +-1 0 3 1/-1/-1 +-1 0 17 1/-1/-1 +-1 0 127 1/-1/-1 +-1 0 MIN+1 0 +-1 0 MAX 1/-1/-1 +-1 0 MIN 0 +-1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 -1 -1 0 +-1 -1 1 0 +-1 -1 -2 0 +-1 -1 2 0 +-1 -1 -3 0 +-1 -1 3 0 +-1 -1 17 0 +-1 -1 127 0 +-1 -1 MIN+1 0 +-1 -1 MAX 0 +-1 -1 MIN 0 +-1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 1 -1 0 +-1 1 1 2/-1/0 +-1 1 -2 0 +-1 1 2 1/-1/-1 +-1 1 -3 0 +-1 1 3 1/-1/-1 +-1 1 17 1/-1/-1 +-1 1 127 1/-1/-1 +-1 1 MIN+1 0 +-1 1 MAX 1/-1/-1 +-1 1 MIN 0 +-1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 3 -1 0 +-1 3 1 4/-1/2 +-1 3 -2 0 +-1 3 2 2/-1/1 +-1 3 -3 0 +-1 3 3 2/-1/2 +-1 3 17 1/-1/-1 +-1 3 127 1/-1/-1 +-1 3 MIN+1 0 +-1 3 MAX 1/-1/-1 +-1 3 MIN 0 +-1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MIN+1 -1 MAX-1/-1/MIN+2 +-1 MIN+1 1 0 +-1 MIN+1 -2 1073741823/-1/MIN+3 +-1 MIN+1 2 0 +-1 MIN+1 -3 715827882/-1/MIN+4 +-1 MIN+1 3 0 +-1 MIN+1 17 0 +-1 MIN+1 127 0 +-1 MIN+1 MIN+1 1/-1/-1 +-1 MIN+1 MAX 0 +-1 MIN+1 MIN 1/-1/-1 +-1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MAX -1 0 +-1 MAX 1 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -2 0 +-1 MAX 2 1073741824/-1/MAX-2 +-1 MAX -3 0 +-1 MAX 3 715827883/-1/MAX-2 +-1 MAX 17 126322568/-1/MAX-9 +-1 MAX 127 16909321/-1/MAX-8 +-1 MAX MIN+1 0 +-1 MAX MAX 2/-1/MAX-1 +-1 MAX MIN 0 +-1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MIN -1 MAX/-1/MIN+1 +-1 MIN 1 0 +-1 MIN -2 1073741824/-1/MIN+1 +-1 MIN 2 0 +-1 MIN -3 715827883/-1/MIN+1 +-1 MIN 3 0 +-1 MIN 17 0 +-1 MIN 127 0 +-1 MIN MIN+1 1/-1/-1 +-1 MIN MAX 0 +-1 MIN MIN 1/-1/-1 + +start end step length/first/last +----------------------------------------- +1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 0 -1 1/1/1 +1 0 1 0 +1 0 -2 1/1/1 +1 0 2 0 +1 0 -3 1/1/1 +1 0 3 0 +1 0 17 0 +1 0 127 0 +1 0 MIN+1 1/1/1 +1 0 MAX 0 +1 0 MIN 1/1/1 +1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 -1 -1 2/1/0 +1 -1 1 0 +1 -1 -2 1/1/1 +1 -1 2 0 +1 -1 -3 1/1/1 +1 -1 3 0 +1 -1 17 0 +1 -1 127 0 +1 -1 MIN+1 1/1/1 +1 -1 MAX 0 +1 -1 MIN 1/1/1 +1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 1 -1 0 +1 1 1 0 +1 1 -2 0 +1 1 2 0 +1 1 -3 0 +1 1 3 0 +1 1 17 0 +1 1 127 0 +1 1 MIN+1 0 +1 1 MAX 0 +1 1 MIN 0 +1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 3 -1 0 +1 3 1 2/1/2 +1 3 -2 0 +1 3 2 1/1/1 +1 3 -3 0 +1 3 3 1/1/1 +1 3 17 1/1/1 +1 3 127 1/1/1 +1 3 MIN+1 0 +1 3 MAX 1/1/1 +1 3 MIN 0 +1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MIN+1 -1 --- + java.lang.IllegalArgumentException: 1 until -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +1 MIN+1 1 0 +1 MIN+1 -2 1073741824/1/MIN+3 +1 MIN+1 2 0 +1 MIN+1 -3 715827883/1/MIN+3 +1 MIN+1 3 0 +1 MIN+1 17 0 +1 MIN+1 127 0 +1 MIN+1 MIN+1 2/1/MIN+2 +1 MIN+1 MAX 0 +1 MIN+1 MIN 1/1/1 +1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MAX -1 0 +1 MAX 1 MAX-1/1/MAX-1 +1 MAX -2 0 +1 MAX 2 1073741823/1/MAX-2 +1 MAX -3 0 +1 MAX 3 715827882/1/MAX-3 +1 MAX 17 126322568/1/MAX-7 +1 MAX 127 16909321/1/MAX-6 +1 MAX MIN+1 0 +1 MAX MAX 1/1/1 +1 MAX MIN 0 +1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MIN -1 --- + java.lang.IllegalArgumentException: 1 until -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +1 MIN 1 0 +1 MIN -2 1073741825/1/MIN+1 +1 MIN 2 0 +1 MIN -3 715827883/1/MIN+3 +1 MIN 3 0 +1 MIN 17 0 +1 MIN 127 0 +1 MIN MIN+1 2/1/MIN+2 +1 MIN MAX 0 +1 MIN MIN 2/1/MIN+1 + +start end step length/first/last +----------------------------------------- +3 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 0 -1 3/3/1 +3 0 1 0 +3 0 -2 2/3/1 +3 0 2 0 +3 0 -3 1/3/3 +3 0 3 0 +3 0 17 0 +3 0 127 0 +3 0 MIN+1 1/3/3 +3 0 MAX 0 +3 0 MIN 1/3/3 +3 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 -1 -1 4/3/0 +3 -1 1 0 +3 -1 -2 2/3/1 +3 -1 2 0 +3 -1 -3 2/3/0 +3 -1 3 0 +3 -1 17 0 +3 -1 127 0 +3 -1 MIN+1 1/3/3 +3 -1 MAX 0 +3 -1 MIN 1/3/3 +3 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 1 -1 2/3/2 +3 1 1 0 +3 1 -2 1/3/3 +3 1 2 0 +3 1 -3 1/3/3 +3 1 3 0 +3 1 17 0 +3 1 127 0 +3 1 MIN+1 1/3/3 +3 1 MAX 0 +3 1 MIN 1/3/3 +3 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 3 -1 0 +3 3 1 0 +3 3 -2 0 +3 3 2 0 +3 3 -3 0 +3 3 3 0 +3 3 17 0 +3 3 127 0 +3 3 MIN+1 0 +3 3 MAX 0 +3 3 MIN 0 +3 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MIN+1 -1 --- + java.lang.IllegalArgumentException: 3 until -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +3 MIN+1 1 0 +3 MIN+1 -2 1073741825/3/MIN+3 +3 MIN+1 2 0 +3 MIN+1 -3 715827884/3/MIN+2 +3 MIN+1 3 0 +3 MIN+1 17 0 +3 MIN+1 127 0 +3 MIN+1 MIN+1 2/3/MIN+4 +3 MIN+1 MAX 0 +3 MIN+1 MIN 2/3/MIN+3 +3 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MAX -1 0 +3 MAX 1 MAX-3/3/MAX-1 +3 MAX -2 0 +3 MAX 2 1073741822/3/MAX-2 +3 MAX -3 0 +3 MAX 3 715827882/3/MAX-1 +3 MAX 17 126322568/3/MAX-5 +3 MAX 127 16909321/3/MAX-4 +3 MAX MIN+1 0 +3 MAX MAX 1/3/3 +3 MAX MIN 0 +3 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MIN -1 --- + java.lang.IllegalArgumentException: 3 until -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +3 MIN 1 0 +3 MIN -2 1073741826/3/MIN+1 +3 MIN 2 0 +3 MIN -3 715827884/3/MIN+2 +3 MIN 3 0 +3 MIN 17 0 +3 MIN 127 0 +3 MIN MIN+1 2/3/MIN+4 +3 MIN MAX 0 +3 MIN MIN 2/3/MIN+3 + +start end step length/first/last +----------------------------------------- +MIN+1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 0 -1 0 +MIN+1 0 1 MAX/MIN+1/-1 +MIN+1 0 -2 0 +MIN+1 0 2 1073741824/MIN+1/-1 +MIN+1 0 -3 0 +MIN+1 0 3 715827883/MIN+1/-1 +MIN+1 0 17 126322568/MIN+1/-8 +MIN+1 0 127 16909321/MIN+1/-7 +MIN+1 0 MIN+1 0 +MIN+1 0 MAX 1/MIN+1/MIN+1 +MIN+1 0 MIN 0 +MIN+1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 -1 -1 0 +MIN+1 -1 1 MAX-1/MIN+1/-2 +MIN+1 -1 -2 0 +MIN+1 -1 2 1073741823/MIN+1/-3 +MIN+1 -1 -3 0 +MIN+1 -1 3 715827882/MIN+1/-4 +MIN+1 -1 17 126322568/MIN+1/-8 +MIN+1 -1 127 16909321/MIN+1/-7 +MIN+1 -1 MIN+1 0 +MIN+1 -1 MAX 1/MIN+1/MIN+1 +MIN+1 -1 MIN 0 +MIN+1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 1 -1 0 +MIN+1 1 1 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -2 0 +MIN+1 1 2 1073741824/MIN+1/-1 +MIN+1 1 -3 0 +MIN+1 1 3 715827883/MIN+1/-1 +MIN+1 1 17 126322568/MIN+1/-8 +MIN+1 1 127 16909321/MIN+1/-7 +MIN+1 1 MIN+1 0 +MIN+1 1 MAX 2/MIN+1/0 +MIN+1 1 MIN 0 +MIN+1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 3 -1 0 +MIN+1 3 1 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -2 0 +MIN+1 3 2 1073741825/MIN+1/1 +MIN+1 3 -3 0 +MIN+1 3 3 715827884/MIN+1/2 +MIN+1 3 17 126322568/MIN+1/-8 +MIN+1 3 127 16909321/MIN+1/-7 +MIN+1 3 MIN+1 0 +MIN+1 3 MAX 2/MIN+1/0 +MIN+1 3 MIN 0 +MIN+1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MIN+1 -1 0 +MIN+1 MIN+1 1 0 +MIN+1 MIN+1 -2 0 +MIN+1 MIN+1 2 0 +MIN+1 MIN+1 -3 0 +MIN+1 MIN+1 3 0 +MIN+1 MIN+1 17 0 +MIN+1 MIN+1 127 0 +MIN+1 MIN+1 MIN+1 0 +MIN+1 MIN+1 MAX 0 +MIN+1 MIN+1 MIN 0 +MIN+1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MAX -1 0 +MIN+1 MAX 1 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -2 0 +MIN+1 MAX 2 MAX/MIN+1/MAX-2 +MIN+1 MAX -3 0 +MIN+1 MAX 3 1431655765/MIN+1/MAX-2 +MIN+1 MAX 17 252645135/MIN+1/MAX-16 +MIN+1 MAX 127 33818641/MIN+1/MAX-14 +MIN+1 MAX MIN+1 0 +MIN+1 MAX MAX 2/MIN+1/0 +MIN+1 MAX MIN 0 +MIN+1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MIN -1 1/MIN+1/MIN+1 +MIN+1 MIN 1 0 +MIN+1 MIN -2 1/MIN+1/MIN+1 +MIN+1 MIN 2 0 +MIN+1 MIN -3 1/MIN+1/MIN+1 +MIN+1 MIN 3 0 +MIN+1 MIN 17 0 +MIN+1 MIN 127 0 +MIN+1 MIN MIN+1 1/MIN+1/MIN+1 +MIN+1 MIN MAX 0 +MIN+1 MIN MIN 1/MIN+1/MIN+1 + +start end step length/first/last +----------------------------------------- +MAX 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 0 -1 MAX/MAX/1 +MAX 0 1 0 +MAX 0 -2 1073741824/MAX/1 +MAX 0 2 0 +MAX 0 -3 715827883/MAX/1 +MAX 0 3 0 +MAX 0 17 0 +MAX 0 127 0 +MAX 0 MIN+1 1/MAX/MAX +MAX 0 MAX 0 +MAX 0 MIN 1/MAX/MAX +MAX -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX -1 -1 --- + java.lang.IllegalArgumentException: 2147483647 until -1 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX -1 1 0 +MAX -1 -2 1073741824/MAX/1 +MAX -1 2 0 +MAX -1 -3 715827883/MAX/1 +MAX -1 3 0 +MAX -1 17 0 +MAX -1 127 0 +MAX -1 MIN+1 2/MAX/0 +MAX -1 MAX 0 +MAX -1 MIN 1/MAX/MAX +MAX 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 1 -1 MAX-1/MAX/2 +MAX 1 1 0 +MAX 1 -2 1073741823/MAX/3 +MAX 1 2 0 +MAX 1 -3 715827882/MAX/4 +MAX 1 3 0 +MAX 1 17 0 +MAX 1 127 0 +MAX 1 MIN+1 1/MAX/MAX +MAX 1 MAX 0 +MAX 1 MIN 1/MAX/MAX +MAX 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 3 -1 MAX-3/MAX/4 +MAX 3 1 0 +MAX 3 -2 1073741822/MAX/5 +MAX 3 2 0 +MAX 3 -3 715827882/MAX/4 +MAX 3 3 0 +MAX 3 17 0 +MAX 3 127 0 +MAX 3 MIN+1 1/MAX/MAX +MAX 3 MAX 0 +MAX 3 MIN 1/MAX/MAX +MAX MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MIN+1 -1 --- + java.lang.IllegalArgumentException: 2147483647 until -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX MIN+1 1 0 +MAX MIN+1 -2 MAX/MAX/MIN+3 +MAX MIN+1 2 0 +MAX MIN+1 -3 1431655765/MAX/MIN+3 +MAX MIN+1 3 0 +MAX MIN+1 17 0 +MAX MIN+1 127 0 +MAX MIN+1 MIN+1 2/MAX/0 +MAX MIN+1 MAX 0 +MAX MIN+1 MIN 2/MAX/-1 +MAX MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MAX -1 0 +MAX MAX 1 0 +MAX MAX -2 0 +MAX MAX 2 0 +MAX MAX -3 0 +MAX MAX 3 0 +MAX MAX 17 0 +MAX MAX 127 0 +MAX MAX MIN+1 0 +MAX MAX MAX 0 +MAX MAX MIN 0 +MAX MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MIN -1 --- + java.lang.IllegalArgumentException: 2147483647 until -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX MIN 1 0 +MAX MIN -2 --- + java.lang.IllegalArgumentException: 2147483647 until -2147483648 by -2: seqs cannot contain more than Int.MaxValue elements. +MAX MIN 2 0 +MAX MIN -3 1431655765/MAX/MIN+3 +MAX MIN 3 0 +MAX MIN 17 0 +MAX MIN 127 0 +MAX MIN MIN+1 3/MAX/MIN+1 +MAX MIN MAX 0 +MAX MIN MIN 2/MAX/-1 + +start end step length/first/last +----------------------------------------- +MIN 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 0 -1 0 +MIN 0 1 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -2 0 +MIN 0 2 1073741824/MIN/-2 +MIN 0 -3 0 +MIN 0 3 715827883/MIN/-2 +MIN 0 17 126322568/MIN/-9 +MIN 0 127 16909321/MIN/-8 +MIN 0 MIN+1 0 +MIN 0 MAX 2/MIN/-1 +MIN 0 MIN 0 +MIN -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN -1 -1 0 +MIN -1 1 MAX/MIN/-2 +MIN -1 -2 0 +MIN -1 2 1073741824/MIN/-2 +MIN -1 -3 0 +MIN -1 3 715827883/MIN/-2 +MIN -1 17 126322568/MIN/-9 +MIN -1 127 16909321/MIN/-8 +MIN -1 MIN+1 0 +MIN -1 MAX 1/MIN/MIN +MIN -1 MIN 0 +MIN 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 1 -1 0 +MIN 1 1 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -2 0 +MIN 1 2 1073741825/MIN/0 +MIN 1 -3 0 +MIN 1 3 715827883/MIN/-2 +MIN 1 17 126322568/MIN/-9 +MIN 1 127 16909321/MIN/-8 +MIN 1 MIN+1 0 +MIN 1 MAX 2/MIN/-1 +MIN 1 MIN 0 +MIN 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 3 -1 0 +MIN 3 1 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -2 0 +MIN 3 2 1073741826/MIN/2 +MIN 3 -3 0 +MIN 3 3 715827884/MIN/1 +MIN 3 17 126322568/MIN/-9 +MIN 3 127 16909321/MIN/-8 +MIN 3 MIN+1 0 +MIN 3 MAX 2/MIN/-1 +MIN 3 MIN 0 +MIN MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MIN+1 -1 0 +MIN MIN+1 1 1/MIN/MIN +MIN MIN+1 -2 0 +MIN MIN+1 2 1/MIN/MIN +MIN MIN+1 -3 0 +MIN MIN+1 3 1/MIN/MIN +MIN MIN+1 17 1/MIN/MIN +MIN MIN+1 127 1/MIN/MIN +MIN MIN+1 MIN+1 0 +MIN MIN+1 MAX 1/MIN/MIN +MIN MIN+1 MIN 0 +MIN MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MAX -1 0 +MIN MAX 1 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -2 0 +MIN MAX 2 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 2: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -3 0 +MIN MAX 3 1431655765/MIN/MAX-3 +MIN MAX 17 252645135/MIN/MAX-17 +MIN MAX 127 33818641/MIN/MAX-15 +MIN MAX MIN+1 0 +MIN MAX MAX 3/MIN/MAX-1 +MIN MAX MIN 0 +MIN MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MIN -1 0 +MIN MIN 1 0 +MIN MIN -2 0 +MIN MIN 2 0 +MIN MIN -3 0 +MIN MIN 3 0 +MIN MIN 17 0 +MIN MIN 127 0 +MIN MIN MIN+1 0 +MIN MIN MAX 0 +MIN MIN MIN 0 + +>>> start to end <<< + +start end step length/first/last +----------------------------------------- +0 0 0 1/0/0 +0 0 -1 1/0/0 +0 0 1 1/0/0 +0 0 -2 1/0/0 +0 0 2 1/0/0 +0 0 -3 1/0/0 +0 0 3 1/0/0 +0 0 17 1/0/0 +0 0 127 1/0/0 +0 0 MIN+1 1/0/0 +0 0 MAX 1/0/0 +0 0 MIN 1/0/0 +0 -1 0 0 +0 -1 -1 0 +0 -1 1 0 +0 -1 -2 0 +0 -1 2 0 +0 -1 -3 0 +0 -1 3 0 +0 -1 17 0 +0 -1 127 0 +0 -1 MIN+1 0 +0 -1 MAX 0 +0 -1 MIN 0 +0 1 0 2/0/1 +0 1 -1 2/0/1 +0 1 1 2/0/1 +0 1 -2 2/0/1 +0 1 2 2/0/1 +0 1 -3 2/0/1 +0 1 3 2/0/1 +0 1 17 2/0/1 +0 1 127 2/0/1 +0 1 MIN+1 2/0/1 +0 1 MAX 2/0/1 +0 1 MIN 2/0/1 +0 3 0 4/0/3 +0 3 -1 4/0/3 +0 3 1 4/0/3 +0 3 -2 4/0/3 +0 3 2 4/0/3 +0 3 -3 4/0/3 +0 3 3 4/0/3 +0 3 17 4/0/3 +0 3 127 4/0/3 +0 3 MIN+1 4/0/3 +0 3 MAX 4/0/3 +0 3 MIN 4/0/3 +0 MIN+1 0 0 +0 MIN+1 -1 0 +0 MIN+1 1 0 +0 MIN+1 -2 0 +0 MIN+1 2 0 +0 MIN+1 -3 0 +0 MIN+1 3 0 +0 MIN+1 17 0 +0 MIN+1 127 0 +0 MIN+1 MIN+1 0 +0 MIN+1 MAX 0 +0 MIN+1 MIN 0 +0 MAX 0 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX -1 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX 1 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX -2 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX 2 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX -3 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX 3 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX 17 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX 127 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX MIN+1 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX MAX --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX MIN --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MIN 0 0 +0 MIN -1 0 +0 MIN 1 0 +0 MIN -2 0 +0 MIN 2 0 +0 MIN -3 0 +0 MIN 3 0 +0 MIN 17 0 +0 MIN 127 0 +0 MIN MIN+1 0 +0 MIN MAX 0 +0 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +-1 0 0 2/-1/0 +-1 0 -1 2/-1/0 +-1 0 1 2/-1/0 +-1 0 -2 2/-1/0 +-1 0 2 2/-1/0 +-1 0 -3 2/-1/0 +-1 0 3 2/-1/0 +-1 0 17 2/-1/0 +-1 0 127 2/-1/0 +-1 0 MIN+1 2/-1/0 +-1 0 MAX 2/-1/0 +-1 0 MIN 2/-1/0 +-1 -1 0 1/-1/-1 +-1 -1 -1 1/-1/-1 +-1 -1 1 1/-1/-1 +-1 -1 -2 1/-1/-1 +-1 -1 2 1/-1/-1 +-1 -1 -3 1/-1/-1 +-1 -1 3 1/-1/-1 +-1 -1 17 1/-1/-1 +-1 -1 127 1/-1/-1 +-1 -1 MIN+1 1/-1/-1 +-1 -1 MAX 1/-1/-1 +-1 -1 MIN 1/-1/-1 +-1 1 0 3/-1/1 +-1 1 -1 3/-1/1 +-1 1 1 3/-1/1 +-1 1 -2 3/-1/1 +-1 1 2 3/-1/1 +-1 1 -3 3/-1/1 +-1 1 3 3/-1/1 +-1 1 17 3/-1/1 +-1 1 127 3/-1/1 +-1 1 MIN+1 3/-1/1 +-1 1 MAX 3/-1/1 +-1 1 MIN 3/-1/1 +-1 3 0 5/-1/3 +-1 3 -1 5/-1/3 +-1 3 1 5/-1/3 +-1 3 -2 5/-1/3 +-1 3 2 5/-1/3 +-1 3 -3 5/-1/3 +-1 3 3 5/-1/3 +-1 3 17 5/-1/3 +-1 3 127 5/-1/3 +-1 3 MIN+1 5/-1/3 +-1 3 MAX 5/-1/3 +-1 3 MIN 5/-1/3 +-1 MIN+1 0 0 +-1 MIN+1 -1 0 +-1 MIN+1 1 0 +-1 MIN+1 -2 0 +-1 MIN+1 2 0 +-1 MIN+1 -3 0 +-1 MIN+1 3 0 +-1 MIN+1 17 0 +-1 MIN+1 127 0 +-1 MIN+1 MIN+1 0 +-1 MIN+1 MAX 0 +-1 MIN+1 MIN 0 +-1 MAX 0 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -1 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 1 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -2 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 2 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -3 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 3 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 17 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 127 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX MIN+1 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX MAX --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX MIN --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MIN 0 0 +-1 MIN -1 0 +-1 MIN 1 0 +-1 MIN -2 0 +-1 MIN 2 0 +-1 MIN -3 0 +-1 MIN 3 0 +-1 MIN 17 0 +-1 MIN 127 0 +-1 MIN MIN+1 0 +-1 MIN MAX 0 +-1 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +1 0 0 0 +1 0 -1 0 +1 0 1 0 +1 0 -2 0 +1 0 2 0 +1 0 -3 0 +1 0 3 0 +1 0 17 0 +1 0 127 0 +1 0 MIN+1 0 +1 0 MAX 0 +1 0 MIN 0 +1 -1 0 0 +1 -1 -1 0 +1 -1 1 0 +1 -1 -2 0 +1 -1 2 0 +1 -1 -3 0 +1 -1 3 0 +1 -1 17 0 +1 -1 127 0 +1 -1 MIN+1 0 +1 -1 MAX 0 +1 -1 MIN 0 +1 1 0 1/1/1 +1 1 -1 1/1/1 +1 1 1 1/1/1 +1 1 -2 1/1/1 +1 1 2 1/1/1 +1 1 -3 1/1/1 +1 1 3 1/1/1 +1 1 17 1/1/1 +1 1 127 1/1/1 +1 1 MIN+1 1/1/1 +1 1 MAX 1/1/1 +1 1 MIN 1/1/1 +1 3 0 3/1/3 +1 3 -1 3/1/3 +1 3 1 3/1/3 +1 3 -2 3/1/3 +1 3 2 3/1/3 +1 3 -3 3/1/3 +1 3 3 3/1/3 +1 3 17 3/1/3 +1 3 127 3/1/3 +1 3 MIN+1 3/1/3 +1 3 MAX 3/1/3 +1 3 MIN 3/1/3 +1 MIN+1 0 0 +1 MIN+1 -1 0 +1 MIN+1 1 0 +1 MIN+1 -2 0 +1 MIN+1 2 0 +1 MIN+1 -3 0 +1 MIN+1 3 0 +1 MIN+1 17 0 +1 MIN+1 127 0 +1 MIN+1 MIN+1 0 +1 MIN+1 MAX 0 +1 MIN+1 MIN 0 +1 MAX 0 MAX/1/MAX +1 MAX -1 MAX/1/MAX +1 MAX 1 MAX/1/MAX +1 MAX -2 MAX/1/MAX +1 MAX 2 MAX/1/MAX +1 MAX -3 MAX/1/MAX +1 MAX 3 MAX/1/MAX +1 MAX 17 MAX/1/MAX +1 MAX 127 MAX/1/MAX +1 MAX MIN+1 MAX/1/MAX +1 MAX MAX MAX/1/MAX +1 MAX MIN MAX/1/MAX +1 MIN 0 0 +1 MIN -1 0 +1 MIN 1 0 +1 MIN -2 0 +1 MIN 2 0 +1 MIN -3 0 +1 MIN 3 0 +1 MIN 17 0 +1 MIN 127 0 +1 MIN MIN+1 0 +1 MIN MAX 0 +1 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +3 0 0 0 +3 0 -1 0 +3 0 1 0 +3 0 -2 0 +3 0 2 0 +3 0 -3 0 +3 0 3 0 +3 0 17 0 +3 0 127 0 +3 0 MIN+1 0 +3 0 MAX 0 +3 0 MIN 0 +3 -1 0 0 +3 -1 -1 0 +3 -1 1 0 +3 -1 -2 0 +3 -1 2 0 +3 -1 -3 0 +3 -1 3 0 +3 -1 17 0 +3 -1 127 0 +3 -1 MIN+1 0 +3 -1 MAX 0 +3 -1 MIN 0 +3 1 0 0 +3 1 -1 0 +3 1 1 0 +3 1 -2 0 +3 1 2 0 +3 1 -3 0 +3 1 3 0 +3 1 17 0 +3 1 127 0 +3 1 MIN+1 0 +3 1 MAX 0 +3 1 MIN 0 +3 3 0 1/3/3 +3 3 -1 1/3/3 +3 3 1 1/3/3 +3 3 -2 1/3/3 +3 3 2 1/3/3 +3 3 -3 1/3/3 +3 3 3 1/3/3 +3 3 17 1/3/3 +3 3 127 1/3/3 +3 3 MIN+1 1/3/3 +3 3 MAX 1/3/3 +3 3 MIN 1/3/3 +3 MIN+1 0 0 +3 MIN+1 -1 0 +3 MIN+1 1 0 +3 MIN+1 -2 0 +3 MIN+1 2 0 +3 MIN+1 -3 0 +3 MIN+1 3 0 +3 MIN+1 17 0 +3 MIN+1 127 0 +3 MIN+1 MIN+1 0 +3 MIN+1 MAX 0 +3 MIN+1 MIN 0 +3 MAX 0 MAX-2/3/MAX +3 MAX -1 MAX-2/3/MAX +3 MAX 1 MAX-2/3/MAX +3 MAX -2 MAX-2/3/MAX +3 MAX 2 MAX-2/3/MAX +3 MAX -3 MAX-2/3/MAX +3 MAX 3 MAX-2/3/MAX +3 MAX 17 MAX-2/3/MAX +3 MAX 127 MAX-2/3/MAX +3 MAX MIN+1 MAX-2/3/MAX +3 MAX MAX MAX-2/3/MAX +3 MAX MIN MAX-2/3/MAX +3 MIN 0 0 +3 MIN -1 0 +3 MIN 1 0 +3 MIN -2 0 +3 MIN 2 0 +3 MIN -3 0 +3 MIN 3 0 +3 MIN 17 0 +3 MIN 127 0 +3 MIN MIN+1 0 +3 MIN MAX 0 +3 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +MIN+1 0 0 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 -1 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 1 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 -2 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 2 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 -3 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 3 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 17 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 127 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 MIN+1 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 MAX --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 MIN --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 -1 0 MAX/MIN+1/-1 +MIN+1 -1 -1 MAX/MIN+1/-1 +MIN+1 -1 1 MAX/MIN+1/-1 +MIN+1 -1 -2 MAX/MIN+1/-1 +MIN+1 -1 2 MAX/MIN+1/-1 +MIN+1 -1 -3 MAX/MIN+1/-1 +MIN+1 -1 3 MAX/MIN+1/-1 +MIN+1 -1 17 MAX/MIN+1/-1 +MIN+1 -1 127 MAX/MIN+1/-1 +MIN+1 -1 MIN+1 MAX/MIN+1/-1 +MIN+1 -1 MAX MAX/MIN+1/-1 +MIN+1 -1 MIN MAX/MIN+1/-1 +MIN+1 1 0 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -1 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 1 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -2 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 2 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -3 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 3 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 17 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 127 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 MIN+1 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 MAX --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 MIN --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 0 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -1 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 1 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -2 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 2 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -3 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 3 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 17 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 127 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 MIN+1 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 MAX --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 MIN --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MIN+1 0 1/MIN+1/MIN+1 +MIN+1 MIN+1 -1 1/MIN+1/MIN+1 +MIN+1 MIN+1 1 1/MIN+1/MIN+1 +MIN+1 MIN+1 -2 1/MIN+1/MIN+1 +MIN+1 MIN+1 2 1/MIN+1/MIN+1 +MIN+1 MIN+1 -3 1/MIN+1/MIN+1 +MIN+1 MIN+1 3 1/MIN+1/MIN+1 +MIN+1 MIN+1 17 1/MIN+1/MIN+1 +MIN+1 MIN+1 127 1/MIN+1/MIN+1 +MIN+1 MIN+1 MIN+1 1/MIN+1/MIN+1 +MIN+1 MIN+1 MAX 1/MIN+1/MIN+1 +MIN+1 MIN+1 MIN 1/MIN+1/MIN+1 +MIN+1 MAX 0 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -1 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 1 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -2 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 2 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -3 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 3 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 17 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 127 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX MIN+1 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX MAX --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX MIN --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MIN 0 0 +MIN+1 MIN -1 0 +MIN+1 MIN 1 0 +MIN+1 MIN -2 0 +MIN+1 MIN 2 0 +MIN+1 MIN -3 0 +MIN+1 MIN 3 0 +MIN+1 MIN 17 0 +MIN+1 MIN 127 0 +MIN+1 MIN MIN+1 0 +MIN+1 MIN MAX 0 +MIN+1 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +MAX 0 0 0 +MAX 0 -1 0 +MAX 0 1 0 +MAX 0 -2 0 +MAX 0 2 0 +MAX 0 -3 0 +MAX 0 3 0 +MAX 0 17 0 +MAX 0 127 0 +MAX 0 MIN+1 0 +MAX 0 MAX 0 +MAX 0 MIN 0 +MAX -1 0 0 +MAX -1 -1 0 +MAX -1 1 0 +MAX -1 -2 0 +MAX -1 2 0 +MAX -1 -3 0 +MAX -1 3 0 +MAX -1 17 0 +MAX -1 127 0 +MAX -1 MIN+1 0 +MAX -1 MAX 0 +MAX -1 MIN 0 +MAX 1 0 0 +MAX 1 -1 0 +MAX 1 1 0 +MAX 1 -2 0 +MAX 1 2 0 +MAX 1 -3 0 +MAX 1 3 0 +MAX 1 17 0 +MAX 1 127 0 +MAX 1 MIN+1 0 +MAX 1 MAX 0 +MAX 1 MIN 0 +MAX 3 0 0 +MAX 3 -1 0 +MAX 3 1 0 +MAX 3 -2 0 +MAX 3 2 0 +MAX 3 -3 0 +MAX 3 3 0 +MAX 3 17 0 +MAX 3 127 0 +MAX 3 MIN+1 0 +MAX 3 MAX 0 +MAX 3 MIN 0 +MAX MIN+1 0 0 +MAX MIN+1 -1 0 +MAX MIN+1 1 0 +MAX MIN+1 -2 0 +MAX MIN+1 2 0 +MAX MIN+1 -3 0 +MAX MIN+1 3 0 +MAX MIN+1 17 0 +MAX MIN+1 127 0 +MAX MIN+1 MIN+1 0 +MAX MIN+1 MAX 0 +MAX MIN+1 MIN 0 +MAX MAX 0 1/MAX/MAX +MAX MAX -1 1/MAX/MAX +MAX MAX 1 1/MAX/MAX +MAX MAX -2 1/MAX/MAX +MAX MAX 2 1/MAX/MAX +MAX MAX -3 1/MAX/MAX +MAX MAX 3 1/MAX/MAX +MAX MAX 17 1/MAX/MAX +MAX MAX 127 1/MAX/MAX +MAX MAX MIN+1 1/MAX/MAX +MAX MAX MAX 1/MAX/MAX +MAX MAX MIN 1/MAX/MAX +MAX MIN 0 0 +MAX MIN -1 0 +MAX MIN 1 0 +MAX MIN -2 0 +MAX MIN 2 0 +MAX MIN -3 0 +MAX MIN 3 0 +MAX MIN 17 0 +MAX MIN 127 0 +MAX MIN MIN+1 0 +MAX MIN MAX 0 +MAX MIN MIN 0 + +start end step length/first/last +----------------------------------------- +MIN 0 0 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -1 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 1 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -2 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 2 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -3 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 3 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 17 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 127 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 MAX --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 MIN --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 0 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 -1 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 1 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 -2 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 2 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 -3 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 3 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 17 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 127 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 MAX --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 MIN --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 0 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -1 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 1 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -2 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 2 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -3 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 3 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 17 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 127 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 MAX --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 MIN --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 0 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -1 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 1 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -2 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 2 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -3 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 3 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 17 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 127 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 MAX --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 MIN --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MIN+1 0 2/MIN/MIN+1 +MIN MIN+1 -1 2/MIN/MIN+1 +MIN MIN+1 1 2/MIN/MIN+1 +MIN MIN+1 -2 2/MIN/MIN+1 +MIN MIN+1 2 2/MIN/MIN+1 +MIN MIN+1 -3 2/MIN/MIN+1 +MIN MIN+1 3 2/MIN/MIN+1 +MIN MIN+1 17 2/MIN/MIN+1 +MIN MIN+1 127 2/MIN/MIN+1 +MIN MIN+1 MIN+1 2/MIN/MIN+1 +MIN MIN+1 MAX 2/MIN/MIN+1 +MIN MIN+1 MIN 2/MIN/MIN+1 +MIN MAX 0 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -1 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 1 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -2 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 2 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -3 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 3 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 17 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 127 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX MAX --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX MIN --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MIN 0 1/MIN/MIN +MIN MIN -1 1/MIN/MIN +MIN MIN 1 1/MIN/MIN +MIN MIN -2 1/MIN/MIN +MIN MIN 2 1/MIN/MIN +MIN MIN -3 1/MIN/MIN +MIN MIN 3 1/MIN/MIN +MIN MIN 17 1/MIN/MIN +MIN MIN 127 1/MIN/MIN +MIN MIN MIN+1 1/MIN/MIN +MIN MIN MAX 1/MIN/MIN +MIN MIN MIN 1/MIN/MIN + +>>> start to end by step <<< + +start end step length/first/last +----------------------------------------- +0 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 0 -1 1/0/0 +0 0 1 1/0/0 +0 0 -2 1/0/0 +0 0 2 1/0/0 +0 0 -3 1/0/0 +0 0 3 1/0/0 +0 0 17 1/0/0 +0 0 127 1/0/0 +0 0 MIN+1 1/0/0 +0 0 MAX 1/0/0 +0 0 MIN 1/0/0 +0 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 -1 -1 2/0/-1 +0 -1 1 0 +0 -1 -2 1/0/0 +0 -1 2 0 +0 -1 -3 1/0/0 +0 -1 3 0 +0 -1 17 0 +0 -1 127 0 +0 -1 MIN+1 1/0/0 +0 -1 MAX 0 +0 -1 MIN 1/0/0 +0 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 1 -1 0 +0 1 1 2/0/1 +0 1 -2 0 +0 1 2 1/0/0 +0 1 -3 0 +0 1 3 1/0/0 +0 1 17 1/0/0 +0 1 127 1/0/0 +0 1 MIN+1 0 +0 1 MAX 1/0/0 +0 1 MIN 0 +0 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 3 -1 0 +0 3 1 4/0/3 +0 3 -2 0 +0 3 2 2/0/2 +0 3 -3 0 +0 3 3 2/0/3 +0 3 17 1/0/0 +0 3 127 1/0/0 +0 3 MIN+1 0 +0 3 MAX 1/0/0 +0 3 MIN 0 +0 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MIN+1 -1 --- + java.lang.IllegalArgumentException: 0 to -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +0 MIN+1 1 0 +0 MIN+1 -2 1073741824/0/MIN+2 +0 MIN+1 2 0 +0 MIN+1 -3 715827883/0/MIN+2 +0 MIN+1 3 0 +0 MIN+1 17 0 +0 MIN+1 127 0 +0 MIN+1 MIN+1 2/0/MIN+1 +0 MIN+1 MAX 0 +0 MIN+1 MIN 1/0/0 +0 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MAX -1 0 +0 MAX 1 --- + java.lang.IllegalArgumentException: 0 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +0 MAX -2 0 +0 MAX 2 1073741824/0/MAX-1 +0 MAX -3 0 +0 MAX 3 715827883/0/MAX-1 +0 MAX 17 126322568/0/MAX-8 +0 MAX 127 16909321/0/MAX-7 +0 MAX MIN+1 0 +0 MAX MAX 2/0/MAX +0 MAX MIN 0 +0 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MIN -1 --- + java.lang.IllegalArgumentException: 0 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +0 MIN 1 0 +0 MIN -2 1073741825/0/MIN +0 MIN 2 0 +0 MIN -3 715827883/0/MIN+2 +0 MIN 3 0 +0 MIN 17 0 +0 MIN 127 0 +0 MIN MIN+1 2/0/MIN+1 +0 MIN MAX 0 +0 MIN MIN 2/0/MIN + +start end step length/first/last +----------------------------------------- +-1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 0 -1 0 +-1 0 1 2/-1/0 +-1 0 -2 0 +-1 0 2 1/-1/-1 +-1 0 -3 0 +-1 0 3 1/-1/-1 +-1 0 17 1/-1/-1 +-1 0 127 1/-1/-1 +-1 0 MIN+1 0 +-1 0 MAX 1/-1/-1 +-1 0 MIN 0 +-1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 -1 -1 1/-1/-1 +-1 -1 1 1/-1/-1 +-1 -1 -2 1/-1/-1 +-1 -1 2 1/-1/-1 +-1 -1 -3 1/-1/-1 +-1 -1 3 1/-1/-1 +-1 -1 17 1/-1/-1 +-1 -1 127 1/-1/-1 +-1 -1 MIN+1 1/-1/-1 +-1 -1 MAX 1/-1/-1 +-1 -1 MIN 1/-1/-1 +-1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 1 -1 0 +-1 1 1 3/-1/1 +-1 1 -2 0 +-1 1 2 2/-1/1 +-1 1 -3 0 +-1 1 3 1/-1/-1 +-1 1 17 1/-1/-1 +-1 1 127 1/-1/-1 +-1 1 MIN+1 0 +-1 1 MAX 1/-1/-1 +-1 1 MIN 0 +-1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 3 -1 0 +-1 3 1 5/-1/3 +-1 3 -2 0 +-1 3 2 3/-1/3 +-1 3 -3 0 +-1 3 3 2/-1/2 +-1 3 17 1/-1/-1 +-1 3 127 1/-1/-1 +-1 3 MIN+1 0 +-1 3 MAX 1/-1/-1 +-1 3 MIN 0 +-1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MIN+1 -1 MAX/-1/MIN+1 +-1 MIN+1 1 0 +-1 MIN+1 -2 1073741824/-1/MIN+1 +-1 MIN+1 2 0 +-1 MIN+1 -3 715827883/-1/MIN+1 +-1 MIN+1 3 0 +-1 MIN+1 17 0 +-1 MIN+1 127 0 +-1 MIN+1 MIN+1 1/-1/-1 +-1 MIN+1 MAX 0 +-1 MIN+1 MIN 1/-1/-1 +-1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MAX -1 0 +-1 MAX 1 --- + java.lang.IllegalArgumentException: -1 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -2 0 +-1 MAX 2 1073741825/-1/MAX +-1 MAX -3 0 +-1 MAX 3 715827883/-1/MAX-2 +-1 MAX 17 126322568/-1/MAX-9 +-1 MAX 127 16909321/-1/MAX-8 +-1 MAX MIN+1 0 +-1 MAX MAX 2/-1/MAX-1 +-1 MAX MIN 0 +-1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MIN -1 --- + java.lang.IllegalArgumentException: -1 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +-1 MIN 1 0 +-1 MIN -2 1073741824/-1/MIN+1 +-1 MIN 2 0 +-1 MIN -3 715827883/-1/MIN+1 +-1 MIN 3 0 +-1 MIN 17 0 +-1 MIN 127 0 +-1 MIN MIN+1 2/-1/MIN +-1 MIN MAX 0 +-1 MIN MIN 1/-1/-1 + +start end step length/first/last +----------------------------------------- +1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 0 -1 2/1/0 +1 0 1 0 +1 0 -2 1/1/1 +1 0 2 0 +1 0 -3 1/1/1 +1 0 3 0 +1 0 17 0 +1 0 127 0 +1 0 MIN+1 1/1/1 +1 0 MAX 0 +1 0 MIN 1/1/1 +1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 -1 -1 3/1/-1 +1 -1 1 0 +1 -1 -2 2/1/-1 +1 -1 2 0 +1 -1 -3 1/1/1 +1 -1 3 0 +1 -1 17 0 +1 -1 127 0 +1 -1 MIN+1 1/1/1 +1 -1 MAX 0 +1 -1 MIN 1/1/1 +1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 1 -1 1/1/1 +1 1 1 1/1/1 +1 1 -2 1/1/1 +1 1 2 1/1/1 +1 1 -3 1/1/1 +1 1 3 1/1/1 +1 1 17 1/1/1 +1 1 127 1/1/1 +1 1 MIN+1 1/1/1 +1 1 MAX 1/1/1 +1 1 MIN 1/1/1 +1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 3 -1 0 +1 3 1 3/1/3 +1 3 -2 0 +1 3 2 2/1/3 +1 3 -3 0 +1 3 3 1/1/1 +1 3 17 1/1/1 +1 3 127 1/1/1 +1 3 MIN+1 0 +1 3 MAX 1/1/1 +1 3 MIN 0 +1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MIN+1 -1 --- + java.lang.IllegalArgumentException: 1 to -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +1 MIN+1 1 0 +1 MIN+1 -2 1073741825/1/MIN+1 +1 MIN+1 2 0 +1 MIN+1 -3 715827883/1/MIN+3 +1 MIN+1 3 0 +1 MIN+1 17 0 +1 MIN+1 127 0 +1 MIN+1 MIN+1 2/1/MIN+2 +1 MIN+1 MAX 0 +1 MIN+1 MIN 2/1/MIN+1 +1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MAX -1 0 +1 MAX 1 MAX/1/MAX +1 MAX -2 0 +1 MAX 2 1073741824/1/MAX +1 MAX -3 0 +1 MAX 3 715827883/1/MAX +1 MAX 17 126322568/1/MAX-7 +1 MAX 127 16909321/1/MAX-6 +1 MAX MIN+1 0 +1 MAX MAX 1/1/1 +1 MAX MIN 0 +1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MIN -1 --- + java.lang.IllegalArgumentException: 1 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +1 MIN 1 0 +1 MIN -2 1073741825/1/MIN+1 +1 MIN 2 0 +1 MIN -3 715827884/1/MIN +1 MIN 3 0 +1 MIN 17 0 +1 MIN 127 0 +1 MIN MIN+1 2/1/MIN+2 +1 MIN MAX 0 +1 MIN MIN 2/1/MIN+1 + +start end step length/first/last +----------------------------------------- +3 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 0 -1 4/3/0 +3 0 1 0 +3 0 -2 2/3/1 +3 0 2 0 +3 0 -3 2/3/0 +3 0 3 0 +3 0 17 0 +3 0 127 0 +3 0 MIN+1 1/3/3 +3 0 MAX 0 +3 0 MIN 1/3/3 +3 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 -1 -1 5/3/-1 +3 -1 1 0 +3 -1 -2 3/3/-1 +3 -1 2 0 +3 -1 -3 2/3/0 +3 -1 3 0 +3 -1 17 0 +3 -1 127 0 +3 -1 MIN+1 1/3/3 +3 -1 MAX 0 +3 -1 MIN 1/3/3 +3 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 1 -1 3/3/1 +3 1 1 0 +3 1 -2 2/3/1 +3 1 2 0 +3 1 -3 1/3/3 +3 1 3 0 +3 1 17 0 +3 1 127 0 +3 1 MIN+1 1/3/3 +3 1 MAX 0 +3 1 MIN 1/3/3 +3 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 3 -1 1/3/3 +3 3 1 1/3/3 +3 3 -2 1/3/3 +3 3 2 1/3/3 +3 3 -3 1/3/3 +3 3 3 1/3/3 +3 3 17 1/3/3 +3 3 127 1/3/3 +3 3 MIN+1 1/3/3 +3 3 MAX 1/3/3 +3 3 MIN 1/3/3 +3 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MIN+1 -1 --- + java.lang.IllegalArgumentException: 3 to -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +3 MIN+1 1 0 +3 MIN+1 -2 1073741826/3/MIN+1 +3 MIN+1 2 0 +3 MIN+1 -3 715827884/3/MIN+2 +3 MIN+1 3 0 +3 MIN+1 17 0 +3 MIN+1 127 0 +3 MIN+1 MIN+1 2/3/MIN+4 +3 MIN+1 MAX 0 +3 MIN+1 MIN 2/3/MIN+3 +3 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MAX -1 0 +3 MAX 1 MAX-2/3/MAX +3 MAX -2 0 +3 MAX 2 1073741823/3/MAX +3 MAX -3 0 +3 MAX 3 715827882/3/MAX-1 +3 MAX 17 126322568/3/MAX-5 +3 MAX 127 16909321/3/MAX-4 +3 MAX MIN+1 0 +3 MAX MAX 1/3/3 +3 MAX MIN 0 +3 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MIN -1 --- + java.lang.IllegalArgumentException: 3 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +3 MIN 1 0 +3 MIN -2 1073741826/3/MIN+1 +3 MIN 2 0 +3 MIN -3 715827884/3/MIN+2 +3 MIN 3 0 +3 MIN 17 0 +3 MIN 127 0 +3 MIN MIN+1 2/3/MIN+4 +3 MIN MAX 0 +3 MIN MIN 2/3/MIN+3 + +start end step length/first/last +----------------------------------------- +MIN+1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 0 -1 0 +MIN+1 0 1 --- + java.lang.IllegalArgumentException: -2147483647 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 0 -2 0 +MIN+1 0 2 1073741824/MIN+1/-1 +MIN+1 0 -3 0 +MIN+1 0 3 715827883/MIN+1/-1 +MIN+1 0 17 126322568/MIN+1/-8 +MIN+1 0 127 16909321/MIN+1/-7 +MIN+1 0 MIN+1 0 +MIN+1 0 MAX 2/MIN+1/0 +MIN+1 0 MIN 0 +MIN+1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 -1 -1 0 +MIN+1 -1 1 MAX/MIN+1/-1 +MIN+1 -1 -2 0 +MIN+1 -1 2 1073741824/MIN+1/-1 +MIN+1 -1 -3 0 +MIN+1 -1 3 715827883/MIN+1/-1 +MIN+1 -1 17 126322568/MIN+1/-8 +MIN+1 -1 127 16909321/MIN+1/-7 +MIN+1 -1 MIN+1 0 +MIN+1 -1 MAX 1/MIN+1/MIN+1 +MIN+1 -1 MIN 0 +MIN+1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 1 -1 0 +MIN+1 1 1 --- + java.lang.IllegalArgumentException: -2147483647 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -2 0 +MIN+1 1 2 1073741825/MIN+1/1 +MIN+1 1 -3 0 +MIN+1 1 3 715827883/MIN+1/-1 +MIN+1 1 17 126322568/MIN+1/-8 +MIN+1 1 127 16909321/MIN+1/-7 +MIN+1 1 MIN+1 0 +MIN+1 1 MAX 2/MIN+1/0 +MIN+1 1 MIN 0 +MIN+1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 3 -1 0 +MIN+1 3 1 --- + java.lang.IllegalArgumentException: -2147483647 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -2 0 +MIN+1 3 2 1073741826/MIN+1/3 +MIN+1 3 -3 0 +MIN+1 3 3 715827884/MIN+1/2 +MIN+1 3 17 126322568/MIN+1/-8 +MIN+1 3 127 16909321/MIN+1/-7 +MIN+1 3 MIN+1 0 +MIN+1 3 MAX 2/MIN+1/0 +MIN+1 3 MIN 0 +MIN+1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MIN+1 -1 1/MIN+1/MIN+1 +MIN+1 MIN+1 1 1/MIN+1/MIN+1 +MIN+1 MIN+1 -2 1/MIN+1/MIN+1 +MIN+1 MIN+1 2 1/MIN+1/MIN+1 +MIN+1 MIN+1 -3 1/MIN+1/MIN+1 +MIN+1 MIN+1 3 1/MIN+1/MIN+1 +MIN+1 MIN+1 17 1/MIN+1/MIN+1 +MIN+1 MIN+1 127 1/MIN+1/MIN+1 +MIN+1 MIN+1 MIN+1 1/MIN+1/MIN+1 +MIN+1 MIN+1 MAX 1/MIN+1/MIN+1 +MIN+1 MIN+1 MIN 1/MIN+1/MIN+1 +MIN+1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MAX -1 0 +MIN+1 MAX 1 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -2 0 +MIN+1 MAX 2 --- + java.lang.IllegalArgumentException: -2147483647 to 2147483647 by 2: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -3 0 +MIN+1 MAX 3 1431655765/MIN+1/MAX-2 +MIN+1 MAX 17 252645135/MIN+1/MAX-16 +MIN+1 MAX 127 33818641/MIN+1/MAX-14 +MIN+1 MAX MIN+1 0 +MIN+1 MAX MAX 3/MIN+1/MAX +MIN+1 MAX MIN 0 +MIN+1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MIN -1 2/MIN+1/MIN +MIN+1 MIN 1 0 +MIN+1 MIN -2 1/MIN+1/MIN+1 +MIN+1 MIN 2 0 +MIN+1 MIN -3 1/MIN+1/MIN+1 +MIN+1 MIN 3 0 +MIN+1 MIN 17 0 +MIN+1 MIN 127 0 +MIN+1 MIN MIN+1 1/MIN+1/MIN+1 +MIN+1 MIN MAX 0 +MIN+1 MIN MIN 1/MIN+1/MIN+1 + +start end step length/first/last +----------------------------------------- +MAX 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 0 -1 --- + java.lang.IllegalArgumentException: 2147483647 to 0 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX 0 1 0 +MAX 0 -2 1073741824/MAX/1 +MAX 0 2 0 +MAX 0 -3 715827883/MAX/1 +MAX 0 3 0 +MAX 0 17 0 +MAX 0 127 0 +MAX 0 MIN+1 2/MAX/0 +MAX 0 MAX 0 +MAX 0 MIN 1/MAX/MAX +MAX -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX -1 -1 --- + java.lang.IllegalArgumentException: 2147483647 to -1 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX -1 1 0 +MAX -1 -2 1073741825/MAX/-1 +MAX -1 2 0 +MAX -1 -3 715827883/MAX/1 +MAX -1 3 0 +MAX -1 17 0 +MAX -1 127 0 +MAX -1 MIN+1 2/MAX/0 +MAX -1 MAX 0 +MAX -1 MIN 2/MAX/-1 +MAX 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 1 -1 MAX/MAX/1 +MAX 1 1 0 +MAX 1 -2 1073741824/MAX/1 +MAX 1 2 0 +MAX 1 -3 715827883/MAX/1 +MAX 1 3 0 +MAX 1 17 0 +MAX 1 127 0 +MAX 1 MIN+1 1/MAX/MAX +MAX 1 MAX 0 +MAX 1 MIN 1/MAX/MAX +MAX 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 3 -1 MAX-2/MAX/3 +MAX 3 1 0 +MAX 3 -2 1073741823/MAX/3 +MAX 3 2 0 +MAX 3 -3 715827882/MAX/4 +MAX 3 3 0 +MAX 3 17 0 +MAX 3 127 0 +MAX 3 MIN+1 1/MAX/MAX +MAX 3 MAX 0 +MAX 3 MIN 1/MAX/MAX +MAX MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MIN+1 -1 --- + java.lang.IllegalArgumentException: 2147483647 to -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX MIN+1 1 0 +MAX MIN+1 -2 --- + java.lang.IllegalArgumentException: 2147483647 to -2147483647 by -2: seqs cannot contain more than Int.MaxValue elements. +MAX MIN+1 2 0 +MAX MIN+1 -3 1431655765/MAX/MIN+3 +MAX MIN+1 3 0 +MAX MIN+1 17 0 +MAX MIN+1 127 0 +MAX MIN+1 MIN+1 3/MAX/MIN+1 +MAX MIN+1 MAX 0 +MAX MIN+1 MIN 2/MAX/-1 +MAX MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MAX -1 1/MAX/MAX +MAX MAX 1 1/MAX/MAX +MAX MAX -2 1/MAX/MAX +MAX MAX 2 1/MAX/MAX +MAX MAX -3 1/MAX/MAX +MAX MAX 3 1/MAX/MAX +MAX MAX 17 1/MAX/MAX +MAX MAX 127 1/MAX/MAX +MAX MAX MIN+1 1/MAX/MAX +MAX MAX MAX 1/MAX/MAX +MAX MAX MIN 1/MAX/MAX +MAX MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MIN -1 --- + java.lang.IllegalArgumentException: 2147483647 to -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX MIN 1 0 +MAX MIN -2 --- + java.lang.IllegalArgumentException: 2147483647 to -2147483648 by -2: seqs cannot contain more than Int.MaxValue elements. +MAX MIN 2 0 +MAX MIN -3 1431655766/MAX/MIN +MAX MIN 3 0 +MAX MIN 17 0 +MAX MIN 127 0 +MAX MIN MIN+1 3/MAX/MIN+1 +MAX MIN MAX 0 +MAX MIN MIN 2/MAX/-1 + +start end step length/first/last +----------------------------------------- +MIN 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 0 -1 0 +MIN 0 1 --- + java.lang.IllegalArgumentException: -2147483648 to 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -2 0 +MIN 0 2 1073741825/MIN/0 +MIN 0 -3 0 +MIN 0 3 715827883/MIN/-2 +MIN 0 17 126322568/MIN/-9 +MIN 0 127 16909321/MIN/-8 +MIN 0 MIN+1 0 +MIN 0 MAX 2/MIN/-1 +MIN 0 MIN 0 +MIN -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN -1 -1 0 +MIN -1 1 --- + java.lang.IllegalArgumentException: -2147483648 to -1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 -2 0 +MIN -1 2 1073741824/MIN/-2 +MIN -1 -3 0 +MIN -1 3 715827883/MIN/-2 +MIN -1 17 126322568/MIN/-9 +MIN -1 127 16909321/MIN/-8 +MIN -1 MIN+1 0 +MIN -1 MAX 2/MIN/-1 +MIN -1 MIN 0 +MIN 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 1 -1 0 +MIN 1 1 --- + java.lang.IllegalArgumentException: -2147483648 to 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -2 0 +MIN 1 2 1073741825/MIN/0 +MIN 1 -3 0 +MIN 1 3 715827884/MIN/1 +MIN 1 17 126322568/MIN/-9 +MIN 1 127 16909321/MIN/-8 +MIN 1 MIN+1 0 +MIN 1 MAX 2/MIN/-1 +MIN 1 MIN 0 +MIN 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 3 -1 0 +MIN 3 1 --- + java.lang.IllegalArgumentException: -2147483648 to 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -2 0 +MIN 3 2 1073741826/MIN/2 +MIN 3 -3 0 +MIN 3 3 715827884/MIN/1 +MIN 3 17 126322568/MIN/-9 +MIN 3 127 16909321/MIN/-8 +MIN 3 MIN+1 0 +MIN 3 MAX 2/MIN/-1 +MIN 3 MIN 0 +MIN MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MIN+1 -1 0 +MIN MIN+1 1 2/MIN/MIN+1 +MIN MIN+1 -2 0 +MIN MIN+1 2 1/MIN/MIN +MIN MIN+1 -3 0 +MIN MIN+1 3 1/MIN/MIN +MIN MIN+1 17 1/MIN/MIN +MIN MIN+1 127 1/MIN/MIN +MIN MIN+1 MIN+1 0 +MIN MIN+1 MAX 1/MIN/MIN +MIN MIN+1 MIN 0 +MIN MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MAX -1 0 +MIN MAX 1 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -2 0 +MIN MAX 2 --- + java.lang.IllegalArgumentException: -2147483648 to 2147483647 by 2: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -3 0 +MIN MAX 3 1431655766/MIN/MAX +MIN MAX 17 252645136/MIN/MAX +MIN MAX 127 33818641/MIN/MAX-15 +MIN MAX MIN+1 0 +MIN MAX MAX 3/MIN/MAX-1 +MIN MAX MIN 0 +MIN MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MIN -1 1/MIN/MIN +MIN MIN 1 1/MIN/MIN +MIN MIN -2 1/MIN/MIN +MIN MIN 2 1/MIN/MIN +MIN MIN -3 1/MIN/MIN +MIN MIN 3 1/MIN/MIN +MIN MIN 17 1/MIN/MIN +MIN MIN 127 1/MIN/MIN +MIN MIN MIN+1 1/MIN/MIN +MIN MIN MAX 1/MIN/MIN +MIN MIN MIN 1/MIN/MIN + +>>> start until end <<< + +start end step length/first/last +----------------------------------------- +0 0 0 0 +0 0 -1 0 +0 0 1 0 +0 0 -2 0 +0 0 2 0 +0 0 -3 0 +0 0 3 0 +0 0 17 0 +0 0 127 0 +0 0 MIN+1 0 +0 0 MAX 0 +0 0 MIN 0 +0 -1 0 0 +0 -1 -1 0 +0 -1 1 0 +0 -1 -2 0 +0 -1 2 0 +0 -1 -3 0 +0 -1 3 0 +0 -1 17 0 +0 -1 127 0 +0 -1 MIN+1 0 +0 -1 MAX 0 +0 -1 MIN 0 +0 1 0 1/0/0 +0 1 -1 1/0/0 +0 1 1 1/0/0 +0 1 -2 1/0/0 +0 1 2 1/0/0 +0 1 -3 1/0/0 +0 1 3 1/0/0 +0 1 17 1/0/0 +0 1 127 1/0/0 +0 1 MIN+1 1/0/0 +0 1 MAX 1/0/0 +0 1 MIN 1/0/0 +0 3 0 3/0/2 +0 3 -1 3/0/2 +0 3 1 3/0/2 +0 3 -2 3/0/2 +0 3 2 3/0/2 +0 3 -3 3/0/2 +0 3 3 3/0/2 +0 3 17 3/0/2 +0 3 127 3/0/2 +0 3 MIN+1 3/0/2 +0 3 MAX 3/0/2 +0 3 MIN 3/0/2 +0 MIN+1 0 0 +0 MIN+1 -1 0 +0 MIN+1 1 0 +0 MIN+1 -2 0 +0 MIN+1 2 0 +0 MIN+1 -3 0 +0 MIN+1 3 0 +0 MIN+1 17 0 +0 MIN+1 127 0 +0 MIN+1 MIN+1 0 +0 MIN+1 MAX 0 +0 MIN+1 MIN 0 +0 MAX 0 MAX/0/MAX-1 +0 MAX -1 MAX/0/MAX-1 +0 MAX 1 MAX/0/MAX-1 +0 MAX -2 MAX/0/MAX-1 +0 MAX 2 MAX/0/MAX-1 +0 MAX -3 MAX/0/MAX-1 +0 MAX 3 MAX/0/MAX-1 +0 MAX 17 MAX/0/MAX-1 +0 MAX 127 MAX/0/MAX-1 +0 MAX MIN+1 MAX/0/MAX-1 +0 MAX MAX MAX/0/MAX-1 +0 MAX MIN MAX/0/MAX-1 +0 MIN 0 0 +0 MIN -1 0 +0 MIN 1 0 +0 MIN -2 0 +0 MIN 2 0 +0 MIN -3 0 +0 MIN 3 0 +0 MIN 17 0 +0 MIN 127 0 +0 MIN MIN+1 0 +0 MIN MAX 0 +0 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +-1 0 0 1/-1/-1 +-1 0 -1 1/-1/-1 +-1 0 1 1/-1/-1 +-1 0 -2 1/-1/-1 +-1 0 2 1/-1/-1 +-1 0 -3 1/-1/-1 +-1 0 3 1/-1/-1 +-1 0 17 1/-1/-1 +-1 0 127 1/-1/-1 +-1 0 MIN+1 1/-1/-1 +-1 0 MAX 1/-1/-1 +-1 0 MIN 1/-1/-1 +-1 -1 0 0 +-1 -1 -1 0 +-1 -1 1 0 +-1 -1 -2 0 +-1 -1 2 0 +-1 -1 -3 0 +-1 -1 3 0 +-1 -1 17 0 +-1 -1 127 0 +-1 -1 MIN+1 0 +-1 -1 MAX 0 +-1 -1 MIN 0 +-1 1 0 2/-1/0 +-1 1 -1 2/-1/0 +-1 1 1 2/-1/0 +-1 1 -2 2/-1/0 +-1 1 2 2/-1/0 +-1 1 -3 2/-1/0 +-1 1 3 2/-1/0 +-1 1 17 2/-1/0 +-1 1 127 2/-1/0 +-1 1 MIN+1 2/-1/0 +-1 1 MAX 2/-1/0 +-1 1 MIN 2/-1/0 +-1 3 0 4/-1/2 +-1 3 -1 4/-1/2 +-1 3 1 4/-1/2 +-1 3 -2 4/-1/2 +-1 3 2 4/-1/2 +-1 3 -3 4/-1/2 +-1 3 3 4/-1/2 +-1 3 17 4/-1/2 +-1 3 127 4/-1/2 +-1 3 MIN+1 4/-1/2 +-1 3 MAX 4/-1/2 +-1 3 MIN 4/-1/2 +-1 MIN+1 0 0 +-1 MIN+1 -1 0 +-1 MIN+1 1 0 +-1 MIN+1 -2 0 +-1 MIN+1 2 0 +-1 MIN+1 -3 0 +-1 MIN+1 3 0 +-1 MIN+1 17 0 +-1 MIN+1 127 0 +-1 MIN+1 MIN+1 0 +-1 MIN+1 MAX 0 +-1 MIN+1 MIN 0 +-1 MAX 0 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -1 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 1 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -2 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 2 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -3 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 3 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 17 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX 127 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX MIN+1 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX MAX --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX MIN --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MIN 0 0 +-1 MIN -1 0 +-1 MIN 1 0 +-1 MIN -2 0 +-1 MIN 2 0 +-1 MIN -3 0 +-1 MIN 3 0 +-1 MIN 17 0 +-1 MIN 127 0 +-1 MIN MIN+1 0 +-1 MIN MAX 0 +-1 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +1 0 0 0 +1 0 -1 0 +1 0 1 0 +1 0 -2 0 +1 0 2 0 +1 0 -3 0 +1 0 3 0 +1 0 17 0 +1 0 127 0 +1 0 MIN+1 0 +1 0 MAX 0 +1 0 MIN 0 +1 -1 0 0 +1 -1 -1 0 +1 -1 1 0 +1 -1 -2 0 +1 -1 2 0 +1 -1 -3 0 +1 -1 3 0 +1 -1 17 0 +1 -1 127 0 +1 -1 MIN+1 0 +1 -1 MAX 0 +1 -1 MIN 0 +1 1 0 0 +1 1 -1 0 +1 1 1 0 +1 1 -2 0 +1 1 2 0 +1 1 -3 0 +1 1 3 0 +1 1 17 0 +1 1 127 0 +1 1 MIN+1 0 +1 1 MAX 0 +1 1 MIN 0 +1 3 0 2/1/2 +1 3 -1 2/1/2 +1 3 1 2/1/2 +1 3 -2 2/1/2 +1 3 2 2/1/2 +1 3 -3 2/1/2 +1 3 3 2/1/2 +1 3 17 2/1/2 +1 3 127 2/1/2 +1 3 MIN+1 2/1/2 +1 3 MAX 2/1/2 +1 3 MIN 2/1/2 +1 MIN+1 0 0 +1 MIN+1 -1 0 +1 MIN+1 1 0 +1 MIN+1 -2 0 +1 MIN+1 2 0 +1 MIN+1 -3 0 +1 MIN+1 3 0 +1 MIN+1 17 0 +1 MIN+1 127 0 +1 MIN+1 MIN+1 0 +1 MIN+1 MAX 0 +1 MIN+1 MIN 0 +1 MAX 0 MAX-1/1/MAX-1 +1 MAX -1 MAX-1/1/MAX-1 +1 MAX 1 MAX-1/1/MAX-1 +1 MAX -2 MAX-1/1/MAX-1 +1 MAX 2 MAX-1/1/MAX-1 +1 MAX -3 MAX-1/1/MAX-1 +1 MAX 3 MAX-1/1/MAX-1 +1 MAX 17 MAX-1/1/MAX-1 +1 MAX 127 MAX-1/1/MAX-1 +1 MAX MIN+1 MAX-1/1/MAX-1 +1 MAX MAX MAX-1/1/MAX-1 +1 MAX MIN MAX-1/1/MAX-1 +1 MIN 0 0 +1 MIN -1 0 +1 MIN 1 0 +1 MIN -2 0 +1 MIN 2 0 +1 MIN -3 0 +1 MIN 3 0 +1 MIN 17 0 +1 MIN 127 0 +1 MIN MIN+1 0 +1 MIN MAX 0 +1 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +3 0 0 0 +3 0 -1 0 +3 0 1 0 +3 0 -2 0 +3 0 2 0 +3 0 -3 0 +3 0 3 0 +3 0 17 0 +3 0 127 0 +3 0 MIN+1 0 +3 0 MAX 0 +3 0 MIN 0 +3 -1 0 0 +3 -1 -1 0 +3 -1 1 0 +3 -1 -2 0 +3 -1 2 0 +3 -1 -3 0 +3 -1 3 0 +3 -1 17 0 +3 -1 127 0 +3 -1 MIN+1 0 +3 -1 MAX 0 +3 -1 MIN 0 +3 1 0 0 +3 1 -1 0 +3 1 1 0 +3 1 -2 0 +3 1 2 0 +3 1 -3 0 +3 1 3 0 +3 1 17 0 +3 1 127 0 +3 1 MIN+1 0 +3 1 MAX 0 +3 1 MIN 0 +3 3 0 0 +3 3 -1 0 +3 3 1 0 +3 3 -2 0 +3 3 2 0 +3 3 -3 0 +3 3 3 0 +3 3 17 0 +3 3 127 0 +3 3 MIN+1 0 +3 3 MAX 0 +3 3 MIN 0 +3 MIN+1 0 0 +3 MIN+1 -1 0 +3 MIN+1 1 0 +3 MIN+1 -2 0 +3 MIN+1 2 0 +3 MIN+1 -3 0 +3 MIN+1 3 0 +3 MIN+1 17 0 +3 MIN+1 127 0 +3 MIN+1 MIN+1 0 +3 MIN+1 MAX 0 +3 MIN+1 MIN 0 +3 MAX 0 MAX-3/3/MAX-1 +3 MAX -1 MAX-3/3/MAX-1 +3 MAX 1 MAX-3/3/MAX-1 +3 MAX -2 MAX-3/3/MAX-1 +3 MAX 2 MAX-3/3/MAX-1 +3 MAX -3 MAX-3/3/MAX-1 +3 MAX 3 MAX-3/3/MAX-1 +3 MAX 17 MAX-3/3/MAX-1 +3 MAX 127 MAX-3/3/MAX-1 +3 MAX MIN+1 MAX-3/3/MAX-1 +3 MAX MAX MAX-3/3/MAX-1 +3 MAX MIN MAX-3/3/MAX-1 +3 MIN 0 0 +3 MIN -1 0 +3 MIN 1 0 +3 MIN -2 0 +3 MIN 2 0 +3 MIN -3 0 +3 MIN 3 0 +3 MIN 17 0 +3 MIN 127 0 +3 MIN MIN+1 0 +3 MIN MAX 0 +3 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +MIN+1 0 0 MAX/MIN+1/-1 +MIN+1 0 -1 MAX/MIN+1/-1 +MIN+1 0 1 MAX/MIN+1/-1 +MIN+1 0 -2 MAX/MIN+1/-1 +MIN+1 0 2 MAX/MIN+1/-1 +MIN+1 0 -3 MAX/MIN+1/-1 +MIN+1 0 3 MAX/MIN+1/-1 +MIN+1 0 17 MAX/MIN+1/-1 +MIN+1 0 127 MAX/MIN+1/-1 +MIN+1 0 MIN+1 MAX/MIN+1/-1 +MIN+1 0 MAX MAX/MIN+1/-1 +MIN+1 0 MIN MAX/MIN+1/-1 +MIN+1 -1 0 MAX-1/MIN+1/-2 +MIN+1 -1 -1 MAX-1/MIN+1/-2 +MIN+1 -1 1 MAX-1/MIN+1/-2 +MIN+1 -1 -2 MAX-1/MIN+1/-2 +MIN+1 -1 2 MAX-1/MIN+1/-2 +MIN+1 -1 -3 MAX-1/MIN+1/-2 +MIN+1 -1 3 MAX-1/MIN+1/-2 +MIN+1 -1 17 MAX-1/MIN+1/-2 +MIN+1 -1 127 MAX-1/MIN+1/-2 +MIN+1 -1 MIN+1 MAX-1/MIN+1/-2 +MIN+1 -1 MAX MAX-1/MIN+1/-2 +MIN+1 -1 MIN MAX-1/MIN+1/-2 +MIN+1 1 0 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -1 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 1 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -2 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 2 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -3 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 3 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 17 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 127 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 MIN+1 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 MAX --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 MIN --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 0 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -1 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 1 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -2 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 2 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -3 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 3 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 17 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 127 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 MIN+1 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 MAX --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 MIN --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MIN+1 0 0 +MIN+1 MIN+1 -1 0 +MIN+1 MIN+1 1 0 +MIN+1 MIN+1 -2 0 +MIN+1 MIN+1 2 0 +MIN+1 MIN+1 -3 0 +MIN+1 MIN+1 3 0 +MIN+1 MIN+1 17 0 +MIN+1 MIN+1 127 0 +MIN+1 MIN+1 MIN+1 0 +MIN+1 MIN+1 MAX 0 +MIN+1 MIN+1 MIN 0 +MIN+1 MAX 0 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -1 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 1 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -2 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 2 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -3 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 3 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 17 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX 127 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX MIN+1 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX MAX --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX MIN --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MIN 0 0 +MIN+1 MIN -1 0 +MIN+1 MIN 1 0 +MIN+1 MIN -2 0 +MIN+1 MIN 2 0 +MIN+1 MIN -3 0 +MIN+1 MIN 3 0 +MIN+1 MIN 17 0 +MIN+1 MIN 127 0 +MIN+1 MIN MIN+1 0 +MIN+1 MIN MAX 0 +MIN+1 MIN MIN 0 + +start end step length/first/last +----------------------------------------- +MAX 0 0 0 +MAX 0 -1 0 +MAX 0 1 0 +MAX 0 -2 0 +MAX 0 2 0 +MAX 0 -3 0 +MAX 0 3 0 +MAX 0 17 0 +MAX 0 127 0 +MAX 0 MIN+1 0 +MAX 0 MAX 0 +MAX 0 MIN 0 +MAX -1 0 0 +MAX -1 -1 0 +MAX -1 1 0 +MAX -1 -2 0 +MAX -1 2 0 +MAX -1 -3 0 +MAX -1 3 0 +MAX -1 17 0 +MAX -1 127 0 +MAX -1 MIN+1 0 +MAX -1 MAX 0 +MAX -1 MIN 0 +MAX 1 0 0 +MAX 1 -1 0 +MAX 1 1 0 +MAX 1 -2 0 +MAX 1 2 0 +MAX 1 -3 0 +MAX 1 3 0 +MAX 1 17 0 +MAX 1 127 0 +MAX 1 MIN+1 0 +MAX 1 MAX 0 +MAX 1 MIN 0 +MAX 3 0 0 +MAX 3 -1 0 +MAX 3 1 0 +MAX 3 -2 0 +MAX 3 2 0 +MAX 3 -3 0 +MAX 3 3 0 +MAX 3 17 0 +MAX 3 127 0 +MAX 3 MIN+1 0 +MAX 3 MAX 0 +MAX 3 MIN 0 +MAX MIN+1 0 0 +MAX MIN+1 -1 0 +MAX MIN+1 1 0 +MAX MIN+1 -2 0 +MAX MIN+1 2 0 +MAX MIN+1 -3 0 +MAX MIN+1 3 0 +MAX MIN+1 17 0 +MAX MIN+1 127 0 +MAX MIN+1 MIN+1 0 +MAX MIN+1 MAX 0 +MAX MIN+1 MIN 0 +MAX MAX 0 0 +MAX MAX -1 0 +MAX MAX 1 0 +MAX MAX -2 0 +MAX MAX 2 0 +MAX MAX -3 0 +MAX MAX 3 0 +MAX MAX 17 0 +MAX MAX 127 0 +MAX MAX MIN+1 0 +MAX MAX MAX 0 +MAX MAX MIN 0 +MAX MIN 0 0 +MAX MIN -1 0 +MAX MIN 1 0 +MAX MIN -2 0 +MAX MIN 2 0 +MAX MIN -3 0 +MAX MIN 3 0 +MAX MIN 17 0 +MAX MIN 127 0 +MAX MIN MIN+1 0 +MAX MIN MAX 0 +MAX MIN MIN 0 + +start end step length/first/last +----------------------------------------- +MIN 0 0 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -1 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 1 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -2 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 2 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -3 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 3 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 17 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 127 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 MAX --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 MIN --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN -1 0 MAX/MIN/-2 +MIN -1 -1 MAX/MIN/-2 +MIN -1 1 MAX/MIN/-2 +MIN -1 -2 MAX/MIN/-2 +MIN -1 2 MAX/MIN/-2 +MIN -1 -3 MAX/MIN/-2 +MIN -1 3 MAX/MIN/-2 +MIN -1 17 MAX/MIN/-2 +MIN -1 127 MAX/MIN/-2 +MIN -1 MIN+1 MAX/MIN/-2 +MIN -1 MAX MAX/MIN/-2 +MIN -1 MIN MAX/MIN/-2 +MIN 1 0 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -1 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 1 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -2 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 2 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -3 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 3 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 17 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 127 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 MAX --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 MIN --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 0 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -1 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 1 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -2 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 2 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -3 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 3 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 17 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 127 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 MAX --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 MIN --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MIN+1 0 1/MIN/MIN +MIN MIN+1 -1 1/MIN/MIN +MIN MIN+1 1 1/MIN/MIN +MIN MIN+1 -2 1/MIN/MIN +MIN MIN+1 2 1/MIN/MIN +MIN MIN+1 -3 1/MIN/MIN +MIN MIN+1 3 1/MIN/MIN +MIN MIN+1 17 1/MIN/MIN +MIN MIN+1 127 1/MIN/MIN +MIN MIN+1 MIN+1 1/MIN/MIN +MIN MIN+1 MAX 1/MIN/MIN +MIN MIN+1 MIN 1/MIN/MIN +MIN MAX 0 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -1 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 1 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -2 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 2 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -3 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 3 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 17 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX 127 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX MIN+1 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX MAX --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX MIN --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MIN 0 0 +MIN MIN -1 0 +MIN MIN 1 0 +MIN MIN -2 0 +MIN MIN 2 0 +MIN MIN -3 0 +MIN MIN 3 0 +MIN MIN 17 0 +MIN MIN 127 0 +MIN MIN MIN+1 0 +MIN MIN MAX 0 +MIN MIN MIN 0 + +>>> start until end by step <<< + +start end step length/first/last +----------------------------------------- +0 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 0 -1 0 +0 0 1 0 +0 0 -2 0 +0 0 2 0 +0 0 -3 0 +0 0 3 0 +0 0 17 0 +0 0 127 0 +0 0 MIN+1 0 +0 0 MAX 0 +0 0 MIN 0 +0 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 -1 -1 1/0/0 +0 -1 1 0 +0 -1 -2 1/0/0 +0 -1 2 0 +0 -1 -3 1/0/0 +0 -1 3 0 +0 -1 17 0 +0 -1 127 0 +0 -1 MIN+1 1/0/0 +0 -1 MAX 0 +0 -1 MIN 1/0/0 +0 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 1 -1 0 +0 1 1 1/0/0 +0 1 -2 0 +0 1 2 1/0/0 +0 1 -3 0 +0 1 3 1/0/0 +0 1 17 1/0/0 +0 1 127 1/0/0 +0 1 MIN+1 0 +0 1 MAX 1/0/0 +0 1 MIN 0 +0 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 3 -1 0 +0 3 1 3/0/2 +0 3 -2 0 +0 3 2 2/0/2 +0 3 -3 0 +0 3 3 1/0/0 +0 3 17 1/0/0 +0 3 127 1/0/0 +0 3 MIN+1 0 +0 3 MAX 1/0/0 +0 3 MIN 0 +0 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MIN+1 -1 MAX/0/MIN+2 +0 MIN+1 1 0 +0 MIN+1 -2 1073741824/0/MIN+2 +0 MIN+1 2 0 +0 MIN+1 -3 715827883/0/MIN+2 +0 MIN+1 3 0 +0 MIN+1 17 0 +0 MIN+1 127 0 +0 MIN+1 MIN+1 1/0/0 +0 MIN+1 MAX 0 +0 MIN+1 MIN 1/0/0 +0 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MAX -1 0 +0 MAX 1 MAX/0/MAX-1 +0 MAX -2 0 +0 MAX 2 1073741824/0/MAX-1 +0 MAX -3 0 +0 MAX 3 715827883/0/MAX-1 +0 MAX 17 126322568/0/MAX-8 +0 MAX 127 16909321/0/MAX-7 +0 MAX MIN+1 0 +0 MAX MAX 1/0/0 +0 MAX MIN 0 +0 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +0 MIN -1 --- + java.lang.IllegalArgumentException: 0 until -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +0 MIN 1 0 +0 MIN -2 1073741824/0/MIN+2 +0 MIN 2 0 +0 MIN -3 715827883/0/MIN+2 +0 MIN 3 0 +0 MIN 17 0 +0 MIN 127 0 +0 MIN MIN+1 2/0/MIN+1 +0 MIN MAX 0 +0 MIN MIN 1/0/0 + +start end step length/first/last +----------------------------------------- +-1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 0 -1 0 +-1 0 1 1/-1/-1 +-1 0 -2 0 +-1 0 2 1/-1/-1 +-1 0 -3 0 +-1 0 3 1/-1/-1 +-1 0 17 1/-1/-1 +-1 0 127 1/-1/-1 +-1 0 MIN+1 0 +-1 0 MAX 1/-1/-1 +-1 0 MIN 0 +-1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 -1 -1 0 +-1 -1 1 0 +-1 -1 -2 0 +-1 -1 2 0 +-1 -1 -3 0 +-1 -1 3 0 +-1 -1 17 0 +-1 -1 127 0 +-1 -1 MIN+1 0 +-1 -1 MAX 0 +-1 -1 MIN 0 +-1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 1 -1 0 +-1 1 1 2/-1/0 +-1 1 -2 0 +-1 1 2 1/-1/-1 +-1 1 -3 0 +-1 1 3 1/-1/-1 +-1 1 17 1/-1/-1 +-1 1 127 1/-1/-1 +-1 1 MIN+1 0 +-1 1 MAX 1/-1/-1 +-1 1 MIN 0 +-1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 3 -1 0 +-1 3 1 4/-1/2 +-1 3 -2 0 +-1 3 2 2/-1/1 +-1 3 -3 0 +-1 3 3 2/-1/2 +-1 3 17 1/-1/-1 +-1 3 127 1/-1/-1 +-1 3 MIN+1 0 +-1 3 MAX 1/-1/-1 +-1 3 MIN 0 +-1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MIN+1 -1 MAX-1/-1/MIN+2 +-1 MIN+1 1 0 +-1 MIN+1 -2 1073741823/-1/MIN+3 +-1 MIN+1 2 0 +-1 MIN+1 -3 715827882/-1/MIN+4 +-1 MIN+1 3 0 +-1 MIN+1 17 0 +-1 MIN+1 127 0 +-1 MIN+1 MIN+1 1/-1/-1 +-1 MIN+1 MAX 0 +-1 MIN+1 MIN 1/-1/-1 +-1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MAX -1 0 +-1 MAX 1 --- + java.lang.IllegalArgumentException: -1 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +-1 MAX -2 0 +-1 MAX 2 1073741824/-1/MAX-2 +-1 MAX -3 0 +-1 MAX 3 715827883/-1/MAX-2 +-1 MAX 17 126322568/-1/MAX-9 +-1 MAX 127 16909321/-1/MAX-8 +-1 MAX MIN+1 0 +-1 MAX MAX 2/-1/MAX-1 +-1 MAX MIN 0 +-1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +-1 MIN -1 MAX/-1/MIN+1 +-1 MIN 1 0 +-1 MIN -2 1073741824/-1/MIN+1 +-1 MIN 2 0 +-1 MIN -3 715827883/-1/MIN+1 +-1 MIN 3 0 +-1 MIN 17 0 +-1 MIN 127 0 +-1 MIN MIN+1 1/-1/-1 +-1 MIN MAX 0 +-1 MIN MIN 1/-1/-1 + +start end step length/first/last +----------------------------------------- +1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 0 -1 1/1/1 +1 0 1 0 +1 0 -2 1/1/1 +1 0 2 0 +1 0 -3 1/1/1 +1 0 3 0 +1 0 17 0 +1 0 127 0 +1 0 MIN+1 1/1/1 +1 0 MAX 0 +1 0 MIN 1/1/1 +1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 -1 -1 2/1/0 +1 -1 1 0 +1 -1 -2 1/1/1 +1 -1 2 0 +1 -1 -3 1/1/1 +1 -1 3 0 +1 -1 17 0 +1 -1 127 0 +1 -1 MIN+1 1/1/1 +1 -1 MAX 0 +1 -1 MIN 1/1/1 +1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 1 -1 0 +1 1 1 0 +1 1 -2 0 +1 1 2 0 +1 1 -3 0 +1 1 3 0 +1 1 17 0 +1 1 127 0 +1 1 MIN+1 0 +1 1 MAX 0 +1 1 MIN 0 +1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 3 -1 0 +1 3 1 2/1/2 +1 3 -2 0 +1 3 2 1/1/1 +1 3 -3 0 +1 3 3 1/1/1 +1 3 17 1/1/1 +1 3 127 1/1/1 +1 3 MIN+1 0 +1 3 MAX 1/1/1 +1 3 MIN 0 +1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MIN+1 -1 --- + java.lang.IllegalArgumentException: 1 until -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +1 MIN+1 1 0 +1 MIN+1 -2 1073741824/1/MIN+3 +1 MIN+1 2 0 +1 MIN+1 -3 715827883/1/MIN+3 +1 MIN+1 3 0 +1 MIN+1 17 0 +1 MIN+1 127 0 +1 MIN+1 MIN+1 2/1/MIN+2 +1 MIN+1 MAX 0 +1 MIN+1 MIN 1/1/1 +1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MAX -1 0 +1 MAX 1 MAX-1/1/MAX-1 +1 MAX -2 0 +1 MAX 2 1073741823/1/MAX-2 +1 MAX -3 0 +1 MAX 3 715827882/1/MAX-3 +1 MAX 17 126322568/1/MAX-7 +1 MAX 127 16909321/1/MAX-6 +1 MAX MIN+1 0 +1 MAX MAX 1/1/1 +1 MAX MIN 0 +1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +1 MIN -1 --- + java.lang.IllegalArgumentException: 1 until -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +1 MIN 1 0 +1 MIN -2 1073741825/1/MIN+1 +1 MIN 2 0 +1 MIN -3 715827883/1/MIN+3 +1 MIN 3 0 +1 MIN 17 0 +1 MIN 127 0 +1 MIN MIN+1 2/1/MIN+2 +1 MIN MAX 0 +1 MIN MIN 2/1/MIN+1 + +start end step length/first/last +----------------------------------------- +3 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 0 -1 3/3/1 +3 0 1 0 +3 0 -2 2/3/1 +3 0 2 0 +3 0 -3 1/3/3 +3 0 3 0 +3 0 17 0 +3 0 127 0 +3 0 MIN+1 1/3/3 +3 0 MAX 0 +3 0 MIN 1/3/3 +3 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 -1 -1 4/3/0 +3 -1 1 0 +3 -1 -2 2/3/1 +3 -1 2 0 +3 -1 -3 2/3/0 +3 -1 3 0 +3 -1 17 0 +3 -1 127 0 +3 -1 MIN+1 1/3/3 +3 -1 MAX 0 +3 -1 MIN 1/3/3 +3 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 1 -1 2/3/2 +3 1 1 0 +3 1 -2 1/3/3 +3 1 2 0 +3 1 -3 1/3/3 +3 1 3 0 +3 1 17 0 +3 1 127 0 +3 1 MIN+1 1/3/3 +3 1 MAX 0 +3 1 MIN 1/3/3 +3 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 3 -1 0 +3 3 1 0 +3 3 -2 0 +3 3 2 0 +3 3 -3 0 +3 3 3 0 +3 3 17 0 +3 3 127 0 +3 3 MIN+1 0 +3 3 MAX 0 +3 3 MIN 0 +3 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MIN+1 -1 --- + java.lang.IllegalArgumentException: 3 until -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +3 MIN+1 1 0 +3 MIN+1 -2 1073741825/3/MIN+3 +3 MIN+1 2 0 +3 MIN+1 -3 715827884/3/MIN+2 +3 MIN+1 3 0 +3 MIN+1 17 0 +3 MIN+1 127 0 +3 MIN+1 MIN+1 2/3/MIN+4 +3 MIN+1 MAX 0 +3 MIN+1 MIN 2/3/MIN+3 +3 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MAX -1 0 +3 MAX 1 MAX-3/3/MAX-1 +3 MAX -2 0 +3 MAX 2 1073741822/3/MAX-2 +3 MAX -3 0 +3 MAX 3 715827882/3/MAX-1 +3 MAX 17 126322568/3/MAX-5 +3 MAX 127 16909321/3/MAX-4 +3 MAX MIN+1 0 +3 MAX MAX 1/3/3 +3 MAX MIN 0 +3 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +3 MIN -1 --- + java.lang.IllegalArgumentException: 3 until -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +3 MIN 1 0 +3 MIN -2 1073741826/3/MIN+1 +3 MIN 2 0 +3 MIN -3 715827884/3/MIN+2 +3 MIN 3 0 +3 MIN 17 0 +3 MIN 127 0 +3 MIN MIN+1 2/3/MIN+4 +3 MIN MAX 0 +3 MIN MIN 2/3/MIN+3 + +start end step length/first/last +----------------------------------------- +MIN+1 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 0 -1 0 +MIN+1 0 1 MAX/MIN+1/-1 +MIN+1 0 -2 0 +MIN+1 0 2 1073741824/MIN+1/-1 +MIN+1 0 -3 0 +MIN+1 0 3 715827883/MIN+1/-1 +MIN+1 0 17 126322568/MIN+1/-8 +MIN+1 0 127 16909321/MIN+1/-7 +MIN+1 0 MIN+1 0 +MIN+1 0 MAX 1/MIN+1/MIN+1 +MIN+1 0 MIN 0 +MIN+1 -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 -1 -1 0 +MIN+1 -1 1 MAX-1/MIN+1/-2 +MIN+1 -1 -2 0 +MIN+1 -1 2 1073741823/MIN+1/-3 +MIN+1 -1 -3 0 +MIN+1 -1 3 715827882/MIN+1/-4 +MIN+1 -1 17 126322568/MIN+1/-8 +MIN+1 -1 127 16909321/MIN+1/-7 +MIN+1 -1 MIN+1 0 +MIN+1 -1 MAX 1/MIN+1/MIN+1 +MIN+1 -1 MIN 0 +MIN+1 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 1 -1 0 +MIN+1 1 1 --- + java.lang.IllegalArgumentException: -2147483647 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 1 -2 0 +MIN+1 1 2 1073741824/MIN+1/-1 +MIN+1 1 -3 0 +MIN+1 1 3 715827883/MIN+1/-1 +MIN+1 1 17 126322568/MIN+1/-8 +MIN+1 1 127 16909321/MIN+1/-7 +MIN+1 1 MIN+1 0 +MIN+1 1 MAX 2/MIN+1/0 +MIN+1 1 MIN 0 +MIN+1 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 3 -1 0 +MIN+1 3 1 --- + java.lang.IllegalArgumentException: -2147483647 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 3 -2 0 +MIN+1 3 2 1073741825/MIN+1/1 +MIN+1 3 -3 0 +MIN+1 3 3 715827884/MIN+1/2 +MIN+1 3 17 126322568/MIN+1/-8 +MIN+1 3 127 16909321/MIN+1/-7 +MIN+1 3 MIN+1 0 +MIN+1 3 MAX 2/MIN+1/0 +MIN+1 3 MIN 0 +MIN+1 MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MIN+1 -1 0 +MIN+1 MIN+1 1 0 +MIN+1 MIN+1 -2 0 +MIN+1 MIN+1 2 0 +MIN+1 MIN+1 -3 0 +MIN+1 MIN+1 3 0 +MIN+1 MIN+1 17 0 +MIN+1 MIN+1 127 0 +MIN+1 MIN+1 MIN+1 0 +MIN+1 MIN+1 MAX 0 +MIN+1 MIN+1 MIN 0 +MIN+1 MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MAX -1 0 +MIN+1 MAX 1 --- + java.lang.IllegalArgumentException: -2147483647 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN+1 MAX -2 0 +MIN+1 MAX 2 MAX/MIN+1/MAX-2 +MIN+1 MAX -3 0 +MIN+1 MAX 3 1431655765/MIN+1/MAX-2 +MIN+1 MAX 17 252645135/MIN+1/MAX-16 +MIN+1 MAX 127 33818641/MIN+1/MAX-14 +MIN+1 MAX MIN+1 0 +MIN+1 MAX MAX 2/MIN+1/0 +MIN+1 MAX MIN 0 +MIN+1 MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN+1 MIN -1 1/MIN+1/MIN+1 +MIN+1 MIN 1 0 +MIN+1 MIN -2 1/MIN+1/MIN+1 +MIN+1 MIN 2 0 +MIN+1 MIN -3 1/MIN+1/MIN+1 +MIN+1 MIN 3 0 +MIN+1 MIN 17 0 +MIN+1 MIN 127 0 +MIN+1 MIN MIN+1 1/MIN+1/MIN+1 +MIN+1 MIN MAX 0 +MIN+1 MIN MIN 1/MIN+1/MIN+1 + +start end step length/first/last +----------------------------------------- +MAX 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 0 -1 MAX/MAX/1 +MAX 0 1 0 +MAX 0 -2 1073741824/MAX/1 +MAX 0 2 0 +MAX 0 -3 715827883/MAX/1 +MAX 0 3 0 +MAX 0 17 0 +MAX 0 127 0 +MAX 0 MIN+1 1/MAX/MAX +MAX 0 MAX 0 +MAX 0 MIN 1/MAX/MAX +MAX -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX -1 -1 --- + java.lang.IllegalArgumentException: 2147483647 until -1 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX -1 1 0 +MAX -1 -2 1073741824/MAX/1 +MAX -1 2 0 +MAX -1 -3 715827883/MAX/1 +MAX -1 3 0 +MAX -1 17 0 +MAX -1 127 0 +MAX -1 MIN+1 2/MAX/0 +MAX -1 MAX 0 +MAX -1 MIN 1/MAX/MAX +MAX 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 1 -1 MAX-1/MAX/2 +MAX 1 1 0 +MAX 1 -2 1073741823/MAX/3 +MAX 1 2 0 +MAX 1 -3 715827882/MAX/4 +MAX 1 3 0 +MAX 1 17 0 +MAX 1 127 0 +MAX 1 MIN+1 1/MAX/MAX +MAX 1 MAX 0 +MAX 1 MIN 1/MAX/MAX +MAX 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX 3 -1 MAX-3/MAX/4 +MAX 3 1 0 +MAX 3 -2 1073741822/MAX/5 +MAX 3 2 0 +MAX 3 -3 715827882/MAX/4 +MAX 3 3 0 +MAX 3 17 0 +MAX 3 127 0 +MAX 3 MIN+1 1/MAX/MAX +MAX 3 MAX 0 +MAX 3 MIN 1/MAX/MAX +MAX MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MIN+1 -1 --- + java.lang.IllegalArgumentException: 2147483647 until -2147483647 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX MIN+1 1 0 +MAX MIN+1 -2 MAX/MAX/MIN+3 +MAX MIN+1 2 0 +MAX MIN+1 -3 1431655765/MAX/MIN+3 +MAX MIN+1 3 0 +MAX MIN+1 17 0 +MAX MIN+1 127 0 +MAX MIN+1 MIN+1 2/MAX/0 +MAX MIN+1 MAX 0 +MAX MIN+1 MIN 2/MAX/-1 +MAX MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MAX -1 0 +MAX MAX 1 0 +MAX MAX -2 0 +MAX MAX 2 0 +MAX MAX -3 0 +MAX MAX 3 0 +MAX MAX 17 0 +MAX MAX 127 0 +MAX MAX MIN+1 0 +MAX MAX MAX 0 +MAX MAX MIN 0 +MAX MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MAX MIN -1 --- + java.lang.IllegalArgumentException: 2147483647 until -2147483648 by -1: seqs cannot contain more than Int.MaxValue elements. +MAX MIN 1 0 +MAX MIN -2 --- + java.lang.IllegalArgumentException: 2147483647 until -2147483648 by -2: seqs cannot contain more than Int.MaxValue elements. +MAX MIN 2 0 +MAX MIN -3 1431655765/MAX/MIN+3 +MAX MIN 3 0 +MAX MIN 17 0 +MAX MIN 127 0 +MAX MIN MIN+1 3/MAX/MIN+1 +MAX MIN MAX 0 +MAX MIN MIN 2/MAX/-1 + +start end step length/first/last +----------------------------------------- +MIN 0 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 0 -1 0 +MIN 0 1 --- + java.lang.IllegalArgumentException: -2147483648 until 0 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 0 -2 0 +MIN 0 2 1073741824/MIN/-2 +MIN 0 -3 0 +MIN 0 3 715827883/MIN/-2 +MIN 0 17 126322568/MIN/-9 +MIN 0 127 16909321/MIN/-8 +MIN 0 MIN+1 0 +MIN 0 MAX 2/MIN/-1 +MIN 0 MIN 0 +MIN -1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN -1 -1 0 +MIN -1 1 MAX/MIN/-2 +MIN -1 -2 0 +MIN -1 2 1073741824/MIN/-2 +MIN -1 -3 0 +MIN -1 3 715827883/MIN/-2 +MIN -1 17 126322568/MIN/-9 +MIN -1 127 16909321/MIN/-8 +MIN -1 MIN+1 0 +MIN -1 MAX 1/MIN/MIN +MIN -1 MIN 0 +MIN 1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 1 -1 0 +MIN 1 1 --- + java.lang.IllegalArgumentException: -2147483648 until 1 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 1 -2 0 +MIN 1 2 1073741825/MIN/0 +MIN 1 -3 0 +MIN 1 3 715827883/MIN/-2 +MIN 1 17 126322568/MIN/-9 +MIN 1 127 16909321/MIN/-8 +MIN 1 MIN+1 0 +MIN 1 MAX 2/MIN/-1 +MIN 1 MIN 0 +MIN 3 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN 3 -1 0 +MIN 3 1 --- + java.lang.IllegalArgumentException: -2147483648 until 3 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN 3 -2 0 +MIN 3 2 1073741826/MIN/2 +MIN 3 -3 0 +MIN 3 3 715827884/MIN/1 +MIN 3 17 126322568/MIN/-9 +MIN 3 127 16909321/MIN/-8 +MIN 3 MIN+1 0 +MIN 3 MAX 2/MIN/-1 +MIN 3 MIN 0 +MIN MIN+1 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MIN+1 -1 0 +MIN MIN+1 1 1/MIN/MIN +MIN MIN+1 -2 0 +MIN MIN+1 2 1/MIN/MIN +MIN MIN+1 -3 0 +MIN MIN+1 3 1/MIN/MIN +MIN MIN+1 17 1/MIN/MIN +MIN MIN+1 127 1/MIN/MIN +MIN MIN+1 MIN+1 0 +MIN MIN+1 MAX 1/MIN/MIN +MIN MIN+1 MIN 0 +MIN MAX 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MAX -1 0 +MIN MAX 1 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 1: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -2 0 +MIN MAX 2 --- + java.lang.IllegalArgumentException: -2147483648 until 2147483647 by 2: seqs cannot contain more than Int.MaxValue elements. +MIN MAX -3 0 +MIN MAX 3 1431655765/MIN/MAX-3 +MIN MAX 17 252645135/MIN/MAX-17 +MIN MAX 127 33818641/MIN/MAX-15 +MIN MAX MIN+1 0 +MIN MAX MAX 3/MIN/MAX-1 +MIN MAX MIN 0 +MIN MIN 0 --- + java.lang.IllegalArgumentException: step cannot be 0. +MIN MIN -1 0 +MIN MIN 1 0 +MIN MIN -2 0 +MIN MIN 2 0 +MIN MIN -3 0 +MIN MIN 3 0 +MIN MIN 17 0 +MIN MIN 127 0 +MIN MIN MIN+1 0 +MIN MIN MAX 0 +MIN MIN MIN 0 + diff --git a/test/files/run/range-unit.scala b/test/files/run/range-unit.scala new file mode 100644 index 0000000000..ece0d9806c --- /dev/null +++ b/test/files/run/range-unit.scala @@ -0,0 +1,55 @@ +import scala.collection.immutable.Range + +object Test { + // ha ha, I always forget math.abs(Int.MinValue) == Int.MinValue + val numbers = ( + ( (-3 to 3) ++ List(17, 127, Int.MaxValue, Int.MinValue + 1) + ).distinct.sortBy(n => (math.abs(n), n)) + ) :+ Int.MinValue + + // reducing output a little + val endpoints = numbers filterNot Set(-3, -2, 2, 17, 127) + + def num(n: Int) = { + val frommax = Int.MaxValue - n + val frommin = Int.MinValue - n + + if (n > 0) { + if (frommax == 0) "MAX" + else if (frommax < 1000) "MAX-" + frommax + else "" + n + } + else { + if (frommin == 0) "MIN" + else if (frommin > -1000) "MIN+" + (-frommin) + else "" + n + } + } + + def run[T](body: => Range): List[Any] = { + try { val r = body ; if (r.isEmpty) List(r.length) else List(num(r.length), num(r.head), num(r.last)) } + catch { case e: IllegalArgumentException => List("---\n " + e) } + } + + def runGroup(label: String, f: (Int, Int, Int) => Range) { + println(">>> " + label + " <<<\n") + for (start <- endpoints) { + val s = "%-7s %-7s %-7s %s".format("start", "end", "step", "length/first/last") + println(s + "\n" + ("-" * s.length)) + for (end <- endpoints ; step <- numbers) { + print("%-7s %-7s %-7s ".format(num(start), num(end), num(step))) + println(run(f(start, end, step)).mkString("/")) + } + println("") + } + } + + def main(args: Array[String]): Unit = { + runGroup("Range.inclusive", Range.inclusive(_, _, _)) + runGroup("Range.apply", Range.apply(_, _, _)) + runGroup("start to end", (x, y, _) => x to y) + runGroup("start to end by step", _ to _ by _) + runGroup("start until end", (x, y, _) => x until y) + runGroup("start until end by step", _ until _ by _) + } +} -- cgit v1.2.3