Class: BareTypes::F32

Inherits:
BarePrimitive show all
Defined in:
lib/generative_testing/monkey_patch.rb,
lib/types.rb

Overview

region Floats

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BarePrimitive

#==, #finalize_references, #to_schema

Methods inherited from BaseType

#cycle_search, #initialize

Constructor Details

This class inherits a constructor from BareTypes::BaseType

Class Method Details

.make(depth, names) ⇒ Object



108
109
110
# File 'lib/generative_testing/monkey_patch.rb', line 108

def self.make(depth, names)
  self.new
end

Instance Method Details

#create_inputObject



112
113
114
115
116
117
118
119
120
121
122
# File 'lib/generative_testing/monkey_patch.rb', line 112

def create_input
  float = nil
  loop do
    input = [rand(266), rand(266), rand(266), rand(266)]
    float = input.pack("cccc").unpack('e')
    if float[0] == float[0] && !float[0].nan?
      break
    end
  end
  float[0]
end

#decode(msg) ⇒ Object



184
185
186
# File 'lib/types.rb', line 184

def decode(msg)
  return msg.unpack("e")[0], msg[4..msg.size]
end

#encode(msg, buffer) ⇒ Object



180
181
182
# File 'lib/types.rb', line 180

def encode(msg, buffer)
  buffer << [msg].pack("e")
end