mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* 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
This commit is contained in:
parent
4a223fb67f
commit
6bdfe415df
3 changed files with 29 additions and 6 deletions
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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]
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue