summaryrefslogtreecommitdiff
path: root/spec/ruby/core/set/map_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/ruby/core/set/map_spec.rb')
-rw-r--r--spec/ruby/core/set/map_spec.rb22
1 files changed, 22 insertions, 0 deletions
diff --git a/spec/ruby/core/set/map_spec.rb b/spec/ruby/core/set/map_spec.rb
new file mode 100644
index 0000000000..fd04a8bde1
--- /dev/null
+++ b/spec/ruby/core/set/map_spec.rb
@@ -0,0 +1,22 @@
+require_relative '../../spec_helper'
+
+describe "Set#map!" do
+ before :each do
+ @set = Set[1, 2, 3, 4, 5]
+ end
+
+ it "yields each Object in self" do
+ res = []
+ @set.map! { |x| res << x }
+ res.sort.should == [1, 2, 3, 4, 5].sort
+ end
+
+ it "returns self" do
+ @set.map! { |x| x }.should.equal?(@set)
+ end
+
+ it "replaces self with the return values of the block" do
+ @set.map! { |x| x * 2 }
+ @set.should == Set[2, 4, 6, 8, 10]
+ end
+end