Clover coverage report - DynamicJava Test Coverage (dynamicjava-20130518-r5436)
Coverage timestamp: Sat May 18 2013 03:01:28 CDT
file stats: LOC: 61   Methods: 4
NCLOC: 52   Classes: 1
 
 Source file Conditionals Statements Methods TOTAL
DynamicJava.java 0% 0% 0% 0%
coverage
 1    package edu.rice.cs.dynamicjava;
 2   
 3    import java.io.*;
 4    import edu.rice.cs.plt.tuple.Option;
 5    import edu.rice.cs.plt.tuple.OptionVisitor;
 6    import edu.rice.cs.plt.text.TextUtil;
 7    import edu.rice.cs.plt.text.ArgumentParser;
 8    import edu.rice.cs.plt.io.IOUtil;
 9    import edu.rice.cs.plt.reflect.PathClassLoader;
 10    import edu.rice.cs.dynamicjava.interpreter.Interpreter;
 11    import edu.rice.cs.dynamicjava.interpreter.InterpreterException;
 12   
 13    import static edu.rice.cs.plt.debug.DebugUtil.debug;
 14   
 15    public final class DynamicJava {
 16   
 17  0 private DynamicJava() {}
 18   
 19  0 public static void main(String... args) throws IOException {
 20  0 debug.log();
 21   
 22  0 ArgumentParser argParser = new ArgumentParser();
 23  0 argParser.supportOption("classpath", IOUtil.WORKING_DIRECTORY.toString());
 24  0 argParser.supportAlias("cp", "classpath");
 25  0 ArgumentParser.Result parsedArgs = argParser.parse(args);
 26  0 Iterable<File> cp = IOUtil.parsePath(parsedArgs.getUnaryOption("classpath"));
 27   
 28  0 Interpreter i = new Interpreter(Options.DEFAULT, new PathClassLoader(cp));
 29  0 BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
 30  0 String prev = null;
 31  0 boolean blank = false;
 32  0 String input;
 33  0 do {
 34  0 System.out.print("> ");
 35  0 System.out.flush();
 36  0 input = in.readLine();
 37  0 if (input != null) {
 38    // two blank lines trigger a recompute
 39  0 if (input.equals("")) {
 40  0 if (blank == true) { input = prev; blank = false; }
 41  0 else { blank = true; }
 42    }
 43  0 else { prev = input; blank = false; }
 44  0 try {
 45  0 Option<Object> result = i.interpret(input);
 46  0 result.apply(new OptionVisitor<Object, Void>() {
 47  0 public Void forSome(Object o) { System.out.println(TextUtil.toString(o)); return null; }
 48  0 public Void forNone() { return null; }
 49    });
 50    }
 51  0 catch (InterpreterException e) { e.printUserMessage(); debug.log(e); }
 52    catch (RuntimeException e) {
 53  0 System.out.println("INTERNAL ERROR: Uncaught exception");
 54  0 e.printStackTrace(System.out);
 55    }
 56  0 System.out.println();
 57    }
 58  0 } while (input != null);
 59    }
 60   
 61    }