From 4a5dfd69b632418fc229cd421c886c2104d6be24 Mon Sep 17 00:00:00 2001 From: Alex Dowad Date: Fri, 30 Oct 2015 08:07:02 +0200 Subject: [PATCH 1/2] Fix typo --- lib/ast/node.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/ast/node.rb b/lib/ast/node.rb index 320347b..29d588f 100644 --- a/lib/ast/node.rb +++ b/lib/ast/node.rb @@ -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] From eca358ed08750167c4cd566eb2c22bcb9d6e2d53 Mon Sep 17 00:00:00 2001 From: Alex Dowad Date: Fri, 30 Oct 2015 08:10:34 +0200 Subject: [PATCH 2/2] Node#clone returns self --- lib/ast/node.rb | 1 + test/test_ast.rb | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/lib/ast/node.rb b/lib/ast/node.rb index 29d588f..a943f18 100644 --- a/lib/ast/node.rb +++ b/lib/ast/node.rb @@ -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`. diff --git a/test/test_ast.rb b/test/test_ast.rb index cf4619e..76b6a28 100644 --- a/test/test_ast.rb +++ b/test/test_ast.rb @@ -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