From ea6017a1c99bcde3301048466950b5ef0a8bafec Mon Sep 17 00:00:00 2001 From: Philippe PITTOLI Date: Sun, 26 May 2024 01:41:49 +0200 Subject: [PATCH] Test reverse. --- spec/test-lists.cr | 6 ++++++ src/list.cr | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/spec/test-lists.cr b/spec/test-lists.cr index 34c20a3..695cd46 100644 --- a/spec/test-lists.cr +++ b/spec/test-lists.cr @@ -48,4 +48,10 @@ describe "DoubleLinkedList" do list.size.should eq 0 end + + it "reverse" do + list = DoubleLinkedList(Int32).new + list << 1 << 2 << 3 << 4 + list.reverse.to_s.should eq "[ 4, 3, 2, 1 ]" + end end diff --git a/src/list.cr b/src/list.cr index ff0855c..ab53a4c 100644 --- a/src/list.cr +++ b/src/list.cr @@ -264,7 +264,7 @@ class DoubleLinkedList(V) # values = [1, 2, 3] # list = DoubleLinkedList(Int32).new(values) # list.each do |elem| - # puts elem + # puts elem # end def each each_node do |node|