コード例 #1
0
    def testClone(self):
        srcModule = WppCore.createMemModule('', 'number.mem')
        self.assertEqual(srcModule.type, 'module')
        self.assertEqual(srcModule.getName(), 'number')

        dstCore = TSCore.createInstance()
        dstModule = srcModule.cloneAll(dstCore)
        self.assertEqual(dstModule.type, 'module')
        self.assertEqual(dstModule.getName(), 'number_')
        self.assertTrue(dstModule.isModule())
コード例 #2
0
import unittest
from TS.TSExpression import TSConst
from Wpp.WppExpression import WppConst
from TS.TSCore import TSCore

singleStyle = {'singleQuote': True}
doubleStyle = {'singleQuote': False}
tsCore = TSCore.createInstance()


def fromWpp(stringValue):
    wpp = WppConst.create(stringValue)
    return wpp.clone(tsCore)


class TestTSConst(unittest.TestCase):
    def testString(self):
        self.assertEqual(TSConst.makeString('Hello', singleStyle), "'Hello'")
        self.assertEqual(TSConst.makeString('Hello', doubleStyle), '"Hello"')

        self.assertEqual(TSConst.makeString('\t"Hello"\r\n', singleStyle),
                         """'\\t"Hello"\\r\\n'""")
        self.assertEqual(TSConst.makeString('\t"Hello"\r\n', doubleStyle),
                         '''"\\t\\"Hello\\"\\r\\n"''')

    def testClone(self):
        wppInt = WppConst.create('123')
        self.assertEqual(wppInt.constType, 'int')
        self.assertEqual(wppInt.value, 123)
        tsInt = wppInt.clone(tsCore)
        self.assertEqual(tsInt.type, 'const')
コード例 #3
0
	def testReservedWords(self):
		core = TSCore.createInstance()
		self.assertEqual(core.getSafeName('myName'), 'myName')
		self.assertEqual(core.getSafeName('class'), 'class_')
		self.assertEqual(core.getSafeName('from'), 'from_')