Fix warnings from Crystal 1.5.0 regarding positional parameters

This commit is contained in:
Michael Miller 2022-07-07 18:10:21 -06:00
parent f7147299ab
commit 70391b2d31
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF
5 changed files with 13 additions and 8 deletions

View file

@ -17,7 +17,7 @@ module Spectator::Matchers
# Actually performs the test against the expression. # Actually performs the test against the expression.
def match(actual : Expression(T)) : MatchData forall T def match(actual : Expression(T)) : MatchData forall T
snapshot = snapshot_values(actual.value) snapshot = snapshot_values(actual.value)
if match?(snapshot) if values_match?(snapshot)
SuccessfulMatchData.new(description) SuccessfulMatchData.new(description)
else else
FailedMatchData.new(description, "#{actual.label} does not have #{expected.label}", values(snapshot).to_a) FailedMatchData.new(description, "#{actual.label} does not have #{expected.label}", values(snapshot).to_a)
@ -28,13 +28,18 @@ module Spectator::Matchers
# A successful match with `#match` should normally fail for this method, and vice-versa. # A successful match with `#match` should normally fail for this method, and vice-versa.
def negated_match(actual : Expression(T)) : MatchData forall T def negated_match(actual : Expression(T)) : MatchData forall T
snapshot = snapshot_values(actual.value) snapshot = snapshot_values(actual.value)
if match?(snapshot) if values_match?(snapshot)
FailedMatchData.new(description, "#{actual.label} has #{expected.label}", values(snapshot).to_a) FailedMatchData.new(description, "#{actual.label} has #{expected.label}", values(snapshot).to_a)
else else
SuccessfulMatchData.new(description) SuccessfulMatchData.new(description)
end end
end end
def match?(actual : Expression(T)) : Bool forall T
snapshot = snapshot_values(actual.value)
values_match?(snapshot)
end
# Message displayed when the matcher isn't satisfied. # Message displayed when the matcher isn't satisfied.
# #
# This is only called when `#match?` returns false. # This is only called when `#match?` returns false.
@ -69,7 +74,7 @@ module Spectator::Matchers
end end
# Checks if all predicate methods from the snapshot of them are satisfied. # Checks if all predicate methods from the snapshot of them are satisfied.
private def match?(snapshot) : Bool private def values_match?(snapshot) : Bool
# Test each predicate and immediately return false if one is false. # Test each predicate and immediately return false if one is false.
{% for attribute in ExpectedType.keys %} {% for attribute in ExpectedType.keys %}
return false unless snapshot[{{attribute.symbolize}}] return false unless snapshot[{{attribute.symbolize}}]

View file

@ -153,7 +153,7 @@ module Spectator
yield yield
end end
private def _spectator_stub_fallback(call : MethodCall, _type, &) private def _spectator_stub_fallback(call : MethodCall, type, &)
_spectator_stub_fallback(call) { yield } _spectator_stub_fallback(call) { yield }
end end
@ -167,7 +167,7 @@ module Spectator
raise UnexpectedMessage.new("#{_spectator_stubbed_name} received unexpected message #{call}") raise UnexpectedMessage.new("#{_spectator_stubbed_name} received unexpected message #{call}")
end end
private def _spectator_abstract_stub_fallback(call : MethodCall, _type) private def _spectator_abstract_stub_fallback(call : MethodCall, type)
_spectator_abstract_stub_fallback(call) _spectator_abstract_stub_fallback(call)
end end

View file

@ -5,7 +5,7 @@ module Spectator
# Stub that does nothing and returns nil. # Stub that does nothing and returns nil.
class NullStub < TypedStub(Nil) class NullStub < TypedStub(Nil)
# Invokes the stubbed implementation. # Invokes the stubbed implementation.
def call(_call : MethodCall) : Nil def call(call : MethodCall) : Nil
end end
end end
end end

View file

@ -7,7 +7,7 @@ module Spectator
# Stub that responds with a static value. # Stub that responds with a static value.
class ValueStub(T) < TypedStub(T) class ValueStub(T) < TypedStub(T)
# Invokes the stubbed implementation. # Invokes the stubbed implementation.
def call(_call : MethodCall) : T def call(call : MethodCall) : T
@value @value
end end

View file

@ -9,7 +9,7 @@ module Spectator
end end
# Checks whether the node satisfies the filter. # Checks whether the node satisfies the filter.
def includes?(_node) : Bool def includes?(node) : Bool
@match @match
end end
end end