90 lines
3.4 KiB
Scala
90 lines
3.4 KiB
Scala
package wacc
|
|
|
|
import org.scalatest.{ParallelTestExecution, BeforeAndAfterAll}
|
|
import org.scalatest.flatspec.AnyFlatSpec
|
|
import org.scalatest.Inspectors.forEvery
|
|
|
|
class ParallelExamplesSpec extends AnyFlatSpec with BeforeAndAfterAll with ParallelTestExecution {
|
|
val files =
|
|
allWaccFiles("wacc-examples/valid").map { p =>
|
|
(p.toString, List(0))
|
|
} ++
|
|
allWaccFiles("wacc-examples/invalid/syntaxErr").map { p =>
|
|
(p.toString, List(100))
|
|
} ++
|
|
allWaccFiles("wacc-examples/invalid/semanticErr").map { p =>
|
|
(p.toString, List(200))
|
|
} ++
|
|
allWaccFiles("wacc-examples/invalid/whack").map { p =>
|
|
(p.toString, List(100, 200))
|
|
}
|
|
|
|
// tests go here
|
|
forEvery(files.filter { (filename, _) =>
|
|
!fileIsDissallowed(filename)
|
|
}) { (filename, expectedResult) =>
|
|
s"$filename" should "be parsed with correct result" in {
|
|
val contents = os.read(os.Path(filename))
|
|
assert(expectedResult.contains(compile(contents)))
|
|
}
|
|
}
|
|
|
|
def allWaccFiles(dir: String): IndexedSeq[os.Path] =
|
|
val d = java.io.File(dir)
|
|
os.walk(os.Path(d.getAbsolutePath)).filter { _.ext == "wacc" }
|
|
|
|
def fileIsDissallowed(filename: String): Boolean =
|
|
Seq(
|
|
// format: off
|
|
// disable formatting to avoid binPack
|
|
// "wacc-examples/valid/advanced",
|
|
// "wacc-examples/valid/array",
|
|
// "wacc-examples/valid/basic/exit",
|
|
// "wacc-examples/valid/basic/skip",
|
|
// "wacc-examples/valid/expressions",
|
|
// "wacc-examples/valid/function/nested_functions",
|
|
// "wacc-examples/valid/function/simple_functions",
|
|
// "wacc-examples/valid/if",
|
|
// "wacc-examples/valid/IO/print",
|
|
// "wacc-examples/valid/IO/read",
|
|
// "wacc-examples/valid/IO/IOLoop.wacc",
|
|
// "wacc-examples/valid/IO/IOSequence.wacc",
|
|
// "wacc-examples/valid/pairs",
|
|
// "wacc-examples/valid/runtimeErr",
|
|
// "wacc-examples/valid/scope",
|
|
// "wacc-examples/valid/sequence",
|
|
// "wacc-examples/valid/variables",
|
|
// "wacc-examples/valid/while",
|
|
// invalid (syntax)
|
|
// "wacc-examples/invalid/syntaxErr/array",
|
|
// "wacc-examples/invalid/syntaxErr/basic",
|
|
// "wacc-examples/invalid/syntaxErr/expressions",
|
|
// "wacc-examples/invalid/syntaxErr/function",
|
|
// "wacc-examples/invalid/syntaxErr/if",
|
|
// "wacc-examples/invalid/syntaxErr/literals",
|
|
// "wacc-examples/invalid/syntaxErr/pairs",
|
|
// "wacc-examples/invalid/syntaxErr/print",
|
|
// "wacc-examples/invalid/syntaxErr/sequence",
|
|
// "wacc-examples/invalid/syntaxErr/variables",
|
|
// "wacc-examples/invalid/syntaxErr/while",
|
|
// invalid (semantic)
|
|
// "wacc-examples/invalid/semanticErr/array",
|
|
// "wacc-examples/invalid/semanticErr/exit",
|
|
// "wacc-examples/invalid/semanticErr/expressions",
|
|
// "wacc-examples/invalid/semanticErr/function",
|
|
// "wacc-examples/invalid/semanticErr/if",
|
|
// "wacc-examples/invalid/semanticErr/IO",
|
|
// "wacc-examples/invalid/semanticErr/multiple",
|
|
// "wacc-examples/invalid/semanticErr/pairs",
|
|
// "wacc-examples/invalid/semanticErr/print",
|
|
// "wacc-examples/invalid/semanticErr/read",
|
|
// "wacc-examples/invalid/semanticErr/scope",
|
|
// "wacc-examples/invalid/semanticErr/variables",
|
|
// "wacc-examples/invalid/semanticErr/while",
|
|
// invalid (whack)
|
|
// "wacc-examples/invalid/whack"
|
|
// format: on
|
|
// format: on
|
|
).find(filename.contains).isDefined
|
|
}
|