Store GenericArguments

This commit is contained in:
Michael Miller 2019-11-14 19:15:51 -07:00
parent 763c99f338
commit ac3a5c8515
4 changed files with 9 additions and 7 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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