Compiler error if stub defined in a method

This commit is contained in:
Michael Miller 2022-03-12 23:02:33 -07:00
parent 94872a498d
commit 291b4c75a8
No known key found for this signature in database
GPG key ID: AC78B32D30CE34A2

View file

@ -45,6 +45,7 @@ module Spectator
#
# Stubbed methods will call `#_spectator_find_stub` with the method call information.
private macro stub(method)
{% raise "Cannot define a stub inside a method" if @def %}
{% raise "stub requires a method definition" if !method.is_a?(Def) %}
{% raise "Cannot stub method with reserved keyword as name - #{method.name}" if method.name.starts_with?("_spectator") || ::Spectator::DSL::RESERVED_KEYWORDS.includes?(method.name.symbolize) %}
@ -108,6 +109,7 @@ module Spectator
#
# Stubbed methods will call `#_spectator_find_stub` with the method call information.
private macro abstract_stub(method)
{% raise "Cannot define a stub inside a method" if @def %}
{% raise "abstract_stub requires a method definition" if !method.is_a?(Def) %}
{% raise "Cannot stub method with reserved keyword as name - #{method.name}" if method.name.starts_with?("_spectator") || ::Spectator::DSL::RESERVED_KEYWORDS.includes?(method.name.symbolize) %}