diff --git a/Gemfile.lock b/Gemfile.lock index 4275f1a..95fb442 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ PATH remote: . specs: - ruby_ast_gen (0.15.0) + ruby_ast_gen (0.16.0) GEM remote: https://rubygems.org/ diff --git a/lib/ruby_ast_gen/node_handling.rb b/lib/ruby_ast_gen/node_handling.rb index 5d1dd5f..d9222bb 100644 --- a/lib/ruby_ast_gen/node_handling.rb +++ b/lib/ruby_ast_gen/node_handling.rb @@ -91,6 +91,7 @@ def self.add_node_properties(node_type, base_map, file_path) base_map[:body] = children[2] when :sclass base_map[:name] = children[0] + base_map[:def] = children[1] base_map[:body] = children[2] when :module base_map[:name] = children[0] diff --git a/spec/ruby_ast_gen_spec.rb b/spec/ruby_ast_gen_spec.rb index 090b719..b152831 100644 --- a/spec/ruby_ast_gen_spec.rb +++ b/spec/ruby_ast_gen_spec.rb @@ -56,4 +56,28 @@ class Foo ast = RubyAstGen::parse_file(temp_file.path, temp_name) expect(ast).not_to be_nil end + + it "should create a singleton object body successfully" do + code(<<-CODE) +class C + class << self + def f(x) + x + 1 + end + end +end + CODE + ast = RubyAstGen::parse_file(temp_file.path, temp_name) + expect(ast).not_to be_nil + end + + it "should create an operator assignment successfully" do + code(<<-CODE) +def foo(x) + x += 1 +end + CODE + ast = RubyAstGen::parse_file(temp_file.path, temp_name) + expect(ast).not_to be_nil + end end