// Path: src/main/com/olabini/jescov/LineCoverage.java
// public class LineCoverage {
//     private final int line;
//     private final int hits;
// 
//     public LineCoverage(int line, int hits) {
//         this.line = line;
//         this.hits = hits;
//     }
// 
//     public int getLine() {
//         return this.line;
//     }
// 
//     public int getHits() {
//         return this.hits;
//     }
// 
//     public int getLinesValid() {
//         return 1;
//     }
// 
//     public int getLinesCovered() {
//         return hits > 0 ? 1 : 0;
//     }
// }
// 
// Path: src/main/com/olabini/jescov/CoverageData.java
// public class CoverageData {
//     private final Map<String, FileCoverage> fileCoverage;
// 
//     public CoverageData(List<FileCoverage> fileCoverage) {
//         this.fileCoverage = new TreeMap<String, FileCoverage>();
//         for(FileCoverage fc : fileCoverage) {
//             this.fileCoverage.put(fc.getFilename(), fc);
//         }
//     }
// 
//     public FileCoverage getFileCoverageFor(String filename) {
//         return fileCoverage.get(filename);
//     }
// 
//     public Collection<String> getFileNames() {
//         return fileCoverage.keySet();
//     }
// 
//     public int getLinesValid() {
//         int sum = 0;
//         for(FileCoverage fc : fileCoverage.values()) {
//             sum += fc.getLinesValid();
//         }
//         return sum;
//     }
// 
//     public int getBranchesValid() {
//         int sum = 0;
//         for(FileCoverage fc : fileCoverage.values()) {
//             sum += fc.getBranchesValid();
//         }
//         return sum;
//     }
// 
//     public int getLinesCovered() {
//         int sum = 0;
//         for(FileCoverage fc : fileCoverage.values()) {
//             sum += fc.getLinesCovered();
//         }
//         return sum;
//     }
// 
//     public int getBranchesCovered() {
//         int sum = 0;
//         for(FileCoverage fc : fileCoverage.values()) {
//             sum += fc.getBranchesCovered();
//         }
//         return sum;
//     }
// 
//     public double getLineRate() {
//         return getLinesCovered() / (double)getLinesValid();
//     }
// 
//     public double getBranchRate() {
//         return getBranchesCovered() / (double)getBranchesValid();
//     }
// 
//     public CoverageData plus(CoverageData other) {
//         List<FileCoverage> fcs = new ArrayList<FileCoverage>();
//         Set<String> files = new HashSet<String>();
//         files.addAll(this.getFileNames());
//         files.addAll(other.getFileNames());
//         for(String file : files) {
//             FileCoverage left = this.getFileCoverageFor(file);
//             FileCoverage right = other.getFileCoverageFor(file);
// 
//             if(left == null || right == null) {
//                 if(left == null) {
//                     fcs.add(right);
//                 } else {
//                     fcs.add(left);
//                 }
//             } else {
//                 fcs.add(left.plus(right));
//             }
//         }
// 
//         return new CoverageData(fcs);
//     }
// }
// 
// Path: src/main/com/olabini/jescov/console/Runner.java
// public class Runner {
//     private final Context ctx;
//     private final Scriptable scope;
//     private final Coverage coverage;
//     private final Configuration configuration;
// 
//     public Runner(Configuration configuration) {
//         ctx = Context.enter();
//         scope = ctx.initStandardObjects();
//         this.configuration = configuration;
//         coverage = on(ctx, scope, configuration);
//     }
// 
//     public CoverageData done() {
//         coverage.done();
//         Context.exit();
//         return coverage.getCoverageData();
//     }
// 
//     public void executeReader(String filename, Reader reader) throws IOException {
//         ctx.evaluateReader(scope, reader, filename, 0, null);
//     }
// 
//     public void executeSource(String filename, String sourceCode) {
//         ctx.evaluateString(scope, sourceCode, filename, 0, null);
//     }
// 
//     public static void main(final String[] args) throws Exception {
//         Configuration c = new Configuration();
//         String fileout = c.getJsonOutputFile();
//         FileWriter fw = new FileWriter(fileout);
//         c.setGenerator(new CombinedGenerator(new JsonGenerator(fw), new HtmlGenerator(c)));
//         Runner r = new Runner(c);
//         for(String file : args) {
//             r.executeReader(file, new FileReader(file));
//         }
//         CoverageData data = r.done();
// 
//         if(c.isJsonOutputMerge() && new File(fileout).exists()) {
//             FileReader fr = new FileReader(fileout);
//             CoverageData moreData = new JsonIngester().ingest(fr);
//             fr.close();
//             data = moreData.plus(data);
//         }
//         
//         c.getGenerator().generate(data);
//         fw.close();
//     }
// }// Runner


import com.olabini.jescov.LineCoverage;
import com.olabini.jescov.CoverageData;
import com.olabini.jescov.console.Runner;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;
/*
 * See LICENSE file in distribution for copyright and licensing information.
 */
package com.olabini.jescov.matchers;


public class LineCoverageMatcher extends TypeSafeMatcher<CoverageData> {
    private final int expected;
    private final Integer line;

    public LineCoverageMatcher(int expected) {
        this(expected, null);
    }

    public LineCoverageMatcher(int expected, Integer line) {
        this.expected = expected;
        this.line = line;
    }

// Path: src/main/com/olabini/jescov/LineCoverage.java
// public class LineCoverage {
//     private final int line;
//     private final int hits;
// 
//     public LineCoverage(int line, int hits) {
//         this.line = line;
//         this.hits = hits;
//     }
// 
//     public int getLine() {
//         return this.line;
//     }
// 
//     public int getHits() {
//         return this.hits;
//     }
// 
//     public int getLinesValid() {
//         return 1;
//     }
// 
//     public int getLinesCovered() {
//         return hits > 0 ? 1 : 0;
//     }
// }
// 
// Path: src/main/com/olabini/jescov/CoverageData.java
// public class CoverageData {
//     private final Map<String, FileCoverage> fileCoverage;
// 
//     public CoverageData(List<FileCoverage> fileCoverage) {
//         this.fileCoverage = new TreeMap<String, FileCoverage>();
//         for(FileCoverage fc : fileCoverage) {
//             this.fileCoverage.put(fc.getFilename(), fc);
//         }
//     }
// 
//     public FileCoverage getFileCoverageFor(String filename) {
//         return fileCoverage.get(filename);
//     }
// 
//     public Collection<String> getFileNames() {
//         return fileCoverage.keySet();
//     }
// 
//     public int getLinesValid() {
//         int sum = 0;
//         for(FileCoverage fc : fileCoverage.values()) {
//             sum += fc.getLinesValid();
//         }
//         return sum;
//     }
// 
//     public int getBranchesValid() {
//         int sum = 0;
//         for(FileCoverage fc : fileCoverage.values()) {
//             sum += fc.getBranchesValid();
//         }
//         return sum;
//     }
// 
//     public int getLinesCovered() {
//         int sum = 0;
//         for(FileCoverage fc : fileCoverage.values()) {
//             sum += fc.getLinesCovered();
//         }
//         return sum;
//     }
// 
//     public int getBranchesCovered() {
//         int sum = 0;
//         for(FileCoverage fc : fileCoverage.values()) {
//             sum += fc.getBranchesCovered();
//         }
//         return sum;
//     }
// 
//     public double getLineRate() {
//         return getLinesCovered() / (double)getLinesValid();
//     }
// 
//     public double getBranchRate() {
//         return getBranchesCovered() / (double)getBranchesValid();
//     }
// 
//     public CoverageData plus(CoverageData other) {
//         List<FileCoverage> fcs = new ArrayList<FileCoverage>();
//         Set<String> files = new HashSet<String>();
//         files.addAll(this.getFileNames());
//         files.addAll(other.getFileNames());
//         for(String file : files) {
//             FileCoverage left = this.getFileCoverageFor(file);
//             FileCoverage right = other.getFileCoverageFor(file);
// 
//             if(left == null || right == null) {
//                 if(left == null) {
//                     fcs.add(right);
//                 } else {
//                     fcs.add(left);
//                 }
//             } else {
//                 fcs.add(left.plus(right));
//             }
//         }
// 
//         return new CoverageData(fcs);
//     }
// }
// 
// Path: src/main/com/olabini/jescov/console/Runner.java
// public class Runner {
//     private final Context ctx;
//     private final Scriptable scope;
//     private final Coverage coverage;
//     private final Configuration configuration;
// 
//     public Runner(Configuration configuration) {
//         ctx = Context.enter();
//         scope = ctx.initStandardObjects();
//         this.configuration = configuration;
//         coverage = on(ctx, scope, configuration);
//     }
// 
//     public CoverageData done() {
//         coverage.done();
//         Context.exit();
//         return coverage.getCoverageData();
//     }
// 
//     public void executeReader(String filename, Reader reader) throws IOException {
//         ctx.evaluateReader(scope, reader, filename, 0, null);
//     }
// 
//     public void executeSource(String filename, String sourceCode) {
//         ctx.evaluateString(scope, sourceCode, filename, 0, null);
//     }
// 
//     public static void main(final String[] args) throws Exception {
//         Configuration c = new Configuration();
//         String fileout = c.getJsonOutputFile();
//         FileWriter fw = new FileWriter(fileout);
//         c.setGenerator(new CombinedGenerator(new JsonGenerator(fw), new HtmlGenerator(c)));
//         Runner r = new Runner(c);
//         for(String file : args) {
//             r.executeReader(file, new FileReader(file));
//         }
//         CoverageData data = r.done();
// 
//         if(c.isJsonOutputMerge() && new File(fileout).exists()) {
//             FileReader fr = new FileReader(fileout);
//             CoverageData moreData = new JsonIngester().ingest(fr);
//             fr.close();
//             data = moreData.plus(data);
//         }
//         
//         c.getGenerator().generate(data);
//         fw.close();
//     }
// }// Runner


// Path: src/test/com/olabini/jescov/matchers/LineCoverageMatcher.java
import com.olabini.jescov.LineCoverage;
import com.olabini.jescov.CoverageData;
import com.olabini.jescov.console.Runner;
import org.hamcrest.Description;
import org.hamcrest.TypeSafeMatcher;

/*
 * See LICENSE file in distribution for copyright and licensing information.
 */
package com.olabini.jescov.matchers;


public class LineCoverageMatcher extends TypeSafeMatcher<CoverageData> {
    private final int expected;
    private final Integer line;

    public LineCoverageMatcher(int expected) {
        this(expected, null);
    }

    public LineCoverageMatcher(int expected, Integer line) {
        this.expected = expected;
        this.line = line;
    }

    private LineCoverage lc;