These are chat archives for etorreborre/specs2

30th
Dec 2016
Marko Elezović
@melezov
Dec 30 2016 21:43
Hey guys. I have an "interesting" problem when trying to compile a simple spec against 2.11.8:
[info] Compiling 1 Scala source to D:\Code\server-banner\target\scala-2.11\test-classes... [error] D:\Code\server-banner\src\test\scala\com\oradian\infra\serverbanner\slant\SlantSpec.scala:15: type mismatch; [error] found : () => IndexedSeq[org.specs2.matcher.MatchResult[String]] [error] required: org.specs2.specification.create.InterpolatedFragment [error] single glyph ${testGlyphs} [error] ^ [error] D:\Code\server-banner\src\test\scala\com\oradian\infra\serverbanner\slant\SlantSpec.scala:16: type mismatch; [error] found : () => IndexedSeq[org.specs2.matcher.MatchResult[String]] [error] required: org.specs2.specification.create.InterpolatedFragment [error] glyph pairs ${testGlyphPairs} [error] ^ [error] D:\Code\server-banner\src\test\scala\com\oradian\infra\serverbanner\slant\SlantSpec.scala:19: type mismatch; [error] found : () => Seq[org.specs2.matcher.MatchResult[String]] [error] required: org.specs2.specification.create.InterpolatedFragment [error] use cases ${testUseCases} [error] ^ [error] D:\Code\server-banner\src\test\scala\com\oradian\infra\serverbanner\slant\SlantSpec.scala:20: type mismatch; [error] found : () => org.specs2.matcher.MatchResult[Int] [error] required: org.specs2.specification.create.InterpolatedFragment [error] 3-combinations and variations ${test3CombinationsAndVariations} [error] ^ [error] four errors found
The interesting bit is that it compiles and runs fine against 2.12.1 AND 2.10.6, so I'm scratching my head here...
Marko Elezović
@melezov
Dec 30 2016 21:58
Tried to be a bit paranoid in SBT, so using this: ; clean; ++2.12.1; test:compile; clean; ++2.10.6; test:compile; clean; ++2.11.8; test:compile
Only the last compilation fails
Eric Torreborre
@etorreborre
Dec 30 2016 22:04

I don't really know why it is otherwise compiling in 2.12 but you should write

def testGlyphs =
    Result.foreach(SortedChars) { ch =>
      val actual = Slant(new String(Array(ch)))
      val expected = Glyph.find(ch, None).toString
      actual ==== expected
    }

This will build a result that combines all assertions actual === expected for all chars
You could also use ScalaCheck

def testGlyphs = prop { c: Char =>
  val actual = Slant(new String(Array(ch)))
  val expected = Glyph.find(ch, None).toString
  actual ==== expected
}.setGen(Gen.oneOf(SortedChars:_*))

(or something similar)

I'm sorry I need to go to bed now, I hope that helps
Marko Elezović
@melezov
Dec 30 2016 22:08
Thanx!
I've managed to binary-search it it seems I was too cocky with my scalacOptions (it was due to the -Xexperimentalflag)
Removing the flag makes it run for all cross versions
Thanx for the tip, much appreciated!
Was just about to add specs2-scalacheck to add property based testing against a native implementation (without me having to provide all the test results)