Skip to content

Commit

Permalink
Added :def to :sclass
Browse files Browse the repository at this point in the history
  • Loading branch information
DavidBakerEffendi committed Oct 21, 2024
1 parent 138fa52 commit 4a3d11c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
ruby_ast_gen (0.15.0)
ruby_ast_gen (0.16.0)

GEM
remote: https://rubygems.org/
Expand Down
1 change: 1 addition & 0 deletions lib/ruby_ast_gen/node_handling.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
24 changes: 24 additions & 0 deletions spec/ruby_ast_gen_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 4a3d11c

Please sign in to comment.