MatchDataValue must be a class

Negatable value modifiers don't get updated when they're structs.
This commit is contained in:
Michael Miller 2019-03-22 11:01:47 -06:00
parent a19d9f00aa
commit 5e80b3835a
6 changed files with 6 additions and 6 deletions

View file

@ -3,7 +3,7 @@ require "./match_data_value"
module Spectator::Matchers module Spectator::Matchers
# Selects a value based on whether the value is negated. # Selects a value based on whether the value is negated.
# This is used when a matcher is negated. # This is used when a matcher is negated.
private struct AlternativeMatchDataValue(T1, T2) < MatchDataValue private class AlternativeMatchDataValue(T1, T2) < MatchDataValue
# Creates the wrapper. # Creates the wrapper.
def initialize(@value1 : T1, @value2 : T2) def initialize(@value1 : T1, @value2 : T2)
@negated = false @negated = false

View file

@ -2,7 +2,7 @@ require "./match_data_value"
module Spectator::Matchers module Spectator::Matchers
# Wraps a value for used in match data. # Wraps a value for used in match data.
private struct GenericMatchDataValue(T) < MatchDataValue private class GenericMatchDataValue(T) < MatchDataValue
# Creates the wrapper. # Creates the wrapper.
def initialize(@value : T) def initialize(@value : T)
end end

View file

@ -1,6 +1,6 @@
module Spectator::Matchers module Spectator::Matchers
# Abstract base for all match data values. # Abstract base for all match data values.
# All sub-classes are expected to implement their own `#to_s`. # All sub-classes are expected to implement their own `#to_s`.
private abstract struct MatchDataValue private abstract class MatchDataValue
end end
end end

View file

@ -3,7 +3,7 @@ require "./match_data_value"
module Spectator::Matchers module Spectator::Matchers
# Wraps an expected value that can be negated. # Wraps an expected value that can be negated.
# This is used when a matcher is negated. # This is used when a matcher is negated.
private struct NegatableMatchDataValue(T) < MatchDataValue private class NegatableMatchDataValue(T) < MatchDataValue
# Negatable value. # Negatable value.
getter value getter value

View file

@ -3,7 +3,7 @@ require "./match_data_value"
module Spectator::Matchers module Spectator::Matchers
# Wraps a prefixed value that can be negated. # Wraps a prefixed value that can be negated.
# This is used when a matcher is negated. # This is used when a matcher is negated.
private struct NegatablePrefixedMatchDataValue(T) < MatchDataValue private class NegatablePrefixedMatchDataValue(T) < MatchDataValue
# Negatable value. # Negatable value.
getter value getter value

View file

@ -2,7 +2,7 @@ require "./match_data_value"
module Spectator::Matchers module Spectator::Matchers
# Prefixes (for output formatting) an actual or expected value. # Prefixes (for output formatting) an actual or expected value.
private struct PrefixedMatchDataValue(T) < MatchDataValue private class PrefixedMatchDataValue(T) < MatchDataValue
# Value being prefixed. # Value being prefixed.
getter value : T getter value : T