test/tools/test_msgmerge.rb in gettext-2.3.6 vs test/tools/test_msgmerge.rb in gettext-2.3.7
- old
+ new
@@ -330,49 +330,10 @@
merged_po = @merger.merge(@po, @pot)
assert_equal("salut", merged_po["hello"].msgstr)
end
- def test_similar_msgstr_for_fuzzy
- @po["helol"] = "bonjour"
- @pot["hello"] = ""
- merged_po = @merger.merge(@po, @pot)
-
- assert_false(merged_po.has_key?("helol"))
- assert_true(merged_po.has_key?("hello"))
- assert_equal("bonjour", merged_po["hello"].msgstr)
- assert_equal("fuzzy", merged_po["hello"].flag)
- end
-
- def test_nonexistent_msgctxt
- @po["normal", "hello"] = generate_entry(:msgctxt => "normal",
- :msgid => "hello",
- :msgstr => "salut")
- @pot["hello"] = generate_entry(:msgid => "hello",
- :msgstr => "")
- merged_po = @merger.merge(@po, @pot)
-
- assert_false(merged_po.has_key?("normal", "hello"))
- assert_true(merged_po.has_key?("hello"))
- assert_equal("salut", merged_po["hello"].msgstr)
- assert_equal("fuzzy", merged_po["hello"].flag)
- end
-
- def test_msgid_plural
- @po["he"] = generate_entry(:msgid => "he",
- :msgid_plural => "thye",
- :msgstr => "il\000ils")
- @pot["he"] = generate_entry(:msgid => "he",
- :msgid_plural => "they",
- :msgstr => "")
- merged_po = @merger.merge(@po, @pot)
-
- assert_equal("il\000ils", merged_po["he"].msgstr)
- assert_equal("they", merged_po["he"].msgid_plural)
- assert_equal("fuzzy", merged_po["he"].flag)
- end
-
def test_translator_comment
@po["hello"] = generate_entry(:msgid => "hello",
:msgstr => "bonjour",
:translator_comment => "comment")
@@ -427,23 +388,10 @@
merged_po = @merger.merge(@po, @pot)
assert_equal("bonjour", merged_po["hello"].msgstr)
assert_equal("no-c-format", merged_po["hello"].flag)
end
- def test_fuzzy_flag
- @po["hello"] = generate_entry(:msgid => "hello",
- :msgstr => "bonjuor",
- :flag => "fuzzy")
-
- @pot["hello"] = generate_entry(:msgid => "hello",
- :msgstr => "")
-
- merged_po = @merger.merge(@po, @pot)
- assert_equal("bonjuor", merged_po["hello"].msgstr)
- assert_equal("fuzzy", merged_po["hello"].flag)
- end
-
def test_previous
@po["hello"] = generate_entry(:msgid => "hello",
:msgstr => "bonjour",
:previous => "hi")
@@ -453,40 +401,106 @@
merged_po = @merger.merge(@po, @pot)
assert_equal("bonjour", merged_po["hello"].msgstr)
assert_equal(nil, merged_po["hello"].previous)
end
- def test_fuzzy_header
- @po[""] = generate_entry(:msgid => "",
- :msgstr => "header\nentry",
- :translator_comment => "header comment")
+ class TestAddNoFuzzy < self
+ def test_add_to_nontranslated_entry
+ @po["helol"] = generate_entry(:msgid => "helol",
+ :msgstr => nil)
+ @pot["hello"] = generate_entry(:msgid => "hello",
+ :msgstr => nil)
+ merged_po = @merger.merge(@po, @pot)
+ assert_true(merged_po.has_key?("hello"))
+ assert_nil(merged_po["hello"].flag)
+ end
- @pot[""] = generate_entry(:msgid => "",
- :msgstr => "uninitialized\ncomment",
- :translator_comment => "uninitialized comment",
- :flag => "fuzzy")
+ def test_fuzzy_header
+ @po[""] = generate_entry(:msgid => "",
+ :msgstr => "header\nentry",
+ :translator_comment => "header comment")
- merged_po = @merger.merge(@po, @pot)
- assert_equal("header\nentry", merged_po[""].msgstr)
- assert_equal("header comment", merged_po[""].translator_comment)
- assert_equal(nil, merged_po[""].flag)
+ @pot[""] = generate_entry(:msgid => "",
+ :msgstr => "uninitialized\ncomment",
+ :translator_comment => "uninitialized comment",
+ :flag => "fuzzy")
+
+ merged_po = @merger.merge(@po, @pot)
+ assert_equal("header\nentry", merged_po[""].msgstr)
+ assert_equal("header comment", merged_po[""].translator_comment)
+ assert_equal(nil, merged_po[""].flag)
+ end
+
+ def test_fuzzy_header_including_pot_creation_date
+ creation_date_mark = "POT-Creation-Date: "
+ po_creation_date = "#{creation_date_mark}2012-11-15 08:15+0900"
+ pot_creation_date = "#{creation_date_mark}2012-11-20 14:15+0900"
+ @po[""] = generate_entry(:msgid => "",
+ :msgstr => po_creation_date,
+ :translator_comment => "header comment")
+
+ @pot[""] = generate_entry(:msgid => "",
+ :msgstr => pot_creation_date,
+ :translator_comment => "header comment",
+ :flag => "fuzzy")
+
+ merged_po = @merger.merge(@po, @pot)
+ assert_equal(pot_creation_date, merged_po[""].msgstr)
+ end
end
- def test_fuzzy_header_including_pot_creation_date
- creation_date_mark = "POT-Creation-Date: "
- po_creation_date = "#{creation_date_mark}2012-11-15 08:15+0900"
- pot_creation_date = "#{creation_date_mark}2012-11-20 14:15+0900"
- @po[""] = generate_entry(:msgid => "",
- :msgstr => po_creation_date,
- :translator_comment => "header comment")
+ class TestAddFuzzy < self
+ def test_nonexistent_msgctxt
+ @po["normal", "hello"] = generate_entry(:msgctxt => "normal",
+ :msgid => "hello",
+ :msgstr => "salut")
+ @pot["hello"] = generate_entry(:msgid => "hello",
+ :msgstr => "")
+ merged_po = @merger.merge(@po, @pot)
- @pot[""] = generate_entry(:msgid => "",
- :msgstr => pot_creation_date,
- :translator_comment => "header comment",
- :flag => "fuzzy")
+ assert_false(merged_po.has_key?("normal", "hello"))
+ assert_true(merged_po.has_key?("hello"))
+ assert_equal("salut", merged_po["hello"].msgstr)
+ assert_equal("fuzzy", merged_po["hello"].flag)
+ end
- merged_po = @merger.merge(@po, @pot)
- assert_equal(pot_creation_date, merged_po[""].msgstr)
+ def test_msgid_plural
+ @po["he"] = generate_entry(:msgid => "he",
+ :msgid_plural => "thye",
+ :msgstr => "il\000ils")
+ @pot["he"] = generate_entry(:msgid => "he",
+ :msgid_plural => "they",
+ :msgstr => "")
+ merged_po = @merger.merge(@po, @pot)
+
+ assert_equal("il\000ils", merged_po["he"].msgstr)
+ assert_equal("they", merged_po["he"].msgid_plural)
+ assert_equal("fuzzy", merged_po["he"].flag)
+ end
+
+ def test_fuzzy_matching_entry
+ @po["helol"] = "bonjour"
+ @pot["hello"] = ""
+ merged_po = @merger.merge(@po, @pot)
+
+ assert_false(merged_po.has_key?("helol"))
+ assert_true(merged_po.has_key?("hello"))
+ assert_equal("bonjour", merged_po["hello"].msgstr)
+ assert_equal("fuzzy", merged_po["hello"].flag)
+ end
+
+ def test_merged_entry_from_fuzzy_entry
+ @po["hello"] = generate_entry(:msgid => "hello",
+ :msgstr => "bonjuor",
+ :flag => "fuzzy")
+
+ @pot["hello"] = generate_entry(:msgid => "hello",
+ :msgstr => "")
+
+ merged_po = @merger.merge(@po, @pot)
+ assert_equal("bonjuor", merged_po["hello"].msgstr)
+ assert_equal("fuzzy", merged_po["hello"].flag)
+ end
end
def test_obsolete_entry
@po["hello"] = "bonjour"
@pot["hi"] = "salut"