mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Make Scope#*_def?
methods accept check_outer_scopes
parameter
This commit is contained in:
parent
b6bd74e02f
commit
d23ad7f0ab
2 changed files with 31 additions and 14 deletions
|
@ -180,6 +180,28 @@ module Ameba::AST
|
|||
end
|
||||
end
|
||||
|
||||
describe "#def?" do
|
||||
context "when check_outer_scopes: true" do
|
||||
it "returns true if outer scope is Crystal::Def" do
|
||||
nodes = as_nodes("def foo; 3.times {}; end")
|
||||
outer_scope = Scope.new nodes.def_nodes.first
|
||||
scope = Scope.new nodes.block_nodes.first, outer_scope
|
||||
scope.def?(check_outer_scopes: true).should be_true
|
||||
end
|
||||
end
|
||||
|
||||
it "returns true if Crystal::Def" do
|
||||
nodes = as_nodes("def foo; end")
|
||||
scope = Scope.new nodes.def_nodes.first
|
||||
scope.def?.should be_true
|
||||
end
|
||||
|
||||
it "returns false otherwise" do
|
||||
scope = Scope.new as_node("a = 1")
|
||||
scope.def?.should be_false
|
||||
end
|
||||
end
|
||||
|
||||
describe "#in_macro?" do
|
||||
it "returns true if Crystal::Macro" do
|
||||
nodes = as_nodes <<-CRYSTAL
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue