Skip to content

Commit

Permalink
Add spec
Browse files Browse the repository at this point in the history
  • Loading branch information
Sija authored Feb 25, 2025
1 parent ea06b96 commit e67523a
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions spec/compiler/parser/parser_spec.cr
Original file line number Diff line number Diff line change
Expand Up @@ -2822,6 +2822,32 @@ module Crystal
else_node_location.line_number.should eq 7
end

it "sets the correct location for MacroExpressions in a MacroFor" do
parser = Parser.new <<-CR
{% for key in %w[foo bar] %}
{{key}}
{% end %}
CR

node = parser.parse.should be_a MacroFor
location = node.location.should_not be_nil
location.line_number.should eq 1
location.column_number.should eq 1

body_node = node.body.should be_a Expressions
body_node_location = body_node.location.should_not be_nil
body_node_location.line_number.should eq 1
body_node_location = body_node.end_location.should_not be_nil
body_node_location.line_number.should eq 3

then_node_location = body_node.expressions[1].location.should_not be_nil
then_node_location.line_number.should eq 2
then_node_location.column_number.should eq 3
then_node_location = body_node.expressions[1].end_location.should_not be_nil
then_node_location.line_number.should eq 2
then_node_location.column_number.should eq 8
end

it "sets correct location of Begin within another node" do
parser = Parser.new(<<-CR)
macro finished
Expand Down

0 comments on commit e67523a

Please sign in to comment.