Title: [1049] trunk/rcov4jr/java/src/CoverageHook.java: meta programing in some instances adds new lines to a file.
Revision
1049
Author
hooligan495
Date
2008-07-17 16:50:57 -0400 (Thu, 17 Jul 2008)

Log Message

meta programing in some instances adds new lines to a file.  The extension would not add a 0 for each new line if a code line was hit that was high up.

Modified Paths

Diff

Modified: trunk/rcov4jr/java/src/CoverageHook.java (1048 => 1049)


--- trunk/rcov4jr/java/src/CoverageHook.java	2008-07-17 20:49:01 UTC (rev 1048)
+++ trunk/rcov4jr/java/src/CoverageHook.java	2008-07-17 20:50:57 UTC (rev 1049)
@@ -50,13 +50,20 @@
         // make sure file's counts are in COVER and set to zero
         RubyArray counts = (RubyArray) cover.get(file);
         if (counts == null) {
-            RubyArray ary = context.getRuntime().newArray();
+            counts = context.getRuntime().newArray();
             for (int i = 0; i < lines.size(); i++) {
-                ary.add(Long.valueOf(0));
+                counts.add(Long.valueOf(0));
             }
-            cover.put(file, ary);
-            counts = ary;
+            cover.put(file, counts);
         }
+
+		// in the case of code generation (one example is instance_eval for routes optimization)
+		// We could get here and see that we are not matched up with what we expect
+ 		if (counts.size() <= line ) {
+			for (int i=counts.size(); i<= line; i++) {
+			    counts.add(Long.valueOf(0));
+			}
+		}
         
         // update counts in COVER
         Long count = (Long) counts.get(line);
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to