Ejemplo n.º 1
0
    def setUp(self):
        self._incSim = IncludeHandler.CppIncludeStringIO(
            [
                os.path.join('usr'),
            ], [
                os.path.join('sys'),
            ], u"""Contents of src/spam.c
""", {
                os.path.join('usr', 'spam.hp'): u"""User, spam.hp
""",
                os.path.join('sys', 'spam.h'): u"""System, spam.h
""",
                os.path.join('src', 'spam.h'): u"""Current place, spam.h
""",
            })
        self._incSim.validateCpStack()
        self.assertEqual([], self._incSim.cpStack)
        self.assertEqual(0, self._incSim.cpStackSize)
        # Load the initial translation unit
        f = self._incSim.initialTu('src/spam.c')
        self._incSim.validateCpStack()
        self.assertEqual([
            'src',
        ], self._incSim.cpStack)
        self.assertEqual(1, self._incSim.cpStackSize)
        self.assertNotEqual(None, f)
        # Test the return value
        self.assertEqual('Contents of src/spam.c\n', f.fileObj.read())
        self.assertEqual('src/spam.c', f.filePath)
        self.assertEqual('src', f.currentPlace)
        self.assertEqual('TU', f.origin)
Ejemplo n.º 2
0
 def setUp(self):
     self._incSim = IncludeHandler.CppIncludeStringIO(
         self._pathsUsr,
         self._pathsSys,
         self._initialTuContents,
         self._incFileMap,
     )
     self._incSim.validateCpStack()
     self.assertEqual([], self._incSim.cpStack)
     self.assertEqual(0, self._incSim.cpStackSize)
Ejemplo n.º 3
0
    def setUp(self):
        self._incSim = IncludeHandler.CppIncludeStringIO(
            theUsrDirs=[
                os.path.join('usr'),
                os.path.join('usr', 'inc'),
            ],
            theSysDirs=[
                os.path.join('sys'),
                os.path.join('sys', 'inc'),
            ],
            theInitialTuContent=u"""Contents of src/spam.c
""",
            theFilePathToContent={
                # spam.h
                os.path.join('usr', 'inc', 'spam.h'): u"""User, include, spam.h
""",
                os.path.join('usr', 'spam.h'): u"""User, spam.h
""",
                os.path.join('sys', 'spam.h'): u"""System, spam.h
""",
                os.path.join('sys', 'inc', 'spam.h'):
                u"""System, include, spam.h
""",
                # no_next.h
                os.path.join('usr', 'no_next.h'): u"""User, no_next.h
""",
                os.path.join('sys', 'no_next.h'): u"""System, no_next.h
""",
            })
        self._incSim.validateCpStack()
        self.assertEqual([], self._incSim.cpStack)
        self.assertEqual(0, self._incSim.cpStackSize)
        # Load the initial translation unit
        f = self._incSim.initialTu(u'src/spam.c')
        self._incSim.validateCpStack()
        self.assertEqual([
            'src',
        ], self._incSim.cpStack)
        self.assertEqual(1, self._incSim.cpStackSize)
        self.assertNotEqual(None, f)
        # Test the return value
        self.assertEqual('Contents of src/spam.c\n', f.fileObj.read())
        self.assertEqual('src/spam.c', f.filePath)
        self.assertEqual('src', f.currentPlace)
        self.assertEqual('TU', f.origin)
Ejemplo n.º 4
0
    def setUp(self):
        self._incSim = IncludeHandler.CppIncludeStringIO(
            [
                os.path.join('usr'),
            ], [
                os.path.join('sys'),
            ], u"""Contents of src/spam.c
""", {
                os.path.join('usr', 'spam.hp'): """User, spam.hp
""",
                os.path.join('sys', 'spam.h'): """System, spam.h
""",
            })
        self.assertEqual(False, self._incSim.canInclude())
        self.assertRaises(IncludeHandler.ExceptionCppInclude,
                          self._incSim.endInclude)
        try:
            self._incSim.currentPlace
            self.fail(
                'IncludeHandler.ExceptionCppInclude not raised for currentPlace'
            )
        except IncludeHandler.ExceptionCppInclude:
            pass
        self._incSim.validateCpStack()
        self.assertEqual([], self._incSim.cpStack)
        self.assertEqual(0, self._incSim.cpStackSize)
        # Load the initial translation unit
        f = self._incSim.initialTu('src/spam.c')
        self._incSim.validateCpStack()
        self.assertEqual([
            'src',
        ], self._incSim.cpStack)
        self.assertEqual(1, self._incSim.cpStackSize)
        self.assertNotEqual(None, f)
        # Test the return value
        self.assertEqual('Contents of src/spam.c\n', f.fileObj.read())
        self.assertEqual('src/spam.c', f.filePath)
        self.assertEqual('src', f.currentPlace)
        self.assertEqual('TU', f.origin)
        self.assertRaises(IncludeHandler.ExceptionCppInclude,
                          self._incSim.finalise)