mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Resolve let! not working on uninferable types
Resolves https://github.com/icy-arctic-fox/spectator/issues/4 Use ValueWrapper trick again and initialize immediately with before_each hook.
This commit is contained in:
parent
7868755eee
commit
c48b9ed9e1
1 changed files with 10 additions and 3 deletions
|
@ -19,11 +19,18 @@ module Spectator
|
|||
end
|
||||
|
||||
macro let!(name, &block)
|
||||
# TODO: Doesn't work with late-defined values (let).
|
||||
@%value = {{yield}}
|
||||
@%wrapper : ::Spectator::ValueWrapper?
|
||||
|
||||
def %wrapper
|
||||
{{block.body}}
|
||||
end
|
||||
|
||||
before_each do
|
||||
@%wrapper = ::Spectator::TypedValueWrapper.new(%wrapper)
|
||||
end
|
||||
|
||||
def {{name.id}}
|
||||
@%value
|
||||
@%wrapper.as(::Spectator::TypedValueWrapper(typeof(%wrapper))).value
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Reference in a new issue