[liblouis-liblouisxml] [liblouis] r738 committed - tests/runharness.py: add support for hyphenate tests....

  • From: liblouis@xxxxxxxxxxxxxx
  • To: liblouis-liblouisxml@xxxxxxxxxxxxx
  • Date: Tue, 17 Jul 2012 09:37:51 +0000

Revision: 738
Author:   mesar.hameed@xxxxxxxxx
Date:     Tue Jul 17 02:37:27 2012
Log:      tests/runharness.py: add support for hyphenate tests.
Thanks to Attila.
http://code.google.com/p/liblouis/source/detail?r=738

Modified:
 /trunk/tests/runHarness.py

=======================================
--- /trunk/tests/runHarness.py  Tue Jul 17 02:15:04 2012
+++ /trunk/tests/runHarness.py  Tue Jul 17 02:37:27 2012
@@ -32,7 +32,7 @@
 import sys
 import traceback
 from glob import iglob
-from louis import translate, backTranslateString
+from louis import translate, backTranslateString, hyphenate
from louis import noContractions, compbrlAtCursor, dotsIO, comp8Dots, pass1Only, compbrlLeftCursor, otherTrans, ucBrl

 try:
@@ -127,6 +127,19 @@
     def __str__(self):
         return "%s" % self.harnessName

+    def hyphenateword(self, tables, word, mode):
+ # FIXME: liblouis currently crashes if we dont add space at end of the word, probably due to a counter running past the end of the string. + # medium/longterm this hack should be removed, and the root of the problem found/resolved.
+        hyphen_mask=hyphenate(tables, word+' ', mode)
+        inlen=len(word)
+        hyphen_word = ''
+        for i in range(inlen):
+            if hyphen_mask[i]=='0':
+                hyphen_word=hyphen_word+word[i]
+            else:
+                hyphen_word=hyphen_word+'-'+word[i]
+        return hyphen_word
+
     def check_translate(self):
         if self.cursorPos is not None:
tBrl, temp1, temp2, tBrlCurPos = translate(self.tables, self.input, mode=self.mode, cursorPos=self.cursorPos)
@@ -169,6 +182,18 @@
         ]
assert tBrlCurPos == self.expectedBrlCursorPos, u("\n".join(report))

+    def check_hyphenate(self):
+ hyphenated_word = self.hyphenateword(self.tables, self.input, mode=self.mode)
+        template = "%-25s '%s'"
+        report = [
+            "--- Hyphenation failure: %s ---" % self.__str__(),
+            template % ("input:", self.input),
+            template % ("expected hyphenated word:", self.expectedOutput),
+            template % ("actual hyphenated word:", hyphenated_word),
+            "--- end ---",
+        ]
+        assert hyphenated_word == self.expectedOutput, u("\n".join(report))
+
 def test_allCases():
     harness_dir = "harness"
     if 'HARNESS_DIR' in os.environ:
@@ -209,6 +234,9 @@
                         yield bt.check_cursor
                 if test['testmode'] == 'backtranslate':
                     yield bt.check_backtranslate
+                if test['testmode'] == 'hyphenate':
+                    yield bt.check_hyphenate
+

 if __name__ == '__main__':
run(addplugins=[Reporter()], argv=['-v', '--with-reporter', sys.argv[0]], defaultTest=__name__)
For a description of the software, to download it and links to
project pages go to http://www.abilitiessoft.com

Other related posts:

  • » [liblouis-liblouisxml] [liblouis] r738 committed - tests/runharness.py: add support for hyphenate tests.... - liblouis