Avoid calling NoReturn methods

This commit is contained in:
Michael Miller 2021-07-02 21:52:56 -06:00
parent 1c865d1f4b
commit 92dbfc2a8e
No known key found for this signature in database
GPG key ID: FB9F12F7C646A4AD

View file

@ -82,7 +82,11 @@ module Spectator::Mocks
%call = ::Spectator::Mocks::MethodCall.new({{name.symbolize}}, %args)
%harness.mocks.record_call(self, %call)
if (%stub = %harness.mocks.find_stub(self, %call))
return %stub.call!(%args) { {{original}} }
if typeof({{original}}) == NoReturn
return %stub.call!(%args) { nil }
else
return %stub.call!(%args) { {{original}} }
end
end
{% if body && !body.is_a?(Nop) || return_type.is_a?(ArrayLiteral) %}
@ -101,7 +105,11 @@ module Spectator::Mocks
%call = ::Spectator::Mocks::MethodCall.new({{name.symbolize}}, %args)
%harness.mocks.record_call(self, %call)
if (%stub = %harness.mocks.find_stub(self, %call))
return %stub.call!(%args) { {{original}} { |*%ya| yield *%ya } }
if typeof({{original}}) == NoReturn
return %stub.call!(%args) { nil }
else
return %stub.call!(%args) { {{original}} { |*%ya| yield *%ya } }
end
end
{% if body && !body.is_a?(Nop) || return_type.is_a?(ArrayLiteral) %}