diff --git a/lib/ast_to_prism/parser.rb b/lib/ast_to_prism/parser.rb index 9041bb5..7a82103 100644 --- a/lib/ast_to_prism/parser.rb +++ b/lib/ast_to_prism/parser.rb @@ -589,6 +589,7 @@ def convert_case_body(node) while node do nd_head, nd_body, nd_next = node.children + loc, keyword_loc, then_keyword_loc = node.locations cond = nd_head.children[0...-1].map do |n| convert_node(n) @@ -596,11 +597,11 @@ def convert_case_body(node) conditions << Prism::WhenNode.new( source, # source - null_location, # keyword_loc + location(keyword_loc), # keyword_loc cond, # conditions - null_location, # then_keyword_loc + location(then_keyword_loc), # then_keyword_loc convert_case_statements(nd_body), # statements - location(node) # location + location(loc) # location ) if nd_next&.type == :WHEN diff --git a/spec/basic_spec.rb b/spec/basic_spec.rb index fb3462f..1f2dfff 100644 --- a/spec/basic_spec.rb +++ b/spec/basic_spec.rb @@ -2462,7 +2462,7 @@ def m describe "case with head" do it "tests" do - pending "WhenNode locations are not supported" + pending "CaseNode locations are not supported" test_code(<<~CODE) case x @@ -2472,7 +2472,7 @@ def m end it "tests" do - pending "WhenNode locations are not supported" + pending "CaseNode locations are not supported" test_code(<<~CODE) case x @@ -2482,7 +2482,7 @@ def m end it "tests" do - pending "WhenNode locations and ElseNode locations are not supported" + pending "ElseNode locations are not supported" test_code(<<~CODE) case x @@ -2493,7 +2493,7 @@ def m end it "tests" do - pending "WhenNode locations are not supported" + pending "CaseNode locations are not supported" test_code(<<~CODE) case x @@ -2506,7 +2506,7 @@ def m end it "tests" do - pending "WhenNode locations and ElseNode locations are not supported" + pending "ElseNode locations are not supported" test_code(<<~CODE) case x @@ -2523,7 +2523,7 @@ def m describe "case with no head" do it "tests" do - pending "WhenNode locations locations are not supported" + pending "CaseNode locations are not supported" test_code(<<~CODE) case @@ -2533,7 +2533,7 @@ def m end it "tests" do - pending "WhenNode locations locations are not supported" + pending "CaseNode locations are not supported" test_code(<<~CODE) case @@ -2543,7 +2543,7 @@ def m end it "tests" do - pending "WhenNode locations and ElseNode locations are not supported" + pending "ElseNode locations are not supported" test_code(<<~CODE) case @@ -2554,7 +2554,7 @@ def m end it "tests" do - pending "WhenNode locations locations are not supported" + pending "CaseNode locations are not supported" test_code(<<~CODE) case @@ -2567,7 +2567,7 @@ def m end it "tests" do - pending "WhenNode locations and ElseNode locations are not supported" + pending "ElseNode locations are not supported" test_code(<<~CODE) case