From ac5c2bbe47d6da2027724a04f5207c9abdf5d7f5 Mon Sep 17 00:00:00 2001 From: Michael Miller Date: Thu, 14 Feb 2019 16:19:49 -0700 Subject: [PATCH] Reorder source arguments and simplify --- src/spectator/dsl/example_dsl.cr | 6 +++--- src/spectator/expectations/block_expectation_partial.cr | 4 ++-- src/spectator/expectations/value_expectation_partial.cr | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/spectator/dsl/example_dsl.cr b/src/spectator/dsl/example_dsl.cr index 2c791bc..da7f072 100644 --- a/src/spectator/dsl/example_dsl.cr +++ b/src/spectator/dsl/example_dsl.cr @@ -17,7 +17,7 @@ module Spectator::DSL # Where the actual value is returned by the system-under-test, # and the expected value is what the actual value should be to satisfy the condition. macro expect(actual, _source_file = __FILE__, _source_line = __LINE__) - ::Spectator::Expectations::ValueExpectationPartial.new({{actual.stringify}}, {{_source_file}}, {{_source_line}}, {{actual}}) + ::Spectator::Expectations::ValueExpectationPartial.new({{actual}}, {{actual.stringify}}, {{_source_file}}, {{_source_line}}) end # Starts an expectation on a block of code. @@ -55,11 +55,11 @@ module Spectator::DSL # The raw block can't be used because it's not clear to the user. {% method_name = block.body.id.split('.').last %} # TODO: Maybe pass the subject in as __arg0 instead of prefixing with `subject.`. - ::Spectator::Expectations::ValueExpectationPartial.new({{"#" + method_name}}, {{_source_file}}, {{_source_line}}, subject.{{method_name.id}}) + ::Spectator::Expectations::ValueExpectationPartial.new(subject.{{method_name}}, {{"#" + method_name}}, {{_source_file}}, {{_source_line}}) {% else %} # In this case, it looks like the short-hand method syntax wasn't used. # Just drop in the block as-is. - ::Spectator::Expectations::ValueExpectationPartial.new({{block.body.stringify}}, {{_source_file}}, {{_source_line}}, {{block.body}}) + ::Spectator::Expectations::ValueExpectationPartial.new({{block.body}}, {{block.body.stringify}}, {{_source_file}}, {{_source_line}}) {% end %} end diff --git a/src/spectator/expectations/block_expectation_partial.cr b/src/spectator/expectations/block_expectation_partial.cr index 7fd0c97..05089af 100644 --- a/src/spectator/expectations/block_expectation_partial.cr +++ b/src/spectator/expectations/block_expectation_partial.cr @@ -11,14 +11,14 @@ module Spectator::Expectations # Creates the expectation partial. # The label should be a string representation of the block. # The block is stored for later use. - protected def initialize(label, source_file, source_line, @block : -> ReturnType) + protected def initialize(@block : -> ReturnType, label, source_file, source_line) super(label, source_file, source_line) end # Creates the expectation partial. # The label is generated by calling `#to_s` on the block. # The block is stored for later use. - protected def initialize(source_file, source_line, @block : -> ReturnType) + protected def initialize(@block : -> ReturnType, source_file, source_line) super(@block.to_s, source_file, source_line) end end diff --git a/src/spectator/expectations/value_expectation_partial.cr b/src/spectator/expectations/value_expectation_partial.cr index 7f364f0..edd8b4a 100644 --- a/src/spectator/expectations/value_expectation_partial.cr +++ b/src/spectator/expectations/value_expectation_partial.cr @@ -10,14 +10,14 @@ module Spectator::Expectations # Creates the expectation partial. # The label should be a string representation of the actual value. # The actual value is stored for later use. - protected def initialize(label : String, source_file, source_line, @actual : ActualType) + protected def initialize(@actual : ActualType, label, source_file, source_line) super(label, source_file, source_line) end # Creates the expectation partial. # The label is generated by calling `#to_s` on the actual value. # The actual value is stored for later use. - protected def initialize(source_file, source_line, @actual : ActualType) + protected def initialize(@actual : ActualType, source_file, source_line) super(@actual.to_s, source_file, source_line) end end