Class: Array

Inherits:
Object show all
Defined in:
lib/threading_test_tools.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#data_equal_check_orderObject

Returns the value of attribute data_equal_check_order.



240
241
242
# File 'lib/threading_test_tools.rb', line 240

def data_equal_check_order
  @data_equal_check_order
end

Instance Method Details

#data_equal?(obj, message = nil, recursive_check = {}) ⇒ Boolean

Returns:

  • (Boolean)


242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
# File 'lib/threading_test_tools.rb', line 242

def data_equal?(obj, message = nil, recursive_check = {})
  return true if data_equal_ignore
  if not self.class.data_equal?(obj.class, message, recursive_check)
    !message.nil? and message.unshift '.class'
    return false
  end
  if not self.size.data_equal?(obj.size, message, recursive_check)
    !message.nil? and message.unshift '.size'
    return false
  end
  return recursive_check[[self, obj]] if recursive_check.has_key?([self, obj])
  recursive_check[[self, obj]] = true
  if not data_equal_check_order
    other_indices = (0..(obj.size - 1)).to_a
    self.each do |entry|
      catch :match_found do
        other_indices.each do |other_index|
          if entry.data_equal?(obj[other_index], nil, recursive_check)
            other_indices.delete(other_index)
            throw :match_found
          end
        end
        !message.nil? and message.unshift " has no corresponding entry for #{entry}."
        recursive_check[[self, obj]] = false
        return false
      end
    end
  else
    self.each_index do |index|
      if not self[index].data_equal?(obj[index], message, recursive_check)
        !message.nil? and message.unshift "[#{index}]"
        recursive_check[[self, obj]] = false
        return false
      end
    end
  end
  true
end