1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
require 'rspec'
require 'immutable/hash'
require 'immutable/set'
require 'immutable/vector'
require 'immutable/sorted_set'
require 'immutable/list'
require 'immutable/deque'
require 'immutable/core_ext'
require 'immutable/nested'
# Suppress warnings from use of old RSpec expectation and mock syntax
# If all tests are eventually updated to use the new syntax, this can be removed
RSpec.configure do |config|
config.expect_with :rspec do |c|
c.syntax = [:should, :expect]
end
config.mock_with :rspec do |c|
c.syntax = [:should, :expect]
end
end
V = Immutable::Vector
L = Immutable::List
H = Immutable::Hash
S = Immutable::Set
SS = Immutable::SortedSet
D = Immutable::Deque
EmptyList = Immutable::EmptyList
Struct.new('Customer', :name, :address)
def fixture(name)
File.read(fixture_path(name))
end
def fixture_path(name)
File.join('spec', 'fixtures', name)
end
if RUBY_ENGINE == 'ruby'
def calculate_stack_overflow_depth(n)
calculate_stack_overflow_depth(n + 1)
rescue SystemStackError
n
end
STACK_OVERFLOW_DEPTH = calculate_stack_overflow_depth(2)
else
STACK_OVERFLOW_DEPTH = 16_384
end
BigList = Immutable.interval(0, STACK_OVERFLOW_DEPTH)
class DeterministicHash
attr_reader :hash, :value
def initialize(value, hash)
@value = value
@hash = hash
end
def to_s
@value.to_s
end
def inspect
@value.inspect
end
def ==(other)
other.is_a?(DeterministicHash) && value == other.value
end
alias eql? ==
def <=>(other)
value <=> other.value
end
end
class EqualNotEql
def ==(other)
true
end
def eql?(other)
false
end
end
class EqlNotEqual
def ==(other)
false
end
def eql?(other)
true
end
end
|