Title: [1046] trunk/rcov4jr/java/src/RcovrtService.java: changed the way we copy the coverage hash at the time of generateCoverage before it was a shallow copy which was causing start and end comparisons to fail in rcov .
Revision
1046
Author
hooligan495
Date
2008-07-10 15:16:37 -0400 (Thu, 10 Jul 2008)

Log Message

changed the way we copy the coverage hash at the time of generateCoverage before it was a shallow copy which was causing start and end comparisons to fail in rcov.

Modified Paths

Diff

Modified: trunk/rcov4jr/java/src/RcovrtService.java (1045 => 1046)


--- trunk/rcov4jr/java/src/RcovrtService.java	2008-07-07 23:14:19 UTC (rev 1045)
+++ trunk/rcov4jr/java/src/RcovrtService.java	2008-07-10 19:16:37 UTC (rev 1046)
@@ -68,16 +68,28 @@
     */
     @JRubyMethod(name="generate_coverage_info", meta = true)
     public static IRubyObject generateCoverageInfo(IRubyObject recv) {
-        IRubyObject cover = CoverageHook.getCoverageHook().getCover(recv.getRuntime()).dup();
+        RubyHash cover = (RubyHash)CoverageHook.getCoverageHook().getCover(recv.getRuntime());
+		//copy a hash not sure there is a better way.
+		Ruby run = recv.getRuntime();
+		RubyHash xcover = RubyHash.newHash(run);
+		RubyArray keys = cover.keys();
+		RubyArray temp;
+		org.jruby.runtime.ThreadContext  ctx = run.getCurrentContext();
+		for (int i=0; i < keys.length().getLongValue(); i++) {
+			IRubyObject key = keys.aref(org.jruby.javasupport.JavaUtil.convertJavaToRuby(run, Long.valueOf(i)));
+			temp = ((RubyArray)cover.op_aref(ctx, key)).aryDup();
+			xcover.op_aset(ctx,key, temp);
+		}
         RubyModule rcov__ = (RubyModule) recv.getRuntime().getModule("Rcov").getConstant("RCOV__");
+
         if (rcov__.const_defined_p(RubySymbol.newSymbol(recv.getRuntime(), "COVER")).isTrue()) {
             rcov__.remove_const(recv.getRuntime().newString("COVER"));
         } 
-        rcov__.defineConstant( "COVER", cover );
-        
-        return cover;
-    }
+        rcov__.defineConstant( "COVER", xcover );
 
+        return xcover;
+   }
+
     @JRubyMethod(name="remove_callsite_hook", meta = true)
     public static IRubyObject removeCallsiteHook(IRubyObject recv) {
         return removeRcovHook( recv, CallsiteHook.getCallsiteHook() );
_______________________________________________
Jruby-extras-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/jruby-extras-devel

Reply via email to