diff --git a/ChangeLog b/ChangeLog index cbf7794614..4ab6a66bd7 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +Wed Mar 16 15:44:05 2016 Martin Duerst + + * test/ruby/enc/test_case_mapping.rb: Adding tests for actual Unicode + case mapping. Fixing some aliasing issues. + (with Kimihito Matsui) + Tue Mar 15 21:38:28 2016 Tanaka Akira * enum.c (enum_inject): Consider redefinition of Fixnum#+. diff --git a/test/ruby/enc/test_case_mapping.rb b/test/ruby/enc/test_case_mapping.rb index 0336e3f32f..d0bcd7620c 100644 --- a/test/ruby/enc/test_case_mapping.rb +++ b/test/ruby/enc/test_case_mapping.rb @@ -8,31 +8,39 @@ class TestCaseMappingPreliminary < Test::Unit::TestCase # checks, including idempotence and non-modification; not always guaranteed def check_upcase_properties(expected, start, *flags) assert_equal expected, start.upcase(*flags) - temp = start + temp = start.dup assert_equal expected, temp.upcase!(*flags) assert_equal expected, expected.upcase(*flags) - temp = expected + temp = expected.dup assert_nil temp.upcase!(*flags) end def check_downcase_properties(expected, start, *flags) assert_equal expected, start.downcase(*flags) - temp = start + temp = start.dup assert_equal expected, temp.downcase!(*flags) assert_equal expected, expected.downcase(*flags) - temp = expected + temp = expected.dup assert_nil temp.downcase!(*flags) end def check_capitalize_properties(expected, start, *flags) assert_equal expected, start.capitalize(*flags) - temp = start + temp = start.dup assert_equal expected, temp.capitalize!(*flags) assert_equal expected, expected.capitalize(*flags) - temp = expected + temp = expected.dup assert_nil temp.capitalize!(*flags) end + def check_capitalize_suffixes(lower, upper) + while not upper.length > 1 + lower = lower[1..-1] + check_capitalize_properties upper[0]+lower, upper, :lithuanian + upper = upper[1..-1] + end + end + # different properties; careful: roundtrip isn't always guaranteed def check_swapcase_properties(expected, start, *flags) assert_equal expected, start.swapcase(*flags) @@ -49,6 +57,13 @@ class TestCaseMappingPreliminary < Test::Unit::TestCase check_swapcase_properties 'yUKIHIRO matsumoto (MAtz)', 'Yukihiro MATSUMOTO (maTZ)', :lithuanian end + def test_general + check_downcase_properties 'résumé dürst ĭñŧėřŋãţijňőńæłĩżàťïōņ', 'RÉSUMÉ DÜRST ĬÑŦĖŘŊÃŢIJŇŐŃÆŁĨŻÀŤÏŌŅ', :lithuanian + check_upcase_properties 'RÉSUMÉ DÜRST ĬÑŦĖŘŊÃŢIJŇŐŃÆŁĨŻÀŤÏŌŅ', 'résumé dürst ĭñŧėřŋãţijňőńæłĩżàťïōņ', :lithuanian + check_capitalize_suffixes 'résumé dürst ĭñŧėřŋãţijňőńæłĩżàťïōņ', 'RÉSUMÉ DÜRST ĬÑŦĖŘŊÃŢIJŇŐŃÆŁĨŻÀŤÏŌŅ' + check_swapcase_properties 'résumé DÜRST ĭñŧėřŊÃŢIJŇŐŃæłĩżàťïōņ', 'RÉSUMÉ dürst ĬÑŦĖŘŋãţijňőńÆŁĨŻÀŤÏŌŅ', :lithuanian + end + def test_ascii_option check_downcase_properties 'yukihiro matsumoto (matz)', 'Yukihiro MATSUMOTO (MATZ)', :ascii check_upcase_properties 'YUKIHIRO MATSUMOTO (MATZ)', 'yukihiro matsumoto (matz)', :ascii