mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Use fully-qualified names
This commit is contained in:
parent
9109fc30fd
commit
0999cb2dbc
3 changed files with 18 additions and 17 deletions
|
@ -3,7 +3,7 @@ module Spectator
|
|||
module Builder
|
||||
extend self
|
||||
|
||||
@group_stack = [ExampleGroupBuilder.new]
|
||||
@group_stack = [::Spectator::DSL::ExampleGroupBuilder.new]
|
||||
|
||||
private def current_group
|
||||
@group_stack.last
|
||||
|
@ -15,18 +15,21 @@ module Spectator
|
|||
end
|
||||
|
||||
def start_group(what : String) : Nil
|
||||
push_group(ExampleGroupBuilder.new(what))
|
||||
group = ::Spectator::DSL::ExampleGroupBuilder.new(what)
|
||||
push_group(group)
|
||||
end
|
||||
|
||||
def start_given_group(what : String, values : Array(ValueWrapper)) : Nil
|
||||
push_group(GivenExampleGroupBuilder.new(what, values))
|
||||
group = ::Spectator::DSL::GivenExampleGroupBuilder.new(what, values)
|
||||
push_group(group)
|
||||
end
|
||||
|
||||
def end_group : Nil
|
||||
@group_stack.pop
|
||||
end
|
||||
|
||||
def add_example(factory : AbstractExampleFactory) : Nil
|
||||
def add_example(example_type : Example.class) : Nil
|
||||
factory = ::Spectator::DSL::ExampleGroupBuilder.new(example_type)
|
||||
current_group.add_child(factory)
|
||||
end
|
||||
|
||||
|
@ -52,7 +55,7 @@ module Spectator
|
|||
|
||||
protected def build : Array(Example)
|
||||
# TODO
|
||||
ExampleGroup.new
|
||||
[] of Example
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -38,13 +38,13 @@ module Spectator
|
|||
%collection.first
|
||||
end
|
||||
|
||||
@%wrapper : ValueWrapper
|
||||
@%wrapper : ::Spectator::ValueWrapper
|
||||
|
||||
def {{block.args.empty? ? "value".id : block.args.first}}
|
||||
@%wrapper.as(TypedValueWrapper(typeof(%first))).value
|
||||
@%wrapper.as(::Spectator::TypedValueWrapper(typeof(%first))).value
|
||||
end
|
||||
|
||||
def initialize(locals : Hash(Symbol, ValueWrapper))
|
||||
def initialize(locals : Hash(Symbol, ::Spectator::ValueWrapper))
|
||||
super
|
||||
@%wrapper = locals[:%group]
|
||||
end
|
||||
|
@ -94,14 +94,14 @@ module Spectator
|
|||
macro let(name, &block)
|
||||
let!(%value) {{block}}
|
||||
|
||||
@%wrapper : ValueWrapper?
|
||||
@%wrapper : ::Spectator::ValueWrapper?
|
||||
|
||||
def {{name.id}}
|
||||
if (wrapper = @%wrapper)
|
||||
wrapper.unsafe_as(TypedValueWrapper(typeof(%value))).value
|
||||
wrapper.unsafe_as(::Spectator::TypedValueWrapper(typeof(%value))).value
|
||||
else
|
||||
%value.tap do |value|
|
||||
@%wrapper = TypedValueWrapper(typeof(%value)).new(value)
|
||||
@%wrapper = ::Spectator::TypedValueWrapper(typeof(%value)).new(value)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
@ -142,7 +142,7 @@ module Spectator
|
|||
include ::Spectator::DSL::ExampleDSL
|
||||
include {{@type.id}}
|
||||
|
||||
def initialize(locals : Hash(Symbol, ValueWrapper))
|
||||
def initialize(locals : Hash(Symbol, ::Spectator::ValueWrapper))
|
||||
super
|
||||
end
|
||||
|
||||
|
@ -161,13 +161,11 @@ module Spectator
|
|||
end
|
||||
|
||||
def group
|
||||
::Spectator::Definitions::GROUPS[{{@type.symbolize}}]
|
||||
nil # TODO
|
||||
end
|
||||
end
|
||||
|
||||
::Spectator::DSL::Builder.add_example_factory(
|
||||
::Spectator::DSL::ExampleFactory(Example%example).new
|
||||
)
|
||||
::Spectator::DSL::Builder.add_example(Example%example)
|
||||
end
|
||||
|
||||
macro pending(description, &block)
|
||||
|
|
|
@ -2,7 +2,7 @@ module Spectator
|
|||
# Base class for proxying test values to examples.
|
||||
# This abstraction is required for inferring types.
|
||||
# The `DSL#let` macro makes heavy use of this.
|
||||
private abstract class ValueWrapper
|
||||
abstract class ValueWrapper
|
||||
# Retrieves the underlying value.
|
||||
abstract def value
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue