Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/ast/node.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def eql?(other)
# By default, each entry in the `properties` hash is assigned to
# an instance variable in this instance of Node. A subclass should define
# attribute readers for such variables. The values passed in the hash
# are not frozen or whitelisted; such behavior can also be implemented\
# are not frozen or whitelisted; such behavior can also be implemented
# by subclassing Node and overriding this method.
#
# @return [nil]
Expand All @@ -104,6 +104,7 @@ def assign_properties(properties)
def dup
self
end
alias :clone :dup

# Returns a new instance of Node where non-nil arguments replace the
# corresponding fields of `self`.
Expand Down
4 changes: 4 additions & 0 deletions test/test_ast.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ class MetaNode < AST::Node
@node.dup.should.equal? @node
end

it 'should return self when cloning' do
@node.clone.should.equal? @node
end

it 'should return an updated node, but only if needed' do
@node.updated().should.be.identical_to @node
@node.updated(:node).should.be.identical_to @node
Expand Down