mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Store GenericArguments
This commit is contained in:
parent
763c99f338
commit
ac3a5c8515
4 changed files with 9 additions and 7 deletions
|
@ -4,8 +4,10 @@ require "./method_call"
|
|||
require "./method_stub"
|
||||
|
||||
module Spectator::Mocks
|
||||
abstract class GenericMethodStub(ReturnType) < MethodStub
|
||||
def initialize(name, source, @args : Arguments? = nil)
|
||||
abstract class GenericMethodStub(ReturnType, T, NT) < MethodStub
|
||||
getter! arguments : GenericArguments(T, NT)
|
||||
|
||||
def initialize(name, source, @args : GenericArguments(T, NT) = nil)
|
||||
super(name, source)
|
||||
end
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ require "./generic_method_stub"
|
|||
require "./value_method_stub"
|
||||
|
||||
module Spectator::Mocks
|
||||
class NilMethodStub < GenericMethodStub(Nil)
|
||||
class NilMethodStub < GenericMethodStub(Nil, Tuple, NamedTuple)
|
||||
def call(_args : GenericArguments(T, NT), _rt : RT.class) forall T, NT, RT
|
||||
nil
|
||||
end
|
||||
|
|
|
@ -2,12 +2,12 @@ require "./arguments"
|
|||
require "./generic_method_stub"
|
||||
|
||||
module Spectator::Mocks
|
||||
class ProcMethodStub(ReturnType) < GenericMethodStub(ReturnType)
|
||||
class ProcMethodStub(ReturnType, T, NT) < GenericMethodStub(ReturnType, T, NT)
|
||||
def initialize(name, source, @proc : -> ReturnType, args = nil)
|
||||
super(name, source, args)
|
||||
end
|
||||
|
||||
def call(_args : GenericArguments(T, NT), rt : RT.class) forall T, NT, RT
|
||||
def call(_args : GenericArguments(T2, NT2), rt : RT.class) forall T2, NT2, RT
|
||||
@proc.call
|
||||
end
|
||||
end
|
||||
|
|
|
@ -2,12 +2,12 @@ require "./generic_arguments"
|
|||
require "./generic_method_stub"
|
||||
|
||||
module Spectator::Mocks
|
||||
class ValueMethodStub(ReturnType) < GenericMethodStub(ReturnType)
|
||||
class ValueMethodStub(ReturnType, T, NT) < GenericMethodStub(ReturnType, T, NT)
|
||||
def initialize(name, source, @value : ReturnType, args = nil)
|
||||
super(name, source, args)
|
||||
end
|
||||
|
||||
def call(_args : GenericArguments(T, NT), rt : RT.class) forall T, NT, RT
|
||||
def call(_args : GenericArguments(T2, NT2), rt : RT.class) forall T2, NT2, RT
|
||||
@value
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue