Skip to content
Snippets Groups Projects
Commit 92fd83a4 authored by Régis Blanc's avatar Régis Blanc
Browse files

add a method to write a program to a file in valid scala syntax

parent 604d34eb
No related branches found
No related tags found
No related merge requests found
......@@ -43,7 +43,7 @@ class TestGeneration(reporter: Reporter) extends Analyser(reporter) {
val Program(id, ObjectDef(objId, defs, invariants)) = program
val testProgram = Program(id, ObjectDef(objId, testFun +: defs , invariants))
println("New program:\n" + ScalaPrinter(testProgram))
testProgram.writeScalaFile("TestGen.scala")
reporter.info("Running from waypoint with the following testcases:\n")
reporter.info(testcases.mkString("\n"))
......
......@@ -54,6 +54,15 @@ object Definitions {
def caseClassDef(name: String) = mainObject.caseClassDef(name)
def allIdentifiers : Set[Identifier] = mainObject.allIdentifiers + id
def isPure: Boolean = definedFunctions.forall(fd => fd.body.forall(Trees.isPure) && fd.precondition.forall(Trees.isPure) && fd.postcondition.forall(Trees.isPure))
def writeScalaFile(filename: String) {
import java.io.FileWriter
import java.io.BufferedWriter
val fstream = new FileWriter(filename)
val out = new BufferedWriter(fstream)
out.write(ScalaPrinter(this))
out.close
}
}
/** Objects work as containers for class definitions, functions (def's) and
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment