Skip to content

Commit

Permalink
Cross compile to Scala 2.12
Browse files Browse the repository at this point in the history
Conditional runs test for SI-9623.
  • Loading branch information
flicken committed Nov 6, 2017
1 parent 8df3da9 commit 3b9b86f
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 13 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
language: scala
jdk: oraclejdk8
scala:
- 2.11.7
- 2.11.11
- 2.12.4

# Use container-based infrastructure
sudo: false
Expand Down
4 changes: 3 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@ name := "iterata"
homepage := Some(url("https://github.com/tim-group/iterata"))
licenses := Seq("MIT" -> url("http://opensource.org/licenses/MIT"))

scalaVersion := "2.11.8"
crossScalaVersions := Seq("2.11.11", "2.12.4")

scalaVersion := crossScalaVersions.value.head

// Compilation options
scalacOptions ++= Seq("-unchecked", "-deprecation")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,23 +5,31 @@ import org.scalatest.{DiagrammedAssertions, FunSpec, Matchers}

class MemoizeExhaustionIteratorSpec extends FunSpec with Matchers with DiagrammedAssertions {

val expectSI9623ToBeFixed = util.Properties.versionNumberString.split("\\.") match {
case Array("2", "11", minor) if minor.toInt < 8 => false
case _ => true
}

describe("Demonstration of SI-9623: JoinIterator always calls hasNext on exhausted left iterator after `++`") {

describe("after a single `++`") {
if (!expectSI9623ToBeFixed) {
describe("after a single `++`") {

it("JoinIterator always calls hasNext on exhausted left iterator") {
val it1 = new IteratorWithExpensiveHasNext()
val it2 = new IteratorWithExpensiveHasNext()
it("JoinIterator always calls hasNext on exhausted left iterator") {
println(util.Properties.versionString)
println(util.Properties.versionMsg)
val it1 = new IteratorWithExpensiveHasNext()
val it2 = new IteratorWithExpensiveHasNext()

(it1 ++ it2).foreach(_ => ())
(it1 ++ it2).foreach(_ => ())

// Why it1.hasNext is called 21 times instead of the expected 1:
// - for each of the 10 values in it2, once in JoinIterator#hasNext,
// and again in JoinIterator#next()
// - plus the final time that JoinIterator#hasNext will return false
it1.numTimesHasNextReturnedFalse should be(21)
// Why it1.hasNext is called 21 times instead of the expected 1:
// - for each of the 10 values in it2, once in JoinIterator#hasNext,
// and again in JoinIterator#next()
// - plus the final time that JoinIterator#hasNext will return false
it1.numTimesHasNextReturnedFalse should be(21)
}
}

}

describe("after two `++` calls") {
Expand Down

0 comments on commit 3b9b86f

Please sign in to comment.