Remove unecessary type restrictions

This commit is contained in:
Michael Miller 2019-01-28 10:04:17 -07:00
parent 592d13d0d4
commit 61a3e6b113
15 changed files with 45 additions and 45 deletions

View File

@ -6,19 +6,19 @@ module Spectator::Matchers
struct CaseMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
def match?(partial) : Bool
expected === partial.actual
end
# Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def message(partial) : String
"Expected #{partial.label} to semantically equal #{label} (using ===)"
end
# Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def negated_message(partial) : String
"Expected #{partial.label} to not semantically equal #{label} (using ===)"
end
end

View File

@ -7,14 +7,14 @@ module Spectator::Matchers
abstract struct ConditionMatcher < Matcher
# Determines whether the matcher is satisfied with the value given to it.
# True is returned if the matcher is satisfied, false otherwise.
abstract def match?(partial : ValueExpectationPartial(ActualType)) : Bool forall ActualType
abstract def match?(partial) : Bool
# Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user.
abstract def message(partial : ValueExpectationPartial(ActualType)) : String forall ActualType
abstract def message(partial) : String
# Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user.
abstract def negated_message(partial : ValueExpectationPartial(ActualType)) : String forall ActualType
abstract def negated_message(partial) : String
end
end

View File

@ -11,19 +11,19 @@ module Spectator::Matchers
# Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
def match?(partial) : Bool
partial.actual.empty?
end
# Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def message(partial) : String
"Expected #{partial.label} to be empty"
end
# Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def negated_message(partial) : String
"Expected #{partial.label} to not be empty"
end
end

View File

@ -6,19 +6,19 @@ module Spectator::Matchers
struct EqualityMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
def match?(partial) : Bool
partial.actual == expected
end
# Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def message(partial) : String
"Expected #{partial.label} to equal #{label} (using ==)"
end
# Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def negated_message(partial) : String
"Expected #{partial.label} to not equal #{label} (using ==)"
end
end

View File

@ -6,19 +6,19 @@ module Spectator::Matchers
struct GreaterThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
def match?(partial) : Bool
partial.actual >= expected
end
# Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def message(partial) : String
"Expected #{partial.label} to be greater than or equal to #{label} (using >=)"
end
# Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def negated_message(partial) : String
"Expected #{partial.label} to not be greater than or equal to #{label} (using >=)"
end
end

View File

@ -6,19 +6,19 @@ module Spectator::Matchers
struct GreaterThanMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
def match?(partial) : Bool
partial.actual > expected
end
# Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def message(partial) : String
"Expected #{partial.label} to be greater than #{label} (using >)"
end
# Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def negated_message(partial) : String
"Expected #{partial.label} to not be greater than #{label} (using >)"
end
end

View File

@ -6,19 +6,19 @@ module Spectator::Matchers
struct InequalityMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
def match?(partial) : Bool
partial.actual != expected
end
# Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def message(partial) : String
"Expected #{partial.label} to not equal #{label} (using !=)"
end
# Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def negated_message(partial) : String
"Expected #{partial.label} to equal #{label} (using !=)"
end
end

View File

@ -6,19 +6,19 @@ module Spectator::Matchers
struct LessThanEqualMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
def match?(partial) : Bool
partial.actual <= expected
end
# Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def message(partial) : String
"Expected #{partial.label} to be less than or equal to #{label} (using <=)"
end
# Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def negated_message(partial) : String
"Expected #{partial.label} to not be less than or equal to #{label} (using <=)"
end
end

View File

@ -6,19 +6,19 @@ module Spectator::Matchers
struct LessThanMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
def match?(partial) : Bool
partial.actual < expected
end
# Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def message(partial) : String
"Expected #{partial.label} to be less than #{label} (using <)"
end
# Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def negated_message(partial) : String
"Expected #{partial.label} to not be less than #{label} (using <)"
end
end

View File

@ -11,19 +11,19 @@ module Spectator::Matchers
# Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
def match?(partial) : Bool
partial.actual.nil?
end
# Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def message(partial) : String
"Expected #{partial.label} to be nil"
end
# Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def negated_message(partial) : String
"Expected #{partial.label} to not be nil"
end
end

View File

@ -8,19 +8,19 @@ module Spectator::Matchers
struct RangeMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
def match?(partial) : Bool
@expected.includes?(partial.actual)
end
# Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def message(partial) : String
"Expected #{partial.label} to be in #{label}"
end
# Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def negated_message(partial) : String
"Expected #{partial.label} to not be in #{label}"
end

View File

@ -6,19 +6,19 @@ module Spectator::Matchers
struct RegexMatcher(ExpectedType) < ValueMatcher(ExpectedType)
# Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
def match?(partial) : Bool
!!(partial.actual =~ expected)
end
# Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def message(partial) : String
"Expected #{partial.label} to match #{label} (using =~)"
end
# Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def negated_message(partial) : String
"Expected #{partial.label} to not match #{label} (using =~)"
end
end

View File

@ -18,20 +18,20 @@ module Spectator::Matchers
# Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
def match?(partial) : Bool
# Cast value to truthy value and compare.
@expected == !!partial.actual
end
# Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def message(partial) : String
"Expected #{partial.label} to be #{label}"
end
# Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def negated_message(partial) : String
"Expected #{partial.label} to not be #{label}"
end

View File

@ -12,19 +12,19 @@ module Spectator::Matchers
# Determines whether the matcher is satisfied with the value given to it.
# True is returned if the match was successful, false otherwise.
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
def match?(partial) : Bool
partial.actual.is_a?(Expected)
end
# Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user.
def message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def message(partial) : String
"Expected #{partial.label} to be a #{label}"
end
# Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user.
def negated_message(partial : Expectations::ValueExpectationPartial(ActualType)) : String forall ActualType
def negated_message(partial) : String
"Expected #{partial.label} to not be a #{label}"
end
end

View File

@ -26,14 +26,14 @@ module Spectator::Matchers
# Determines whether the matcher is satisfied with the value given to it.
# True is returned if the matcher is satisfied, false otherwise.
abstract def match?(partial : ValueExpectationPartial(ActualType)) : Bool forall ActualType
abstract def match?(partial) : Bool
# Describes the condition that satisfies the matcher.
# This is informational and displayed to the end-user.
abstract def message(partial : ValueExpectationPartial(ActualType)) : String forall ActualType
abstract def message(partial) : String
# Describes the condition that won't satsify the matcher.
# This is informational and displayed to the end-user.
abstract def negated_message(partial : ValueExpectationPartial(ActualType)) : String forall ActualType
abstract def negated_message(partial) : String
end
end