class DataDeclarationTest(unittest.TestCase): def setUp(self): self.sut = DataDeclaration("user/wizard/math/matrix.h") def eq_test(self): self.assertTrue(self.sut == self.sut) def eq_false_test(self): self.assertFalse(self.sut == 1) def exact_match_test(self): block_cell_name = BlockCellName("user/wizard/math/matrix.h") blocks = [block_cell_name] self.assertEquals(self.sut.match(blocks), set([block_cell_name])) def partial_match_test(self): block_cell_name = BlockCellName("user/wizard/math/matrix.h") blocks = [block_cell_name] self.assertEquals(self.sut.match(blocks, block_cell_name), set([block_cell_name])) def negative_match_test(self): sut = DataDeclaration("user/wizard/math/scene.h") block_cell_name = BlockCellName("user/wizard/math/matrix.h") blocks = [block_cell_name] self.assertEquals(sut.match(blocks, block_cell_name), set([])) def block_test(self): self.assertEquals(self.sut.block(), BlockName("user/wizard")) def normalize_test_raises_exception(self): self.assertRaises(BiiException, self.sut.normalize, ["a", "b"]) def normalize_test_return_same_data_declaration(self): self.assertEquals(self.sut.normalize([BlockCellName('user\\wizard\\math\\matrix.h')]), self.sut)
def test_replace_includes(self): text = r'''# include "file.h" //My comment # include "file2.h" # include "path/to/file.h" //My comment # include "file3.h" //bii://biicode.txt ''' parser = DRLCPPParser() parser.parse(text) d1 = CPPDeclaration('file.h') d2 = CPPDeclaration('user/block/file.h') text = parser.updateDeclaration(text, d1, d2) d1 = CPPDeclaration('file3.h') d2 = CPPDeclaration('user/block2/file3.h') text = parser.updateDeclaration(text, d1, d2) d1 = CPPDeclaration('file2.h') d2 = CPPDeclaration('user/block2/file2.h') text = parser.updateDeclaration(text, d1, d2) d1 = DataDeclaration('biicode.txt') d2 = DataDeclaration('user/block/biicode.txt') text = parser.updateDeclaration(text, d1, d2) expected = '''# include "user/block/file.h" //My comment # include "user/block2/file2.h" # include "path/to/file.h" //My comment # include "user/block2/file3.h" //bii://user/block/biicode.txt ''' self.assertEqual(expected, text)
def explicit_declarations(self): result = set() result |= (set([FortranDeclaration("%s%s.f90" % (x.scope, x.name)) for x in self.modules])) includes = set([FortranDeclaration(x.name) for x in self.includes]) for inc in includes: inc.properties.add(DependenciesProperties.EXCLUDE_FROM_BUILD) result |= includes result |= (set([DataDeclaration(x.name) for x in self.references])) return result
class DataDeclarationTest(unittest.TestCase): def setUp(self): self.sut = DataDeclaration("user/wizard/math/matrix.h") def eq_test(self): self.assertTrue(self.sut == self.sut) def eq_false_test(self): self.assertFalse(self.sut == 1) def exact_match_test(self): block_cell_name = BlockCellName("user/wizard/math/matrix.h") blocks = [block_cell_name] self.assertEquals(self.sut.match(blocks), set([block_cell_name])) def partial_match_test(self): block_cell_name = BlockCellName("user/wizard/math/matrix.h") blocks = [block_cell_name] self.assertEquals(self.sut.match(blocks, block_cell_name), set([block_cell_name])) def negative_match_test(self): sut = DataDeclaration("user/wizard/math/scene.h") block_cell_name = BlockCellName("user/wizard/math/matrix.h") blocks = [block_cell_name] self.assertEquals(sut.match(blocks, block_cell_name), set([])) def block_test(self): self.assertEquals(self.sut.block(), BlockName("user/wizard")) def normalize_test_raises_exception(self): self.assertRaises(BiiException, self.sut.normalize, ["a", "b"]) def normalize_test_return_same_data_declaration(self): self.assertEquals( self.sut.normalize([BlockCellName('user\\wizard\\math\\matrix.h') ]), self.sut)
def _define_datas(self): # Use information contained in biicode tags: datas = self.block_holder.data if not datas: return block_name = self.block_holder.block_name cell_names = self.block_holder.cell_names for data in datas: dependents = dependents = { c for c in cell_names if fnmatch(c, data.pattern) } if not dependents: self._biiout.warn('In %s, definition %s\n\t' 'There are no files matching pattern %s' % (block_name, data, data.pattern)) continue for dependent in dependents: cell = self.block_holder[dependent].cell for dep in data.dependencies: cell.dependencies.unresolved.add(DataDeclaration(dep.name))
def setUp(self): self.sut = DataDeclaration("user/wizard/math/matrix.h")
def negative_match_test(self): sut = DataDeclaration("user/wizard/math/scene.h") block_cell_name = BlockCellName("user/wizard/math/matrix.h") blocks = [block_cell_name] self.assertEquals(sut.match(blocks, block_cell_name), set([]))
def explicit_declarations(self): result = set() result |= (set([NodeDeclaration(x.name) for x in self.requires])) result |= (set([DataDeclaration(x.name) for x in self.references])) return result
def explicit_declarations(self): result = set() result |= (set([PythonDeclaration(x.name) for x in self.imports])) result |= (set([CPPDeclaration(x) for x in self.c_includes])) result |= (set([DataDeclaration(x.name) for x in self.references])) return result