aboutsummaryrefslogtreecommitdiff
path: root/lab2/src/test/scala/jsy/tester/JavascriptyTester.scala
blob: ab611b9fa35adea1dd61a1d8e7bd2f016ac3dc7f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package jsy.tester

import java.io.File

import jsy.util.JsyApplication
import org.scalatest._
import flatspec._

/*
 * A ScalaTest interface for running system tests.
 */
class JavascriptyTester(rootPrefix: Option[String], testDirectory: String, jsy: JsyApplication) extends AnyFlatSpec {

  val testResources = s"src${File.separator}test${File.separator}resources"
  val testPrefix = rootPrefix match {
    case None => testResources
    case Some(p) => s"${p}${File.separator}${testResources}"
  }
  val testPath = s"${testPrefix}${File.separator}${testDirectory}"
  jsy.test(new File(testPath)) { case (in,ans,assertion) =>
    s"eval on ${in}" should s"match ${ans}" in {
      val (b: Boolean, msg: String) = assertion
      assert(b, msg)
    }
  }

}