예제 #1
0
 def testUnitConversion(self):
     fuzz = 1e-3
     s = TeX()
     s.input(r'1 pc')
     i = s.readDimen()
     assert i.pt - 12 < fuzz, i.pt
     s = TeX()
     s.input(r'1 in')
     i = s.readDimen()
     assert i.pt - 72.27 < fuzz, i.pt
     s = TeX()
     s.input(r'72 bp')
     i = s.readDimen()
     assert i.inch - 1 < fuzz, i.inch
     s = TeX()
     s.input(r'2.54 cm')
     i = s.readDimen()
     assert i.inch - 1 < fuzz, i.inch
     s = TeX()
     s.input(r'10 mm')
     i = s.readDimen()
     assert i.cm - 1 < fuzz, i.cm
     s = TeX()
     s.input(r'1157 dd')
     i = s.readDimen()
     assert i.pt - 1238 < fuzz, i.pt
     s = TeX()
     s.input(r'1 cc')
     i = s.readDimen()
     assert i.dd - 12 < fuzz, i.dd
     s = TeX()
     s.input(r'65536 sp')
     i = s.readDimen()
     assert i.pt - 1 < fuzz, i.pt
예제 #2
0
 def testUnitConversion(self):
     fuzz = 1e-3
     s = TeX()
     s.input(r'1 pc')
     i = s.readDimen()
     assert i.pt - 12 < fuzz, i.pt
     s = TeX()
     s.input(r'1 in')
     i = s.readDimen()
     assert i.pt - 72.27 < fuzz, i.pt
     s = TeX()
     s.input(r'72 bp')
     i = s.readDimen()
     assert i.inch - 1 < fuzz, i.inch
     s = TeX()
     s.input(r'2.54 cm')
     i = s.readDimen()
     assert i.inch - 1 < fuzz, i.inch
     s = TeX()
     s.input(r'10 mm')
     i = s.readDimen()
     assert i.cm - 1 < fuzz, i.cm
     s = TeX()
     s.input(r'1157 dd')
     i = s.readDimen()
     assert i.pt - 1238 < fuzz, i.pt
     s = TeX()
     s.input(r'1 cc')
     i = s.readDimen()
     assert i.dd - 12 < fuzz, i.dd
     s = TeX()
     s.input(r'65536 sp')
     i = s.readDimen()
     assert i.pt - 1 < fuzz, i.pt
예제 #3
0
 def testReadDimen2(self):
     # This is illegal
     #       s = TeX()
     #       s.input(r"'.77pt")
     #       i = s.readDimen()
     #       s = TeX()
     #       s.input(r'"Ccc')
     #       i = s.readDimen()
     s = TeX()
     s.input(r'-,sp')
     i = s.readDimen()
     assert i.sp == 0, i.sp
예제 #4
0
    def testReadDimen2(self):
        # This is illegal
#       s = TeX()
#       s.input(r"'.77pt")
#       i = s.readDimen()
#       s = TeX()
#       s.input(r'"Ccc')
#       i = s.readDimen()
        s = TeX()
        s.input(r'-,sp')
        i = s.readDimen()
        assert i.sp == 0, i.sp
예제 #5
0
 def testReadDimen(self):
     fuzz = 1e-3
     s = TeX()
     s.input(r'3 in')
     i = s.readDimen()
     assert i.inch - 3 < fuzz, i.inch
     s = TeX()
     s.input(r'29 pc')
     i = s.readDimen()
     assert i.pc - 29 < fuzz, i.pc
     s = TeX()
     s.input(r'-.013837in')
     i = s.readDimen()
     assert i.inch - -0.013837 < fuzz, i.inch
     s = TeX()
     s.input(r'+ 42,1 dd')
     i = s.readDimen()
     assert i.dd - 42.1 < fuzz, i.dd
     s = TeX()
     s.input(r'0.mm')
     i = s.readDimen()
     assert i.mm - 0 < fuzz, i.mm
     s = TeX()
     s.input(r'123456789sp')
     i = s.readDimen()
     assert i.sp - 123456789 < fuzz, i.sp
예제 #6
0
 def testReadDimen(self):
     fuzz = 1e-3
     s = TeX()
     s.input(r'3 in')
     i = s.readDimen()
     assert i.inch - 3 < fuzz, i.inch
     s = TeX()
     s.input(r'29 pc')
     i = s.readDimen()
     assert i.pc - 29 < fuzz, i.pc 
     s = TeX()
     s.input(r'-.013837in')
     i = s.readDimen()
     assert i.inch - -0.013837 < fuzz, i.inch
     s = TeX()
     s.input(r'+ 42,1 dd')
     i = s.readDimen()
     assert i.dd - 42.1 < fuzz, i.dd
     s = TeX()
     s.input(r'0.mm')
     i = s.readDimen()
     assert i.mm - 0 < fuzz, i.mm
     s = TeX()
     s.input(r'123456789sp')
     i = s.readDimen()
     assert i.sp - 123456789 < fuzz, i.sp