Fix warnings from Crystal 1.5.0 regarding positional parameters

This commit is contained in:
Michael Miller 2022-07-07 18:16:37 -06:00
parent 41dea9c985
commit 99a0013127
No known key found for this signature in database
GPG key ID: 32B47AE8F388A1FF
8 changed files with 15 additions and 10 deletions

View file

@ -17,7 +17,7 @@ module Spectator::Matchers
# Actually performs the test against the expression.
def match(actual : Expression(T)) : MatchData forall T
snapshot = snapshot_values(actual.value)
if match?(snapshot)
if values_match?(snapshot)
SuccessfulMatchData.new(description)
else
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.
def negated_match(actual : Expression(T)) : MatchData forall T
snapshot = snapshot_values(actual.value)
if match?(snapshot)
if values_match?(snapshot)
FailedMatchData.new(description, "#{actual.label} has #{expected.label}", values(snapshot).to_a)
else
SuccessfulMatchData.new(description)
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.
#
# This is only called when `#match?` returns false.
@ -69,7 +74,7 @@ module Spectator::Matchers
end
# 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.
{% for attribute in ExpectedType.keys %}
return false unless snapshot[{{attribute.symbolize}}]

View file

@ -7,7 +7,7 @@ module Spectator::Mocks
super(name, location, args)
end
def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
def call(args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
raise @exception
end
end

View file

@ -10,7 +10,7 @@ module Spectator::Mocks
raise ArgumentError.new("Values must have at least one item") if @values.size < 1
end
def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
def call(args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
value = @values[@index]
@index += 1 if @index < @values.size - 1
value

View file

@ -4,7 +4,7 @@ require "./value_method_stub"
module Spectator::Mocks
class NilMethodStub < GenericMethodStub(Nil)
def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
def call(args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
nil
end

View file

@ -3,7 +3,7 @@ require "./generic_method_stub"
module Spectator::Mocks
class OriginalMethodStub < GenericMethodStub(Nil)
def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
def call(args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
yield
end
end

View file

@ -11,7 +11,7 @@ module Spectator::Mocks
ProcMethodStub.new(name, location, block, args)
end
def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
def call(args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
@proc.call
end
end

View file

@ -7,7 +7,7 @@ module Spectator::Mocks
super(name, location, args)
end
def call(_args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
def call(args : GenericArguments(T, NT), & : -> RT) forall T, NT, RT
@value
end
end

View file

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