| 1 |
#!/usr/bin/python3 |
| 2 |
# -*- coding: utf-8 -*- |
| 3 |
|
| 4 |
from base_test import IOTest |
| 5 |
import unittest |
| 6 |
|
| 7 |
class PretransferTest(IOTest, unittest.TestCase): |
| 8 |
"""Subclass and override inputs/expectedOutputs (and possibly other |
| 9 |
stuff) to create new pretransfer tests.""" |
| 10 |
|
| 11 |
flags = ["-z"] |
| 12 |
inputs = [""] |
| 13 |
expectedOutputs = [""] |
| 14 |
|
| 15 |
def runTest(self): |
| 16 |
self.runCommand(['../apertium/apertium-pretransfer'] + self.flags, |
| 17 |
zip(self.inputs, self.expectedOutputs)) |
| 18 |
|
| 19 |
class BasicPretransferTest(PretransferTest): |
| 20 |
inputs = ["^a<n>$", "^a<n>+c<po>$", "^a<vblex><pres># b$", "[<div>]^a<n>$", "[<div>]^a<vblex><pres># b$"] |
| 21 |
expectedOutputs = ["^a<n>$", "^a<n>$ ^c<po>$", "^a# b<vblex><pres>$", "[<div>]^a<n>$", "[<div>]^a# b<vblex><pres>$"] |
| 22 |
|
| 23 |
class JoinGroupPretransferTest(PretransferTest): |
| 24 |
inputs = ["[<div>]^a<vblex><pres>+c<po># b$", "[<div>]^a<vblex><pres>+c<po>+d<po># b$"] |
| 25 |
expectedOutputs = ["[<div>]^a# b<vblex><pres>$ ^c<po>$", "[<div>]^a# b<vblex><pres>$ ^c<po>$ ^d<po>$"] |
| 26 |
|
| 27 |
class WordboundBlankTestPretransferTest(PretransferTest): |
| 28 |
inputs = ["[[t:i:abc123]]^a<vblex><pres>+c<po># b$", "[[t:i:xyz456]]^a<vblex><pres>+c<po>+d<po># b$"] |
| 29 |
expectedOutputs = ["[[t:i:abc123]]^a# b<vblex><pres>$ [[t:i:abc123]]^c<po>$", "[[t:i:xyz456]]^a# b<vblex><pres>$ [[t:i:xyz456]]^c<po>$ [[t:i:xyz456]]^d<po>$"] |
| 30 |
|
| 31 |
class EscapingPretransferTest(PretransferTest): |
| 32 |
inputs = [ |
| 33 |
r'^\//\/<slash>$', |
| 34 |
r'^\$/\$<dollar>$', |
| 35 |
] |
| 36 |
expectedOutputs = [ |
| 37 |
r'^\//\/<slash>$', |
| 38 |
r'^\$/\$<dollar>$', |
| 39 |
] |
| 40 |
|
| 41 |
class NoSurfaceEscapingPretransferTest(PretransferTest): |
| 42 |
flags = ['-z', '-n'] |
| 43 |
inputs = [ |
| 44 |
r'^\//\/<slash>$', |
| 45 |
r'^\$/\$<dollar>$', |
| 46 |
] |
| 47 |
expectedOutputs = [ |
| 48 |
r'^\/<slash>$', |
| 49 |
r'^\$<dollar>$', |
| 50 |
] |