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).
|
||||
# The part of the expectation this type covers is the actual value and source.
|
||||
# This can also cover a block's behavior.
|
||||
struct ExpectationPartial
|
||||
struct ExpectationPartial(T)
|
||||
# The actual value being tested.
|
||||
# This also contains its label.
|
||||
getter actual : TestExpression
|
||||
getter actual : TestExpression(T)
|
||||
|
||||
# Location where this expectation was defined.
|
||||
getter source : Source
|
||||
|
||||
# Creates the partial.
|
||||
def initialize(@actual, @source)
|
||||
def initialize(@actual : TestExpression(T), @source : Source)
|
||||
end
|
||||
|
||||
# Asserts that some criteria defined by the matcher is satisfied.
|
||||
|
|
|
@ -2,7 +2,7 @@ require "./test_expression"
|
|||
|
||||
module Spectator
|
||||
# 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.
|
||||
def value : ReturnType
|
||||
@proc.call
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
module Spectator
|
||||
# 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.
|
||||
# For instance, in the expectation:
|
||||
# ```
|
||||
|
@ -15,6 +15,8 @@ module Spectator
|
|||
def initialize(@label)
|
||||
end
|
||||
|
||||
abstract def value : T
|
||||
|
||||
# String representation of the expression.
|
||||
def to_s(io)
|
||||
io << label
|
||||
|
|
|
@ -2,7 +2,7 @@ require "./test_expression"
|
|||
|
||||
module Spectator
|
||||
# Captures a value from a test and its label.
|
||||
struct TestValue(T) < TestExpression
|
||||
struct TestValue(T) < TestExpression(T)
|
||||
# Actual value.
|
||||
getter value : T
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue