mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Switch to structs to reduce memory allocations
This commit is contained in:
parent
f11031f113
commit
d98bc05b88
7 changed files with 7 additions and 7 deletions
|
@ -20,7 +20,7 @@ module Spectator::Expectations
|
||||||
end
|
end
|
||||||
|
|
||||||
# Information regarding the outcome of an expectation.
|
# Information regarding the outcome of an expectation.
|
||||||
class Result
|
struct Result
|
||||||
# Indicates whether the expectation was satisifed or not.
|
# Indicates whether the expectation was satisifed or not.
|
||||||
getter? successful : Bool
|
getter? successful : Bool
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,7 @@ module Spectator::Expectations
|
||||||
# The part of the expectation this class covers is the actual value.
|
# The part of the expectation this class covers is the actual value.
|
||||||
# This can also cover a block's behavior.
|
# This can also cover a block's behavior.
|
||||||
# Sub-types of this class are returned by the `DSL::ExampleDSL.expect` call.
|
# 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.
|
# User-friendly string displayed for the actual expression being tested.
|
||||||
# For instance, in the expectation:
|
# For instance, in the expectation:
|
||||||
# ```
|
# ```
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require "./expectation"
|
require "./expectation"
|
||||||
|
|
||||||
module Spectator::Expectations
|
module Spectator::Expectations
|
||||||
class ValueExpectation(ActualType, ExpectedType)
|
struct ValueExpectation(ActualType, ExpectedType)
|
||||||
include Expectation
|
include Expectation
|
||||||
|
|
||||||
def initialize(@partial : ValueExpectationPartial(ActualType),
|
def initialize(@partial : ValueExpectationPartial(ActualType),
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require "./expectation_partial"
|
require "./expectation_partial"
|
||||||
|
|
||||||
module Spectator::Expectations
|
module Spectator::Expectations
|
||||||
class ValueExpectationPartial(ActualType) < ExpectationPartial
|
struct ValueExpectationPartial(ActualType) < ExpectationPartial
|
||||||
getter actual
|
getter actual
|
||||||
|
|
||||||
protected def initialize(label : String, @actual : ActualType)
|
protected def initialize(label : String, @actual : ActualType)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require "./value_matcher"
|
require "./value_matcher"
|
||||||
|
|
||||||
module Spectator::Matchers
|
module Spectator::Matchers
|
||||||
class EqualityMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
struct EqualityMatcher(ExpectedType) < ValueMatcher(ExpectedType)
|
||||||
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
|
def match?(partial : Expectations::ValueExpectationPartial(ActualType)) : Bool forall ActualType
|
||||||
partial.actual == expected
|
partial.actual == expected
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
module Spectator::Matchers
|
module Spectator::Matchers
|
||||||
abstract class Matcher
|
abstract struct Matcher
|
||||||
private getter label : String
|
private getter label : String
|
||||||
|
|
||||||
private def initialize(@label)
|
private def initialize(@label)
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
require "./matcher"
|
require "./matcher"
|
||||||
|
|
||||||
module Spectator::Matchers
|
module Spectator::Matchers
|
||||||
abstract class ValueMatcher(ExpectedType) < Matcher
|
abstract struct ValueMatcher(ExpectedType) < Matcher
|
||||||
private getter expected
|
private getter expected
|
||||||
|
|
||||||
def initialize(label : String, @expected : ExpectedType)
|
def initialize(label : String, @expected : ExpectedType)
|
||||||
|
|
Loading…
Reference in a new issue