aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/test/core_ext
diff options
context:
space:
mode:
authorJeremy Kemper <jeremy@bitsweat.net>2007-11-14 10:02:26 +0000
committerJeremy Kemper <jeremy@bitsweat.net>2007-11-14 10:02:26 +0000
commita75cafbda23e6381420d940058eddb1a8de54b5a (patch)
treef37f9a779a87ad0ffe64c8090a9983199b5f6c7c /activesupport/test/core_ext
parent696d140b6ce291262861ce7fc146de79461a8ecc (diff)
downloadrails-a75cafbda23e6381420d940058eddb1a8de54b5a.tar.gz
rails-a75cafbda23e6381420d940058eddb1a8de54b5a.tar.bz2
rails-a75cafbda23e6381420d940058eddb1a8de54b5a.zip
Speedup String#blank? and remove some overspecified tests.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8137 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/test/core_ext')
-rw-r--r--activesupport/test/core_ext/blank_test.rb43
1 files changed, 4 insertions, 39 deletions
diff --git a/activesupport/test/core_ext/blank_test.rb b/activesupport/test/core_ext/blank_test.rb
index a14edf440b..27b9813ac4 100644
--- a/activesupport/test/core_ext/blank_test.rb
+++ b/activesupport/test/core_ext/blank_test.rb
@@ -8,47 +8,12 @@ class EmptyFalse
def empty?() false; end
end
-class EmptyStripNotEmpty
- def empty?() true; end
- def strip() 'foo'; end
-end
-
-class EmptyStripEmpty
- def empty?() true; end
- def strip() ''; end
-end
-
-class NotEmptyStripNotEmpty
- def empty?() false; end
- def strip() 'foo'; end
-end
-
-class NotEmptyStripEmpty
- def empty?() false; end
- def strip() ''; end
-end
-
class BlankTest < Test::Unit::TestCase
- BLANK = [ EmptyTrue.new, EmptyStripNotEmpty.new, EmptyStripEmpty.new,
- NotEmptyStripEmpty.new, nil, false, '', ' ', " \n\t \r ",
- [], {} ]
- NOT = [ EmptyFalse.new, NotEmptyStripNotEmpty.new, Object.new, true,
- 0, 1, 'a', [nil], { nil => 0 } ]
-
- class EmptyObject
- def empty?
- true
- end
- alias :strip :empty?
- end
- class NoStripObject < EmptyObject; undef :strip; end
- class NoEmptyStripObject < NoStripObject; undef :empty?; end
+ BLANK = [ EmptyTrue.new, nil, false, '', ' ', " \n\t \r ", [], {} ]
+ NOT = [ EmptyFalse.new, Object.new, true, 0, 1, 'a', [nil], { nil => 0 } ]
def test_blank
- BLANK.each { |v| assert v.blank? }
- NOT.each { |v| assert !v.blank? }
- assert EmptyObject.new.blank?
- assert NoStripObject.new.blank?
- assert !NoEmptyStripObject.new.blank?
+ BLANK.each { |v| assert v.blank?, "#{v.inspect} should be blank" }
+ NOT.each { |v| assert !v.blank?, "#{v.inspect} should not be blank" }
end
end