mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Fix warnings from Crystal 1.5.0 regarding positional parameters
This commit is contained in:
parent
41dea9c985
commit
99a0013127
8 changed files with 15 additions and 10 deletions
|
@ -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}}]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue