From 0f4a92e5b2430ffa6fd8bb34260966a73160b653 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Sat, 6 Apr 2019 11:55:37 -0600 Subject: [PATCH] Placeholder negate method to get around first issue All match data values now have a negate method, but it might not do anything. With this change, a segfault occurs during output. Invalid memory access (signal 11) at address 0x0 [0x55f0f6604906] *CallStack::print_backtrace:Int32 +118 [0x55f0f65f52c0] __crystal_sigfault_handler +192 [0x7fa1f7a8a890] ??? [0x55f0f6612cf6] *Slice(T)::new:read_only:Slice(UInt8) +22 [0x55f0f6608265] *String#to_slice:Slice(UInt8) +37 [0x55f0f6608208] *String#to_s:Nil +24 [0x55f0f6611b91] *String::Builder +17 [0x55f0f667ab7a] *Spectator::Matchers::EqualityMatcher::MatchData(String, String) +26 Program exited because of a segmentation fault (11) --- src/spectator/expectations/expectation.cr | 2 +- src/spectator/matchers/match_data_value.cr | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/spectator/expectations/expectation.cr b/src/spectator/expectations/expectation.cr index d370063..536aff0 100644 --- a/src/spectator/expectations/expectation.cr +++ b/src/spectator/expectations/expectation.cr @@ -25,7 +25,7 @@ module Spectator::Expectations if @negated labeled_values.each do |labeled_value| value = labeled_value.value - value.negate if value.responds_to?(:negate) + value.negate end end end diff --git a/src/spectator/matchers/match_data_value.cr b/src/spectator/matchers/match_data_value.cr index 8cdb6b4..08f48d7 100644 --- a/src/spectator/matchers/match_data_value.cr +++ b/src/spectator/matchers/match_data_value.cr @@ -2,5 +2,9 @@ module Spectator::Matchers # Abstract base for all match data values. # All sub-classes are expected to implement their own `#to_s`. private abstract class MatchDataValue + # Placeholder negation method. + def negate + # ... + end end end