Skip to content

Commit

Permalink
attempt to fix tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Li Haoyi committed Jun 5, 2016
1 parent abc35e6 commit d12d976
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ object ErrorTruncationTests extends TestSuite{
file = 'errorTruncation/"runtimeError.scala",
expected =
s"""Exception in thread "main" java.lang.ArithmeticException: / by zero
|${tab}at $runtimeErrorResourcePackage.runtimeError$.<init>(runtimeError.scala:1)
|${tab}at $runtimeErrorResourcePackage.runtimeError$.<clinit>(runtimeError.scala)
|${tab}at $runtimeErrorResourcePackage.runtimeError$$.<init>(runtimeError.scala:1)
|${tab}at $runtimeErrorResourcePackage.runtimeError$$.<clinit>(runtimeError.scala)
|${tab}at $runtimeErrorResourcePackage.runtimeError.$$main(runtimeError.scala)
|""".stripMargin
)
Expand Down
2 changes: 1 addition & 1 deletion repl/src/test/scala/ammonite/repl/ScriptTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ object ScriptTests extends TestSuite{
val tempDir = ammonite.ops.Path(
java.nio.file.Files.createTempDirectory("ammonite-tester-x")
)
println(tempDir)

val interp1 = createTestInterp(Storage.Folder(tempDir))
val interp2 = createTestInterp(Storage.Folder(tempDir))
interp1.replApi.load.module(scriptPath/"OneBlock.scala")
Expand Down
1 change: 1 addition & 0 deletions repl/src/test/scala/ammonite/repl/TestUtils.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ammonite.repl

object TestUtils {
val sessionPrefix = if (scala2_10) "ammonite.session." else ""
def scala2_10 = scala.util.Properties.versionNumberString.contains("2.10")
}
7 changes: 3 additions & 4 deletions repl/src/test/scala/ammonite/repl/session/AdvancedTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,13 @@ import ammonite.repl.TestUtils._
import ammonite.repl.{TestRepl, Res}
import utest._

import scala.collection.{immutable => imm}

object AdvancedTests extends TestSuite{
val tests = TestSuite{
println("AdvancedTests")
val check = new TestRepl()
'pprint{
check.session("""
check.session(s"""
@ Seq.fill(10)(Seq.fill(3)("Foo"))
res0: Seq[Seq[String]] = List(
List("Foo", "Foo", "Foo"),
Expand All @@ -30,14 +29,14 @@ object AdvancedTests extends TestSuite{
defined class Foo

@ Foo(1, "", Nil)
res2: Foo = Foo(1, "", List())
res2: ${sessionPrefix}Foo = Foo(1, "", List())

@ Foo(
@ 1234567,
@ "I am a cow, hear me moo",
@ Seq("I weigh twice as much as you", "and I look good on the barbecue")
@ )
res3: Foo = Foo(
res3: ${sessionPrefix}Foo = Foo(
1234567,
"I am a cow, hear me moo",
List("I weigh twice as much as you", "and I look good on the barbecue")
Expand Down
25 changes: 13 additions & 12 deletions repl/src/test/scala/ammonite/repl/session/EvaluatorTests.scala
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package ammonite.repl.session

import ammonite.repl.TestRepl
import ammonite.repl.TestUtils._
import utest._

import scala.collection.{immutable => imm}
Expand Down Expand Up @@ -101,18 +102,18 @@ object EvaluatorTests extends TestSuite{
""")
}
'types{
check.session("""
check.session(s"""
@ type Funky = Array[Array[String]]
defined type Funky

@ val arr: Funky = Array(Array("Hello!"))
arr: Funky = Array(Array("Hello!"))
arr: ${sessionPrefix}Funky = Array(Array("Hello!"))

@ type Funky2[T] = Array[Array[T]]
defined type Funky2

@ val arr: Funky2[Int] = Array(Array(123))
arr: Funky2[Int] = Array(Array(123))
arr: ${sessionPrefix}Funky2[Int] = Array(Array(123))
""")
}
'library{
Expand All @@ -129,36 +130,36 @@ object EvaluatorTests extends TestSuite{
}

'classes{
check.session("""
check.session(s"""
@ class C{override def toString() = "Ceee"}
defined class C

@ new C
res1: C = Ceee
res1: ${sessionPrefix}C = Ceee

@ case object CO
defined object CO

@ CO
res3: CO.type = CO
res3: ${sessionPrefix}CO.type = CO

@ case class CC()
defined class CC

@ CC()
res5: CC = CC()
res5: ${sessionPrefix}CC = CC()

@ CO
res6: CO.type = CO
res6: ${sessionPrefix}CO.type = CO

@ case class CO()
defined class CO

@ CO
res8: CO.type = CO
res8: ${sessionPrefix}CO.type = CO

@ CO()
res9: CO = CO()
res9: ${sessionPrefix}CO = CO()
""")
}

Expand Down Expand Up @@ -192,7 +193,7 @@ object EvaluatorTests extends TestSuite{
""")
}
'multistatement{
check.session("""
check.session(s"""
@ ;1; 2L; '3';
res0_0: Int = 1
res0_1: Long = 2L
Expand All @@ -212,7 +213,7 @@ object EvaluatorTests extends TestSuite{
res3_2: Int = 3

@ C()
res4: C = C(0)
res4: ${sessionPrefix}C = C(0)
""")
}

Expand Down
12 changes: 6 additions & 6 deletions repl/src/test/scala/ammonite/repl/session/ImportTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ object ImportTests extends TestSuite{
// Make sure that you can have a term and a type of the same name
// coming from different places and they don't stomp over each other
// (#199) and both are accessible.
* - check.session("""
* - check.session(s"""
@ val Foo = 1

@ type Foo = Int
Expand All @@ -174,11 +174,11 @@ object ImportTests extends TestSuite{
res2: Int = 1

@ 2: Foo
res3: Foo = 2
res3: ${sessionPrefix}Foo = 2
""")

* - {
val pkg2 = if (scala2_10) "pkg2." else ""
val pkg2 = if (scala2_10) sessionPrefix + "pkg2." else ""
check.session(s"""
@ object pkg1{ val Order = "lolz" }

Expand Down Expand Up @@ -230,9 +230,9 @@ object ImportTests extends TestSuite{
val prefix1 = if (scala2_10) "ammonite.repl.testcode.paulp1." else ""
val prefix2 = if (scala2_10) "ammonite.repl.testcode.paulp2." else ""
val prefix3 = if (scala2_10) "ammonite.repl.testcode.paulp3." else ""
val prefix4 = if (scala2_10) "Paulp4." else ""
val prefix5 = if (scala2_10) "Paulp5." else ""
val prefix6 = if (scala2_10) "Paulp6." else ""
val prefix4 = if (scala2_10) "ammonite.session.Paulp4." else ""
val prefix5 = if (scala2_10) "ammonite.session.Paulp5." else ""
val prefix6 = if (scala2_10) "ammonite.session.Paulp6." else ""
'paulp - {

check.session(s"""
Expand Down

0 comments on commit d12d976

Please sign in to comment.