mirror of
https://gitea.invidious.io/iv-org/shard-ameba.git
synced 2024-08-15 00:53:29 +00:00
Track issue.end_location properly
This commit is contained in:
parent
ad2c6bad0e
commit
9885457227
45 changed files with 90 additions and 20 deletions
|
@ -323,7 +323,7 @@ module Ameba::AST
|
|||
branch.to_s.should eq branch.node.to_s
|
||||
end
|
||||
|
||||
it "delegates location to node" do
|
||||
it "delegates locations to node" do
|
||||
nodes = as_nodes %(
|
||||
if true
|
||||
a = 2
|
||||
|
@ -332,6 +332,7 @@ module Ameba::AST
|
|||
branchable = Branchable.new nodes.if_nodes.first
|
||||
branch = Branch.new nodes.assign_nodes.first, branchable
|
||||
branch.location.should eq branch.node.location
|
||||
branch.end_location.should eq branch.node.end_location
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -16,10 +16,11 @@ module Ameba::AST
|
|||
branchable.to_s.should eq node.to_s
|
||||
end
|
||||
|
||||
it "delegates location to @node" do
|
||||
it "delegates locations to @node" do
|
||||
node = as_node %(a = 2 if true)
|
||||
branchable = Branchable.new node
|
||||
branchable.location.should eq node.location
|
||||
branchable.end_location.should eq node.end_location
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -17,10 +17,11 @@ module Ameba::AST
|
|||
flow_expression.to_s.should eq node.to_s
|
||||
end
|
||||
|
||||
it "delegates location to @node" do
|
||||
it "delegates locations to @node" do
|
||||
node = as_node %(break if true)
|
||||
flow_expression = FlowExpression.new node, false
|
||||
flow_expression.location.should eq node.location
|
||||
flow_expression.end_location.should eq node.end_location
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -18,6 +18,21 @@ module Ameba::AST
|
|||
end
|
||||
end
|
||||
|
||||
describe "delegation" do
|
||||
it "delegates to_s to node" do
|
||||
node = as_node("def foo; end")
|
||||
scope = Scope.new node
|
||||
scope.to_s.should eq node.to_s
|
||||
end
|
||||
|
||||
it "delegates locations to node" do
|
||||
node = as_node("def foo; end")
|
||||
scope = Scope.new node
|
||||
scope.location.should eq node.location
|
||||
scope.end_location.should eq node.end_location
|
||||
end
|
||||
end
|
||||
|
||||
describe "#add_variable" do
|
||||
it "adds a new variable to the scope" do
|
||||
scope = Scope.new as_node("")
|
||||
|
|
|
@ -14,9 +14,10 @@ module Ameba::AST
|
|||
end
|
||||
|
||||
describe "delegation" do
|
||||
it "delegates location to node" do
|
||||
it "delegates locations to node" do
|
||||
argument = Argument.new(arg, variable)
|
||||
argument.location.should eq arg.location
|
||||
argument.end_location.should eq arg.end_location
|
||||
end
|
||||
|
||||
it "delegates to_s to node" do
|
||||
|
|
|
@ -22,9 +22,10 @@ module Ameba::AST
|
|||
end
|
||||
|
||||
describe "delegation" do
|
||||
it "delegates location" do
|
||||
it "delegates locations" do
|
||||
assignment = Assignment.new(node, variable)
|
||||
assignment.location.should eq node.location
|
||||
assignment.end_location.should eq node.end_location
|
||||
end
|
||||
|
||||
it "delegates to_s" do
|
||||
|
|
|
@ -13,9 +13,10 @@ module Ameba::AST
|
|||
end
|
||||
|
||||
describe "delegation" do
|
||||
it "delegates location" do
|
||||
it "delegates locations" do
|
||||
variable = Variable.new(var_node, scope)
|
||||
variable.location.should eq var_node.location
|
||||
variable.end_location.should eq var_node.end_location
|
||||
end
|
||||
|
||||
it "delegates name" do
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue