Track issue.end_location properly

This commit is contained in:
Vitalii Elenhaupt 2018-11-24 19:38:13 +02:00
parent ad2c6bad0e
commit 9885457227
No known key found for this signature in database
GPG key ID: 7558EF3A4056C706
45 changed files with 90 additions and 20 deletions

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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("")

View file

@ -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

View file

@ -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

View file

@ -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