test/test_detect_general.rb in locale-2.0.8 vs test/test_detect_general.rb in locale-2.0.9

- old
+ new

@@ -26,18 +26,20 @@ def setup Locale.init Locale.clear_all ENV["LC_ALL"] = nil - ENV["LC_CTYPES"] = nil + ENV["LC_CTYPE"] = nil + ENV["LC_MESSAGES"] = nil ENV["LANG"] = nil ENV["LANGUAGE"] = nil end def test_lc_all ENV["LC_ALL"] = "ja_JP.eucJP" - ENV["LC_CTYPES"] = "zh_CN.UTF-8" #Ignored. + ENV["LC_CTYPE"] = "fr_FR.ISO-8859-1" #Ignored. + ENV["LC_MESSAGES"] = "zh_CN.UTF-8" #Ignored. ENV["LANG"] = "ko_KR.UTF-8" #Ignored. ENV["LANGUAGE"] = nil lang = Locale.current[0] assert_equal Locale::Tag::Posix, lang.class @@ -49,27 +51,46 @@ assert_equal "eucJP", Locale.charset end def test_lc_messages ENV["LC_ALL"] = nil - ENV["LC_CTYPES"] = "ja_JP.eucJP" - ENV["LANG"] = "ko_KR.UTF-8" #Ignored. + ENV["LC_CTYPE"] = nil + ENV["LC_MESSAGES"] = "ja_JP.eucJP" + ENV["LANG"] = "ko_KR.UTF-8" #Ignored except charset. ENV["LANGUAGE"] = nil lang = Locale.current[0] assert_equal Locale::Tag::Posix, lang.class assert_equal "ja", lang.language assert_equal "JP", lang.region assert_equal "eucJP", lang.charset assert_equal Locale::Tag::Posix.new("ja", "JP", "eucJP"), lang - assert_equal "eucJP", Locale.charset + assert_equal "UTF-8", Locale.charset end + def test_lc_messages_with_lc_ctype + ENV["LC_ALL"] = nil + ENV["LC_CTYPE"] = "fr_FR.ISO-8859-1" + ENV["LC_MESSAGES"] = "ja_JP.eucJP" + ENV["LANG"] = "ko_KR.UTF-8" #Ignored. + ENV["LANGUAGE"] = nil + + lang = Locale.current[0] + assert_equal Locale::Tag::Posix, lang.class + assert_equal "ja", lang.language + assert_equal "JP", lang.region + assert_equal "ISO-8859-1", lang.charset + assert_equal Locale::Tag::Posix.new("ja", "JP", "ISO-8859-1"), lang + + assert_equal "ISO-8859-1", Locale.charset + end + def test_lang ENV["LC_ALL"] = nil - ENV["LC_CTYPES"] = nil + ENV["LC_CTYPE"] = nil + ENV["LC_MESSAGES"] = nil ENV["LANG"] = "ja_JP.eucJP" ENV["LANGUAGE"] = nil lang = Locale.current[0] assert_equal Locale::Tag::Posix, lang.class @@ -79,13 +100,31 @@ assert_equal Locale::Tag::Posix.new("ja", "JP", "eucJP"), lang assert_equal "eucJP", Locale.charset end + def test_lang_with_ctype + ENV["LC_ALL"] = nil + ENV["LC_CTYPE"] = "fr_FR.ISO-8859-1" + ENV["LC_MESSAGES"] = nil + ENV["LANG"] = "ja_JP.eucJP" + ENV["LANGUAGE"] = nil + + lang = Locale.current[0] + assert_equal Locale::Tag::Posix, lang.class + assert_equal "ja", lang.language + assert_equal "JP", lang.region + assert_equal "ISO-8859-1", lang.charset + assert_equal Locale::Tag::Posix.new("ja", "JP", "ISO-8859-1"), lang + + assert_equal "ISO-8859-1", Locale.charset + end + def test_lang_complex ENV["LC_ALL"] = "zh_CN.UTF-8" # Ignored. - ENV["LC_CTYPES"] = "ko_KR.UTF-8" #Ingored. + ENV["LC_CTYPE"] = "fr_FR.ISO-8859-1" #Ingored. + ENV["LC_MESSAGES"] = "ko_KR.UTF-8" #Ingored. ENV["LANG"] = "en_US.UTF-8" # Ignored. ENV["LANGUAGE"] ="ja_JP.eucJP:zh_CN.UTF-8" lang = Locale.current[0] assert_equal Locale::Tag::Posix, lang.class @@ -228,9 +267,43 @@ Locale.clear ENV["LANGUAGE"] = "zh_CN.UTF-8:ja_JP" assert_equal Locale::Tag::Posix.parse("zh_CN.UTF-8"), Locale.current[0] assert_equal Locale::Tag::Posix.parse("ja_JP"), Locale.current[1] + end + + class TestCharset < self + def test_lc_all + ENV["LC_ALL"] = "ja_JP.eucJP" + ENV["LC_CTYPE"] = "ko_KR.eucKR" # Ignored. + ENV["LANG"] = "fr_FR.ISO-8859-1" # Ignored. + + assert_equal("eucJP", Locale.charset) + end + + def test_lc_ctype + ENV["LC_ALL"] = nil + ENV["LC_CTYPE"] = "ko_KR.eucKR" + ENV["LANG"] = "fr_FR.ISO-8859-1" # Ignored. + + assert_equal("eucKR", Locale.charset) + end + + def test_lc_messages + ENV["LC_ALL"] = nil + ENV["LC_MESSAGES"] = "ko_KR.eucKR" # Ignored. + ENV["LANG"] = "fr_FR.ISO-8859-1" + + assert_equal("ISO-8859-1", Locale.charset) + end + + def test_lang + ENV["LC_ALL"] = nil + ENV["LC_CTYPE"] = nil + ENV["LANG"] = "fr_FR.ISO-8859-1" + + assert_equal("ISO-8859-1", Locale.charset) + end end private def jruby? RUBY_PLATFORM == "java"