Class: DFuzz::Fudge

Inherits:
Generator show all
Defined in:
lib/dfuzz/fudge.rb

Overview

Generate Xi-F…Xi+F for each Xi in boundaries and fudge_factor F

Direct Known Subclasses

Integer

Instance Method Summary collapse

Methods inherited from Generator

#current, #each, #empty?, #end?, #index, #next, #next?, #pos, #rewind, #shift, #yield

Constructor Details

#initialize(boundaries, fudge_factor, mask = nil) ⇒ Fudge

Returns a new instance of Fudge.



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/dfuzz/fudge.rb', line 6

def initialize(boundaries, fudge_factor, mask = nil)
  super() { |g|
    boundaries.each {|b|
      0.upto(fudge_factor) { |f|
        if (mask)
          g.yield((b+f) & mask)
          g.yield((b-f) & mask)
        else
          g.yield b+f
          g.yield b-f
        end
      }
    }
  }
end