def testTeXNumber(self):
        s = TeX()
        s.input(r'''\newcount\mycount\mycount=120
                    \newdimen\mydimen\mydimen=12sp
                    \newskip\myglue\myglue=10sp plus1pt minus2pt''')
        s.parse()

        value = s.ownerDocument.context['mycount'].value
        assert value == count(120), value
        value = s.ownerDocument.context['mydimen'].value
        assert value == dimen('12sp'), value
        value = s.ownerDocument.context['myglue'].value
        assert value == glue('10sp', plus='1pt', minus='2pt'), value

        # Literal number
        s.input('100')
        arg = s.readArgument(type='Number')
        assert arg == count('100'), arg

        # Set by other dimen
        s.input(r'\mycount')
        arg = s.readArgument(type='Number')
        assert arg == count('120'), arg

        # Multiply by other dimen
        s.input(r'3\mycount')
        arg = s.readArgument(type='Number')
        assert arg == count('360'), arg

        # No number
        s.input('{0}')
        arg = s.readArgument(type='Number')
        assert arg == count(0), arg

        assert ParameterCommand._enablelevel == 0
    def testNumber(self):
        s = TeX()
        s.input(r'''\newcount\mycount\mycount=120
                    \newdimen\mydimen\mydimen=12sp
                    \newskip\myglue\myglue=10sp plus1pt minus2pt''')
        s.parse()

        value = s.ownerDocument.context['mycount'].value
        assert value == count(120), value
        value = s.ownerDocument.context['mydimen'].value
        assert value == dimen('12sp'), value
        value = s.ownerDocument.context['myglue'].value
        assert value == glue('10sp', plus='1pt', minus='2pt'), value

        # Literal number, this will only parse the `1`
        s.input('100')
        arg = s.readArgument(type='number')
        assert arg == count(1), arg

        # Literal number
        s.input('{100}')
        arg = s.readArgument(type='number')
        assert arg == count(100), arg

        # Set by other number
        s.input(r'\mycount')
        arg = s.readArgument(type='number')
        assert arg == count(120), arg

        # Set by other number
        s.input(r'{\mycount}')
        arg = s.readArgument(type='number')
        assert arg == count(120), arg

        # Multiply by other number
        s.input(r'{5\mycount}')
        arg = s.readArgument(type='number')
        assert arg == count(600), arg

        # No number
        s.input('{a}')
        arg = s.readArgument(type='number')
        assert arg == count(0), arg

        # No number
        s.input('b')
        arg = s.readArgument(type='number')
        assert arg == count(0), arg

        # Coerced dimen
        s.input(r'{\mydimen}')
        arg = s.readArgument(type='number')
        assert arg == count(12), arg

        # Coerced glue
        s.input(r'{\myglue}')
        arg = s.readArgument(type='number')
        assert arg == count(10), arg

        assert ParameterCommand._enablelevel == 0
    def testTeXNumber(self):
        s = TeX()
        s.input(r'''\newcount\mycount\mycount=120
                    \newdimen\mydimen\mydimen=12sp
                    \newskip\myglue\myglue=10sp plus1pt minus2pt''')
        s.parse()

        value = s.ownerDocument.context['mycount'].value
        assert value == count(120), value
        value = s.ownerDocument.context['mydimen'].value
        assert value == dimen('12sp'), value
        value = s.ownerDocument.context['myglue'].value
        assert value == glue('10sp', plus='1pt', minus='2pt'), value

        # Literal number
        s.input('100')
        arg = s.readArgument(type='Number')
        assert arg == count('100'), arg

        # Set by other dimen
        s.input(r'\mycount')
        arg = s.readArgument(type='Number')
        assert arg == count('120'), arg

        # Multiply by other dimen
        s.input(r'3\mycount')
        arg = s.readArgument(type='Number')
        assert arg == count('360'), arg

        # No number
        s.input('{0}')
        arg = s.readArgument(type='Number')
        assert arg == count(0), arg

        assert ParameterCommand._enablelevel == 0
    def testNumber(self):
        s = TeX()
        s.input(r'''\newcount\mycount\mycount=120
                    \newdimen\mydimen\mydimen=12sp
                    \newskip\myglue\myglue=10sp plus1pt minus2pt''')
        s.parse()

        value = s.ownerDocument.context['mycount'].value
        assert value == count(120), value
        value = s.ownerDocument.context['mydimen'].value
        assert value == dimen('12sp'), value
        value = s.ownerDocument.context['myglue'].value
        assert value == glue('10sp', plus='1pt', minus='2pt'), value

        # Literal number, this will only parse the `1`
        s.input('100')
        arg = s.readArgument(type='number')
        assert arg == count(1), arg

        # Literal number
        s.input('{100}')
        arg = s.readArgument(type='number')
        assert arg == count(100), arg

        # Set by other number
        s.input(r'\mycount')
        arg = s.readArgument(type='number')
        assert arg == count(120), arg

        # Set by other number
        s.input(r'{\mycount}')
        arg = s.readArgument(type='number')
        assert arg == count(120), arg

        # Multiply by other number
        s.input(r'{5\mycount}')
        arg = s.readArgument(type='number')
        assert arg == count(600), arg

        # No number
        s.input('{a}')
        arg = s.readArgument(type='number')
        assert arg == count(0), arg

        # No number
        s.input('b')
        arg = s.readArgument(type='number')
        assert arg == count(0), arg

        # Coerced dimen
        s.input(r'{\mydimen}')
        arg = s.readArgument(type='number')
        assert arg == count(12), arg

        # Coerced glue
        s.input(r'{\myglue}')
        arg = s.readArgument(type='number')
        assert arg == count(10), arg

        assert ParameterCommand._enablelevel == 0
    def testTeXDimen(self):
        s = TeX()
        s.input(r'''\newcount\mycount\mycount=120
                    \newdimen\mydimen\mydimen=12sp
                    \newskip\myglue\myglue=10sp plus1pt minus2pt''')
        s.parse()

        value = s.ownerDocument.context['mycount'].value
        assert value == count(120), value
        value = s.ownerDocument.context['mydimen'].value
        assert value == dimen('12sp'), value
        value = s.ownerDocument.context['myglue'].value
        assert value == glue('10sp', plus='1pt', minus='2pt'), value

        # Literal dimension
        s.input(r'3.5pt')
        arg = s.readArgument(type='Dimen')
        assert arg == dimen('3.5pt'), arg

        # Literal dimension, {...} aren't allowed
        s.input(r'{3.5pt}')
        arg = s.readArgument(type='Dimen')
        assert arg == dimen(0), arg

        # Set by other dimension
        s.input(r'\mydimen')
        arg = s.readArgument(type='Dimen')
        assert arg == dimen('12sp'), arg

        # Set by count
        s.input(r'\mycount')
        arg = s.readArgument(type='Dimen')
        assert arg == dimen('120sp'), arg

        assert ParameterCommand._enablelevel == 0
    def testTeXDimen(self):
        s = TeX()
        s.input(r'''\newcount\mycount\mycount=120
                    \newdimen\mydimen\mydimen=12sp
                    \newskip\myglue\myglue=10sp plus1pt minus2pt''')
        s.parse()

        value = s.ownerDocument.context['mycount'].value
        assert value == count(120), value
        value = s.ownerDocument.context['mydimen'].value
        assert value == dimen('12sp'), value
        value = s.ownerDocument.context['myglue'].value
        assert value == glue('10sp', plus='1pt', minus='2pt'), value

        # Literal dimension
        s.input(r'3.5pt')
        arg = s.readArgument(type='Dimen')
        assert arg == dimen('3.5pt'), arg

        # Literal dimension, {...} aren't allowed
        s.input(r'{3.5pt}')
        arg = s.readArgument(type='Dimen')
        assert arg == dimen(0), arg

        # Set by other dimension
        s.input(r'\mydimen')
        arg = s.readArgument(type='Dimen')
        assert arg == dimen('12sp'), arg

        # Set by count
        s.input(r'\mycount')
        arg = s.readArgument(type='Dimen')
        assert arg == dimen('120sp'), arg

        assert ParameterCommand._enablelevel == 0
Exemple #7
0
    def newcount(self, name, initial=0):
        """
        Create a new count (like \\newcount)

        Required Arguments:
        name -- name of count to create

        Keyword Arguments:
        initial -- value to initialize to

        """
        # Generate a new count class
        macrolog.debug('creating count %s', name)
        newclass = type(name, (plasTeX.CountCommand,),
                               {'value': plasTeX.count(initial)})
        self.addGlobal(name, newclass)
Exemple #8
0
    def newcount(self, name, initial=0):
        """ 
        Create a new count (like \\newcount)

        Required Arguments:
        name -- name of count to create
      
        Keyword Arguments:
        initial -- value to initialize to

        """
        name = str(name)
        # Generate a new count class
        macrolog.debug('creating count %s', name)
        newclass = new.classobj(name, (plasTeX.CountCommand,), 
                               {'value': plasTeX.count(initial)})
        self.addGlobal(name, newclass)
Exemple #9
0
class LTchunksize(CountCommand):
    value = count(20)
Exemple #10
0
class LTchunksize(CountCommand): value = count(20)

class setlongtables(Command): pass