Created
August 2, 2020 18:23
-
-
Save Sciss/90771c3a31ccc352cff98a261036d896 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// midiRatio( 10.5) shouldBe 1.8340080864049 +- eps | |
val fIn = file("/home/hhrutz/Documents/devel/Numbers/src/test/scala/de/sciss/numbers/DoubleSpecOLD.scala") | |
val lnIn = scala.io.Source.fromFile(fIn).getLines.toList | |
val lnOut = lnIn.map { ln => | |
if (ln.contains("shouldBe")) { | |
val i_eps = ln.indexOf("+-") | |
val hasEps = i_eps > 0 | |
val t_shd = " shouldBe " | |
val i_shd = ln.indexOf(t_shd) | |
val ln1 = if (!hasEps) ln else ln.substring(0, i_eps) | |
val ln2 = ln1.substring(0, i_shd) + ", " + ln1.substring(i_shd + t_shd.length) | |
val pre = if (hasEps) "is_tol" else "is" | |
s" $pre(${ln2.trim})" | |
} else { | |
ln | |
} | |
} | |
val fOut = fIn.replaceName("DoubleSpec.scala") | |
val fos = new java.io.FileOutputStream(fOut) | |
fos.write(lnOut.mkString("\n").getBytes("UTF-8")) | |
fos.close() | |
// midiRatio( 10.5) shouldBe 1.8340080864049 +- eps | |
val fIn = file("/home/hhrutz/Documents/devel/Numbers/src/test/scala/de/sciss/numbers/FloatSpecOLD.scala") | |
val lnIn = scala.io.Source.fromFile(fIn).getLines.toList | |
val lnOut = lnIn.map { ln => | |
if (ln.contains("shouldBe")) { | |
val t_tol = "tol(" | |
val i_eps = ln.indexOf(t_tol) | |
val hasEps = i_eps > 0 | |
val t_shd = " shouldBe " | |
val i_shd = ln.indexOf(t_shd) | |
val ln1 = if (!hasEps) ln else { | |
val j = ln.indexOf(")", i_eps) | |
ln.substring(0, i_eps) + ln.substring(i_eps + t_tol.length, j) | |
} | |
val ln2 = ln1.substring(0, i_shd) + ", " + ln1.substring(i_shd + t_shd.length) | |
val pre = if (hasEps) "is_tol" else "is" | |
s" $pre(${ln2.trim})" | |
} else { | |
ln | |
} | |
} | |
val fOut = fIn.replaceName("FloatSpec.scala") | |
val fos = new java.io.FileOutputStream(fOut) | |
fos.write(lnOut.mkString("\n").getBytes("UTF-8")) | |
fos.close() | |
val fIn = file("/home/hhrutz/Documents/devel/Numbers/src/test/scala/de/sciss/numbers/IntSpecOLD.scala") | |
val lnIn = scala.io.Source.fromFile(fIn).getLines.toList | |
val lnOut = lnIn.map { ln => | |
if (ln.contains("shouldBe")) { | |
val t_shd = " shouldBe " | |
val i_shd = ln.indexOf(t_shd) | |
val ln1 = ln | |
val ln2 = ln1.substring(0, i_shd) + ", " + ln1.substring(i_shd + t_shd.length) | |
val pre = "is" | |
s" $pre(${ln2.trim})" | |
} else { | |
ln | |
} | |
} | |
val fOut = fIn.replaceName("IntSpec.scala") | |
val fos = new java.io.FileOutputStream(fOut) | |
fos.write(lnOut.mkString("\n").getBytes("UTF-8")) | |
fos.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment