summaryrefslogtreecommitdiff
path: root/spec/rubyspec/library/set/sortedset/each_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/rubyspec/library/set/sortedset/each_spec.rb')
-rw-r--r--spec/rubyspec/library/set/sortedset/each_spec.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/spec/rubyspec/library/set/sortedset/each_spec.rb b/spec/rubyspec/library/set/sortedset/each_spec.rb
new file mode 100644
index 0000000000..c715c403b2
--- /dev/null
+++ b/spec/rubyspec/library/set/sortedset/each_spec.rb
@@ -0,0 +1,26 @@
+require File.expand_path('../../../../spec_helper', __FILE__)
+require 'set'
+
+describe "SortedSet#each" do
+ before :each do
+ @set = SortedSet[1, 2, 3]
+ end
+
+ it "yields each Object in self in sorted order" do
+ ret = []
+ SortedSet["one", "two", "three"].each { |x| ret << x }
+ ret.should == ["one", "two", "three"].sort
+ end
+
+ it "returns self" do
+ @set.each { |x| x }.should equal(@set)
+ end
+
+ it "returns an Enumerator when not passed a block" do
+ enum = @set.each
+
+ ret = []
+ enum.each { |x| ret << x }
+ ret.sort.should == [1, 2, 3]
+ end
+end