mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Genericize TestExpression and make value abstract
This seems to resolve issues with the compiler making unions of unrelated test case types.
This commit is contained in:
parent
569faa0a2b
commit
114bfa47c2
4 changed files with 8 additions and 6 deletions
|
@ -6,16 +6,16 @@ module Spectator::Expectations
|
||||||
# Stores part of an expectation (obviously).
|
# Stores part of an expectation (obviously).
|
||||||
# The part of the expectation this type covers is the actual value and source.
|
# The part of the expectation this type covers is the actual value and source.
|
||||||
# This can also cover a block's behavior.
|
# This can also cover a block's behavior.
|
||||||
struct ExpectationPartial
|
struct ExpectationPartial(T)
|
||||||
# The actual value being tested.
|
# The actual value being tested.
|
||||||
# This also contains its label.
|
# This also contains its label.
|
||||||
getter actual : TestExpression
|
getter actual : TestExpression(T)
|
||||||
|
|
||||||
# Location where this expectation was defined.
|
# Location where this expectation was defined.
|
||||||
getter source : Source
|
getter source : Source
|
||||||
|
|
||||||
# Creates the partial.
|
# Creates the partial.
|
||||||
def initialize(@actual, @source)
|
def initialize(@actual : TestExpression(T), @source : Source)
|
||||||
end
|
end
|
||||||
|
|
||||||
# Asserts that some criteria defined by the matcher is satisfied.
|
# Asserts that some criteria defined by the matcher is satisfied.
|
||||||
|
|
|
@ -2,7 +2,7 @@ require "./test_expression"
|
||||||
|
|
||||||
module Spectator
|
module Spectator
|
||||||
# Captures an block from a test and its label.
|
# Captures an block from a test and its label.
|
||||||
struct TestBlock(ReturnType) < TestExpression
|
struct TestBlock(ReturnType) < TestExpression(ReturnType)
|
||||||
# Calls the block and retrieves the value.
|
# Calls the block and retrieves the value.
|
||||||
def value : ReturnType
|
def value : ReturnType
|
||||||
@proc.call
|
@proc.call
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
module Spectator
|
module Spectator
|
||||||
# Base type for capturing an expression from a test.
|
# Base type for capturing an expression from a test.
|
||||||
abstract struct TestExpression
|
abstract struct TestExpression(T)
|
||||||
# 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:
|
||||||
# ```
|
# ```
|
||||||
|
@ -15,6 +15,8 @@ module Spectator
|
||||||
def initialize(@label)
|
def initialize(@label)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
abstract def value : T
|
||||||
|
|
||||||
# String representation of the expression.
|
# String representation of the expression.
|
||||||
def to_s(io)
|
def to_s(io)
|
||||||
io << label
|
io << label
|
||||||
|
|
|
@ -2,7 +2,7 @@ require "./test_expression"
|
||||||
|
|
||||||
module Spectator
|
module Spectator
|
||||||
# Captures a value from a test and its label.
|
# Captures a value from a test and its label.
|
||||||
struct TestValue(T) < TestExpression
|
struct TestValue(T) < TestExpression(T)
|
||||||
# Actual value.
|
# Actual value.
|
||||||
getter value : T
|
getter value : T
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue