diff options
author | Xavier Noria <fxn@hashref.com> | 2010-05-27 10:57:05 +0200 |
---|---|---|
committer | Xavier Noria <fxn@hashref.com> | 2010-05-27 10:57:05 +0200 |
commit | ddec74fb3ab66528ca98ff37ca9b5f4227fdd2e3 (patch) | |
tree | c58ac9162487bdca68342fb2d30730ccfd926378 /activesupport/test | |
parent | 96e2094b8b634e4af0d9d3c8a1db9bbb7023a4a7 (diff) | |
parent | e02db06ece7aeecec7c37f5b0e3de7d65c8684e6 (diff) | |
download | rails-ddec74fb3ab66528ca98ff37ca9b5f4227fdd2e3.tar.gz rails-ddec74fb3ab66528ca98ff37ca9b5f4227fdd2e3.tar.bz2 rails-ddec74fb3ab66528ca98ff37ca9b5f4227fdd2e3.zip |
Merge remote branch 'rails/master'
Diffstat (limited to 'activesupport/test')
-rw-r--r-- | activesupport/test/core_ext/duration_test.rb | 1 | ||||
-rw-r--r-- | activesupport/test/core_ext/string_ext_test.rb | 8 | ||||
-rw-r--r-- | activesupport/test/core_ext/time_with_zone_test.rb | 2 | ||||
-rw-r--r-- | activesupport/test/dependencies_test.rb | 2 | ||||
-rw-r--r-- | activesupport/test/inflector_test.rb | 4 | ||||
-rw-r--r-- | activesupport/test/multibyte_chars_test.rb | 89 | ||||
-rw-r--r-- | activesupport/test/multibyte_conformance.rb | 2 | ||||
-rw-r--r-- | activesupport/test/multibyte_unicode_database_test.rb | 12 |
8 files changed, 58 insertions, 62 deletions
diff --git a/activesupport/test/core_ext/duration_test.rb b/activesupport/test/core_ext/duration_test.rb index 05f529dc7d..710c221fac 100644 --- a/activesupport/test/core_ext/duration_test.rb +++ b/activesupport/test/core_ext/duration_test.rb @@ -5,6 +5,7 @@ class DurationTest < ActiveSupport::TestCase def test_is_a d = 1.day assert d.is_a?(ActiveSupport::Duration) + assert_kind_of ActiveSupport::Duration, d assert_kind_of Numeric, d assert_kind_of Fixnum, d assert !d.is_a?(Hash) diff --git a/activesupport/test/core_ext/string_ext_test.rb b/activesupport/test/core_ext/string_ext_test.rb index ea21e445e2..759b0ddcd6 100644 --- a/activesupport/test/core_ext/string_ext_test.rb +++ b/activesupport/test/core_ext/string_ext_test.rb @@ -245,11 +245,9 @@ class CoreExtStringMultibyteTest < ActiveSupport::TestCase assert_kind_of ActiveSupport::Multibyte.proxy_class, UNICODE_STRING.mb_chars end end - end - - if RUBY_VERSION >= '1.9' - def test_mb_chars_returns_string - assert_kind_of String, UNICODE_STRING.mb_chars + else + def test_mb_chars_returns_instance_of_proxy_class + assert_kind_of ActiveSupport::Multibyte.proxy_class, UNICODE_STRING.mb_chars end end end diff --git a/activesupport/test/core_ext/time_with_zone_test.rb b/activesupport/test/core_ext/time_with_zone_test.rb index 77b1893f77..2cf5bd6ea9 100644 --- a/activesupport/test/core_ext/time_with_zone_test.rb +++ b/activesupport/test/core_ext/time_with_zone_test.rb @@ -326,7 +326,7 @@ class TimeWithZoneTest < Test::Unit::TestCase def test_is_a assert_kind_of Time, @twz assert_kind_of Time, @twz - assert ActiveSupport::TimeWithZone, @twz + assert_kind_of ActiveSupport::TimeWithZone, @twz end def test_class_name diff --git a/activesupport/test/dependencies_test.rb b/activesupport/test/dependencies_test.rb index 2cbf9e5042..75ff88505d 100644 --- a/activesupport/test/dependencies_test.rb +++ b/activesupport/test/dependencies_test.rb @@ -371,7 +371,7 @@ class DependenciesTest < Test::Unit::TestCase end def test_custom_const_missing_should_work - Object.module_eval <<-end_eval + Object.module_eval <<-end_eval, __FILE__, __LINE__ + 1 module ModuleWithCustomConstMissing def self.const_missing(name) const_set name, name.to_s.hash diff --git a/activesupport/test/inflector_test.rb b/activesupport/test/inflector_test.rb index 76bdc0e973..2990177bed 100644 --- a/activesupport/test/inflector_test.rb +++ b/activesupport/test/inflector_test.rb @@ -209,14 +209,14 @@ class InflectorTest < Test::Unit::TestCase end %w{plurals singulars uncountables humans}.each do |inflection_type| - class_eval " + class_eval <<-RUBY, __FILE__, __LINE__ + 1 def test_clear_#{inflection_type} cached_values = ActiveSupport::Inflector.inflections.#{inflection_type} ActiveSupport::Inflector.inflections.clear :#{inflection_type} assert ActiveSupport::Inflector.inflections.#{inflection_type}.empty?, \"#{inflection_type} inflections should be empty after clear :#{inflection_type}\" ActiveSupport::Inflector.inflections.instance_variable_set :@#{inflection_type}, cached_values end - " + RUBY end def test_clear_all diff --git a/activesupport/test/multibyte_chars_test.rb b/activesupport/test/multibyte_chars_test.rb index f15b1351f7..f7a5834527 100644 --- a/activesupport/test/multibyte_chars_test.rb +++ b/activesupport/test/multibyte_chars_test.rb @@ -36,7 +36,7 @@ class MultibyteCharsTest < Test::Unit::TestCase end def test_forwarded_bang_method_calls_should_return_the_original_chars_instance - assert_kind_of @proxy_class, @chars.__method_for_multibyte_testing! + assert_kind_of @proxy_class, @chars.__method_for_multibyte_testing! assert_equal @chars.object_id, @chars.__method_for_multibyte_testing!.object_id end @@ -65,33 +65,32 @@ class MultibyteCharsTest < Test::Unit::TestCase end def test_unpack_utf8_strings - assert_equal 4, @proxy_class.u_unpack(UNICODE_STRING).length - assert_equal 5, @proxy_class.u_unpack(ASCII_STRING).length + assert_equal 4, ActiveSupport::Multibyte::Unicode.u_unpack(UNICODE_STRING).length + assert_equal 5, ActiveSupport::Multibyte::Unicode.u_unpack(ASCII_STRING).length end def test_unpack_raises_encoding_error_on_broken_strings assert_raise(ActiveSupport::Multibyte::EncodingError) do - @proxy_class.u_unpack(BYTE_STRING) + ActiveSupport::Multibyte::Unicode.u_unpack(BYTE_STRING) end end - if RUBY_VERSION < '1.9' - def test_concatenation_should_return_a_proxy_class_instance - assert_equal ActiveSupport::Multibyte.proxy_class, ('a'.mb_chars + 'b').class - assert_equal ActiveSupport::Multibyte.proxy_class, ('a'.mb_chars << 'b').class - end + def test_concatenation_should_return_a_proxy_class_instance + assert_equal ActiveSupport::Multibyte.proxy_class, ('a'.mb_chars + 'b').class + assert_equal ActiveSupport::Multibyte.proxy_class, ('a'.mb_chars << 'b').class + end - def test_ascii_strings_are_treated_at_utf8_strings - assert_equal ActiveSupport::Multibyte.proxy_class, ASCII_STRING.mb_chars.class - end + def test_ascii_strings_are_treated_at_utf8_strings + assert_equal ActiveSupport::Multibyte.proxy_class, ASCII_STRING.mb_chars.class + end - def test_concatenate_should_return_proxy_instance - assert(('a'.mb_chars + 'b').kind_of?(@proxy_class)) - assert(('a'.mb_chars + 'b'.mb_chars).kind_of?(@proxy_class)) - assert(('a'.mb_chars << 'b').kind_of?(@proxy_class)) - assert(('a'.mb_chars << 'b'.mb_chars).kind_of?(@proxy_class)) - end + def test_concatenate_should_return_proxy_instance + assert(('a'.mb_chars + 'b').kind_of?(@proxy_class)) + assert(('a'.mb_chars + 'b'.mb_chars).kind_of?(@proxy_class)) + assert(('a'.mb_chars << 'b').kind_of?(@proxy_class)) + assert(('a'.mb_chars << 'b'.mb_chars).kind_of?(@proxy_class)) end + end class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase @@ -111,35 +110,33 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase @byte_order_mark = [65279].pack('U') end - if RUBY_VERSION < '1.9' - def test_split_should_return_an_array_of_chars_instances - @chars.split(//).each do |character| - assert_kind_of ActiveSupport::Multibyte.proxy_class, character - end + def test_split_should_return_an_array_of_chars_instances + @chars.split(//).each do |character| + assert_kind_of ActiveSupport::Multibyte.proxy_class, character end + end - def test_indexed_insert_accepts_fixnums - @chars[2] = 32 - assert_equal 'こに わ', @chars - end + def test_indexed_insert_accepts_fixnums + @chars[2] = 32 + assert_equal 'こに わ', @chars + end - def test_overridden_bang_methods_return_self - [:rstrip!, :lstrip!, :strip!, :reverse!, :upcase!, :downcase!, :capitalize!].each do |method| - assert_equal @chars.object_id, @chars.send(method).object_id - end + def test_overridden_bang_methods_return_self + [:rstrip!, :lstrip!, :strip!, :reverse!, :upcase!, :downcase!, :capitalize!].each do |method| + assert_equal @chars.object_id, @chars.send(method).object_id end + end - def test_overridden_bang_methods_change_wrapped_string - [:rstrip!, :lstrip!, :strip!, :reverse!, :upcase!, :downcase!].each do |method| - original = ' Café ' - proxy = chars(original.dup) - proxy.send(method) - assert_not_equal original, proxy.to_s - end - proxy = chars('òu') - proxy.capitalize! - assert_equal 'Òu', proxy.to_s + def test_overridden_bang_methods_change_wrapped_string + [:rstrip!, :lstrip!, :strip!, :reverse!, :upcase!, :downcase!].each do |method| + original = ' Café ' + proxy = chars(original.dup) + proxy.send(method) + assert_not_equal original, proxy.to_s end + proxy = chars('òu') + proxy.capitalize! + assert_equal 'Òu', proxy.to_s end if RUBY_VERSION >= '1.9' @@ -151,11 +148,7 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase def test_identity assert_equal @chars, @chars assert @chars.eql?(@chars) - if RUBY_VERSION <= '1.9' - assert !@chars.eql?(UNICODE_STRING) - else - assert @chars.eql?(UNICODE_STRING) - end + assert !@chars.eql?(UNICODE_STRING) end def test_string_methods_are_chainable @@ -207,7 +200,7 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase assert_equal 'こわにちわ', @chars.insert(1, 'わ') assert_equal 'こわわわにちわ', @chars.insert(2, 'わわ') assert_equal 'わこわわわにちわ', @chars.insert(0, 'わ') - assert_equal 'わこわわわにちわ', @chars.wrapped_string if RUBY_VERSION < '1.9' + assert_equal 'わこわわわにちわ', @chars.wrapped_string end def test_insert_should_be_destructive @@ -330,7 +323,7 @@ class MultibyteCharsUTF8BehaviourTest < Test::Unit::TestCase assert_raise(ArgumentError) { @chars.center } end - def test_center_should_count_charactes_instead_of_bytes + def test_center_should_count_characters_instead_of_bytes assert_equal UNICODE_STRING, @chars.center(-3) assert_equal UNICODE_STRING, @chars.center(0) assert_equal UNICODE_STRING, @chars.center(4) diff --git a/activesupport/test/multibyte_conformance.rb b/activesupport/test/multibyte_conformance.rb index caae4791b4..6ec9a839af 100644 --- a/activesupport/test/multibyte_conformance.rb +++ b/activesupport/test/multibyte_conformance.rb @@ -28,7 +28,7 @@ end class MultibyteConformanceTest < Test::Unit::TestCase include MultibyteTestHelpers - UNIDATA_URL = "http://www.unicode.org/Public/#{ActiveSupport::Multibyte::UNICODE_VERSION}/ucd" + UNIDATA_URL = "http://www.unicode.org/Public/#{ActiveSupport::Multibyte::Unicode::UNICODE_VERSION}/ucd" UNIDATA_FILE = '/NormalizationTest.txt' CACHE_DIR = File.join(Dir.tmpdir, 'cache') diff --git a/activesupport/test/multibyte_unicode_database_test.rb b/activesupport/test/multibyte_unicode_database_test.rb index 405c7c2108..26a41579c2 100644 --- a/activesupport/test/multibyte_unicode_database_test.rb +++ b/activesupport/test/multibyte_unicode_database_test.rb @@ -1,21 +1,25 @@ # encoding: utf-8 require 'abstract_unit' + class MultibyteUnicodeDatabaseTest < Test::Unit::TestCase + + include ActiveSupport::Multibyte::Unicode + def setup - @ucd = ActiveSupport::Multibyte::UnicodeDatabase.new + @ucd = UnicodeDatabase.new end - ActiveSupport::Multibyte::UnicodeDatabase::ATTRIBUTES.each do |attribute| + UnicodeDatabase::ATTRIBUTES.each do |attribute| define_method "test_lazy_loading_on_attribute_access_of_#{attribute}" do @ucd.expects(:load) @ucd.send(attribute) end end - + def test_load @ucd.load - ActiveSupport::Multibyte::UnicodeDatabase::ATTRIBUTES.each do |attribute| + UnicodeDatabase::ATTRIBUTES.each do |attribute| assert @ucd.send(attribute).length > 1 end end |