Skip to content

Commit 6b3c332

Browse files
Fix Cell#to_cell method
Previously this could cause there to be Cell<Cell<Node>> objects created when calling #to_cell on a Cell.
1 parent c37b2a1 commit 6b3c332

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

lib/keisan/ast/cell.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ def replace(variable, replacement)
6666
end
6767

6868
def to_cell
69-
self.class.new(node.to_cell)
69+
self.class.new(node.to_node)
7070
end
7171

7272
def to_s

spec/keisan/ast/cell_spec.rb

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,12 @@
3131
expect(cell.to_node).to eq node
3232
end
3333
end
34+
35+
describe "#to_cell" do
36+
it "wraps the node in a new cell" do
37+
new_cell = cell.to_cell
38+
expect(cell).not_to eq new_cell
39+
expect(cell.node).to eq new_cell.node
40+
end
41+
end
3442
end

0 commit comments

Comments
 (0)