import java.io.{File, FileReader}
import javax.script.ScriptEngineManager
import jscl.converter.Converter

val home = System.getProperty("user.dir")
val dir = new File(new File(home), "examples")
val manager = new ScriptEngineManager
val converter = Converter.instance("mmlscala.xsl")

val list = List("pp1", "pp2", "polynomial", "solvable_polynomial", "gb", "group", "bigint", "modint", "mod_polynomial", "product", "rational", "rational_polynomial", "univariate_polynomial", "rf", "rfi", "complex", "complex_residue", "an", "module", "gcd_subres", "gcd_multivariate", "polypower", "primes1", "primes2", "interface")

def task(name: String) = {
  println(name)
  val file = new File(dir, name)
  val engine = manager.getEngineByName("scala")
  val reader = new FileReader(file)
  val code = converter(reader)
  try {
    engine.eval(code)
    1
  } catch {
    case e : Throwable => {
      e.printStackTrace
      println(name + " failure")
      0
    }
  } finally {
    reader.close
  }
}

val n = (0 /: (list map task)) { (l, r) => l + r }
val m = list.length - n
println("success : " + n + ", failure : " + m)