mirror of
https://gitea.invidious.io/iv-org/shard-spectator.git
synced 2024-08-15 00:53:35 +00:00
Upcast to AbstractArguments to avoid instantiating methods
This reduced compilation times when using a large amount of Arguments types.
This commit is contained in:
parent
32a9bfd356
commit
ecab2dd37e
3 changed files with 6 additions and 6 deletions
src/spectator/mocks
|
@ -18,12 +18,12 @@ module Spectator
|
|||
end
|
||||
|
||||
# Constructs an instance from literal arguments.
|
||||
def self.capture(*args, **kwargs) : self
|
||||
new(args, kwargs)
|
||||
def self.capture(*args, **kwargs) : AbstractArguments
|
||||
new(args, kwargs).as(AbstractArguments)
|
||||
end
|
||||
|
||||
# Instance of empty arguments.
|
||||
class_getter empty : Arguments(Tuple(), NamedTuple()) = capture
|
||||
class_getter empty : AbstractArguments = capture
|
||||
|
||||
# Returns the positional argument at the specified index.
|
||||
def [](index : Int)
|
||||
|
|
|
@ -11,12 +11,12 @@ module Spectator
|
|||
getter arguments : AbstractArguments
|
||||
|
||||
# Creates a method call.
|
||||
def initialize(@method : Symbol, @arguments : Arguments = Arguments.empty)
|
||||
def initialize(@method : Symbol, @arguments : AbstractArguments = Arguments.empty)
|
||||
end
|
||||
|
||||
# Creates a method call by splatting its arguments.
|
||||
def self.capture(method : Symbol, *args, **kwargs)
|
||||
arguments = Arguments.new(args, kwargs)
|
||||
arguments = Arguments.new(args, kwargs).as(AbstractArguments)
|
||||
new(method, arguments)
|
||||
end
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ module Spectator
|
|||
module StubModifiers
|
||||
# Returns a new stub with an argument constraint.
|
||||
def with(*args, **kwargs, &block : AbstractArguments -> T) forall T
|
||||
constraint = Arguments.new(args, kwargs)
|
||||
constraint = Arguments.new(args, kwargs).as(AbstractArguments)
|
||||
ProcStub(T).new(method, block, constraint, location)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue