Better handling with be match against Value types and nil

Releates to https://github.com/icy-arctic-fox/spectator/issues/37
This commit is contained in:
Michael Miller 2021-09-28 18:22:41 -06:00
parent 99ced17516
commit a95c5bcab7
No known key found for this signature in database
GPG key ID: F9A0C5C65B162436
2 changed files with 4 additions and 1 deletions

View file

@ -14,7 +14,9 @@ module Spectator::Matchers
# Checks whether the matcher is satisifed with the expression given to it.
private def match?(actual : Expression(T)) : Bool forall T
value = expected.value
if value && value.responds_to?(:same?)
if value.nil?
actual.value.nil?
elsif value.responds_to?(:same?)
value.same?(actual.value)
else
# Value type (struct) comparison.