Switch to structs to reduce memory allocations

This commit is contained in:
Michael Miller 2018-10-06 10:09:39 -06:00
parent f11031f113
commit d98bc05b88
7 changed files with 7 additions and 7 deletions

View file

@ -20,7 +20,7 @@ module Spectator::Expectations
end
# Information regarding the outcome of an expectation.
class Result
struct Result
# Indicates whether the expectation was satisifed or not.
getter? successful : Bool

View file

@ -4,7 +4,7 @@ module Spectator::Expectations
# The part of the expectation this class covers is the actual value.
# This can also cover a block's behavior.
# Sub-types of this class are returned by the `DSL::ExampleDSL.expect` call.
abstract class ExpectationPartial
abstract struct ExpectationPartial
# User-friendly string displayed for the actual expression being tested.
# For instance, in the expectation:
# ```

View file

@ -1,7 +1,7 @@
require "./expectation"
module Spectator::Expectations
class ValueExpectation(ActualType, ExpectedType)
struct ValueExpectation(ActualType, ExpectedType)
include Expectation
def initialize(@partial : ValueExpectationPartial(ActualType),

View file

@ -1,7 +1,7 @@
require "./expectation_partial"
module Spectator::Expectations
class ValueExpectationPartial(ActualType) < ExpectationPartial
struct ValueExpectationPartial(ActualType) < ExpectationPartial
getter actual
protected def initialize(label : String, @actual : ActualType)

View file

@ -1,7 +1,7 @@
require "./value_matcher"
module Spectator::Matchers
class EqualityMatcher(ExpectedType) < ValueMatcher(ExpectedType)
struct EqualityMatcher(ExpectedType) < ValueMatcher(ExpectedType)
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
partial.actual == expected
end

View file

@ -1,5 +1,5 @@
module Spectator::Matchers
abstract class Matcher
abstract struct Matcher
private getter label : String
private def initialize(@label)

View file

@ -1,7 +1,7 @@
require "./matcher"
module Spectator::Matchers
abstract class ValueMatcher(ExpectedType) < Matcher
abstract struct ValueMatcher(ExpectedType) < Matcher
private getter expected
def initialize(label : String, @expected : ExpectedType)