Closed
Description
Okay, not a good title, but this one is rather weird :P
class EqualMatcher
def initialize(@other)
end
def matches(obj)
obj == @other
end
end
class Expectation
def initialize(@target)
end
def to(matcher)
pp self
pp @target unless matcher.matches(@target)
end
end
Expectation.new([1]).to EqualMatcher.new([1])
Expectation.new([1, nil]).to EqualMatcher.new([1, nil])
Expectation.new([1] == [1]).to EqualMatcher.new(true)
Output:
self = #<Expectation(Array(Int32)):0x13A9FA0 @target=[1]>
self = #<Expectation(Array((Int32 | Nil))):0x13A9F20 @target=[1, nil]>
self = #<Expectation(Bool):0x13ABFB0 @target=false>
@target = false
Changing to EqualMatcher
to
class EqualMatcher(T)
def initialize(@other : T)
end
def matches(obj)
obj == @other
end
end
fixes the result (no @target = false
in the output). My guess is a missing error case / exception.
Metadata
Assignees
Labels
No labels
Activity