summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/pry/history_array.rb5
-rw-r--r--test/test_history_array.rb5
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/pry/history_array.rb b/lib/pry/history_array.rb
index 04ae3f3d..48a101e6 100644
--- a/lib/pry/history_array.rb
+++ b/lib/pry/history_array.rb
@@ -89,6 +89,11 @@ class Pry
((@count - size)...@count).map { |n| @hash[n] }
end
+ def pop!
+ @hash.delete @count - 1
+ @count -= 1
+ end
+
def inspect
"#<#{self.class} size=#{size} first=#{@count - size} max_size=#{max_size}>"
end
diff --git a/test/test_history_array.rb b/test/test_history_array.rb
index bc453c68..f1bd07aa 100644
--- a/test/test_history_array.rb
+++ b/test/test_history_array.rb
@@ -59,4 +59,9 @@ describe Pry::HistoryArray do
12.times { |n| @array << n }
@array.entries.compact.size.should == 10
end
+
+ it 'should pop!' do
+ @populated.pop!
+ @populated.to_a.should == [1, 2, 3]
+ end
end