summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-01 09:01:16 +0000
committerknu <knu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-06-01 09:01:16 +0000
commit6bdfe415df2ef15487ba932762c028640b8ff71a (patch)
tree7b97e0a7804c57c23191d7bf3d708e2aee1df6ab
parent4a223fb67f31a1a85a0b4fb019a1106532a541ce (diff)
* lib/set.rb (Set#freeze, taint, untaint): Save a "self" by
utilizing super returning self, and add tests while at it. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@41022 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
-rw-r--r--ChangeLog5
-rw-r--r--lib/set.rb9
-rw-r--r--test/test_set.rb21
3 files changed, 29 insertions, 6 deletions
diff --git a/ChangeLog b/ChangeLog
index 18eab62..82874d5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+Sat Jun 1 17:58:13 2013 Akinori MUSHA <knu@iDaemons.org>
+
+ * lib/set.rb (Set#freeze, taint, untaint): Save a "self" by
+ utilizing super returning self, and add tests while at it.
+
Sat Jun 1 17:24:47 2013 Nobuyoshi Nakada <nobu@ruby-lang.org>
* compile.c (iseq_set_arguments): not a simple single argument if any
diff --git a/lib/set.rb b/lib/set.rb
index cc7542f..a9aa7e7 100644
--- a/lib/set.rb
+++ b/lib/set.rb
@@ -99,21 +99,18 @@ class Set
end
def freeze # :nodoc:
- super
@hash.freeze
- self
+ super
end
def taint # :nodoc:
- super
@hash.taint
- self
+ super
end
def untaint # :nodoc:
- super
@hash.untaint
- self
+ super
end
# Returns the number of elements.
diff --git a/test/test_set.rb b/test/test_set.rb
index 9041182..26950c3 100644
--- a/test/test_set.rb
+++ b/test/test_set.rb
@@ -528,6 +528,27 @@ class TC_Set < Test::Unit::TestCase
}
end
+ def test_taintness
+ orig = set = Set[1,2,3]
+ assert_equal false, set.tainted?
+ assert_same orig, set.taint
+ assert_equal true, set.tainted?
+ assert_same orig, set.untaint
+ assert_equal false, set.tainted?
+ end
+
+ def test_freeze
+ orig = set = Set[1,2,3]
+ assert_equal false, set.frozen?
+ set << 4
+ assert_same orig, set.freeze
+ assert_equal true, set.frozen?
+ assert_raises(RuntimeError) {
+ set << 5
+ }
+ assert_equal 4, set.size
+ end
+
def test_inspect
set1 = Set[1]