C0 code coverage information
Generated on Tue Nov 04 04:48:28 -0200 2008 with
rcov 0.8.1.2
Code reported as executed by Ruby looks like
this... and this: this line is also marked as
covered. Lines considered as run by rcov, but
not reported by Ruby, look like this, and
this: these lines were inferred by rcov (using simple heuristics).
Finally, here's a line marked as not
executed.
1
require 'grid_search' 2
3 class CartesianIterator
4 5 include GridSearch 6 7 def initialize(foo, bar) 8 @lists = [] 9 @tot_iter = 1 10 product!(foo) 11 product!(bar) 12 end 13 14
def dup 15
Marshal.load(Marshal.dump(self)) 16 end 17 18
def equal(other) 19
self.instance_variables.each do |var_name| 20 return false if self.instance_variable_get(var_name)
!= other.instance_variable_get(var_name) 21 end
22 true 23 end
24 alias == equal
25 26 def product!(other) 27 @lists << other.to_a.dup
28 @tot_iter *=
@lists[-1].size 29 self
30 end 31 alias right_product! product!
32 alias x! product!
33 34 def left_product!(other)
35 @lists.unshift
other.to_a.dup 36
@tot_iter *= @lists[-1].size 37 self 38 end 39 40
def product(other) 41
(result = self.dup).product!(other) 42 result 43 end
44 alias right_product product 45 alias x product 46 47
def left_product(other)
48 (result = self.dup).left_product!(other) 49 result 50 end 51 52
def each 53 return false
if @tot_iter < 1 54
55 elems = []
56 for list in @lists
57 elems <<
list.restart_and_raw_next 58 end
59 yield *elems 60
61 last_list_index =
@lists.size-1 62 n =
last_list_index 63 loop
do 64 if elems[n] =
@lists[n].raw_next 65
yield *elems 66 n =
last_list_index 67 next
68 elsif n > 0
69 elems[n] =
@lists[n].restart_and_raw_next 70 n -= 1 71 else 72 return true 73 end 74 end 75 end 76 77
def to_a 78 array = []
79 self.each {|*element|
array << element }
80 array 81 end
82 83 end 84 85 module Iterable 86 def restart 87 @next_index = -1 88 true 89 end
90 alias start restart
91 92 def next
93 @next_index or restart
94 raw_next 95 end 96 97 def raw_next 98 self[@next_index += 1] 99 end 100 101 def restart_and_raw_next 102 self[@next_index = 0] 103 end 104 end 105 106 class Array 107 include Iterable 108 end
Generated using the rcov
code coverage analysis tool for Ruby version 0.8.1.2.