mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Allow matchers to be used in case equality
This commit is contained in:
parent
5520999b6d
commit
b5fbc96195
1 changed files with 14 additions and 0 deletions
|
@ -1,3 +1,4 @@
|
|||
require "../value"
|
||||
require "./match_data"
|
||||
|
||||
module Spectator::Matchers
|
||||
|
@ -22,6 +23,19 @@ module Spectator::Matchers
|
|||
# A successful match with `#match` should normally fail for this method, and vice-versa.
|
||||
abstract def negated_match(actual : Expression(T)) : MatchData forall T
|
||||
|
||||
# Compares a matcher against a value.
|
||||
# Enables composable matchers.
|
||||
def ===(actual : Expression(T)) : Bool
|
||||
match(actual).matched?
|
||||
end
|
||||
|
||||
# Compares a matcher against a value.
|
||||
# Enables composable matchers.
|
||||
def ===(other) : Bool
|
||||
expression = Value.new(other)
|
||||
match(expression).matched?
|
||||
end
|
||||
|
||||
private def match_data_description(actual : Expression(T)) : String forall T
|
||||
match_data_description(actual.label)
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue