def testModuleNaming(self):
    p = template_objects.Module('hello/world',
                                language_model=self.language_model)
    foo = template_objects.CodeObject({'className': 'Foo'}, None,
                                      language_model=self.language_model)
    foo._module = p
    bar = template_objects.CodeObject({'className': 'Bar'}, None, parent=foo)
    baz = template_objects.CodeObject({'className': 'Baz'}, None, parent=bar)

    self.assertEquals('Foo|Bar|Baz', baz.packageRelativeClassName)
    self.assertEquals('hello|world|Foo|Bar|Baz', baz.fullClassName)
 def testParentPath(self):
     foo = template_objects.CodeObject({'className': 'Foo'},
                                       None,
                                       language_model=self.language_model)
     bar = template_objects.CodeObject({'className': 'Bar'},
                                       None,
                                       parent=foo)
     baz = template_objects.CodeObject({'className': 'Baz'},
                                       None,
                                       parent=bar)
     self.assertEquals(['Foo', 'Bar'], baz.parentPath)
  def testFullyQualifiedClassName(self):
    foo = template_objects.CodeObject({'className': 'Foo'}, None,
                                      language_model=self.language_model)
    foo._module = template_objects.Module('test',
                                          language_model=self.language_model)
    bar = template_objects.CodeObject({'className': 'Bar'}, None, parent=foo)
    baz = template_objects.CodeObject({'className': 'Baz'}, None, parent=bar)

    self.assertEquals('test|Foo|Bar|Baz', baz.fullClassName)
    self.assertEquals('', baz.RelativeClassName(baz))
    self.assertEquals('Baz', baz.RelativeClassName(bar))
    self.assertEquals('Bar|Baz', baz.RelativeClassName(foo))
示例#4
0
    def testVoidDataTypeOverride(self):
        class FakeLM(language_model.LanguageModel):
            def CodeTypeForVoid(self):
                return 'the absence of all'

        api = template_objects.CodeObject({}, None)
        void = data_types.Void(api)
        api.SetLanguageModel(FakeLM())
        self.assertEquals('the absence of all', void.code_type)
示例#5
0
 def testVoidDataTypeDefault(self):
     api = template_objects.CodeObject({}, None)
     void = data_types.Void(api)
     api.SetLanguageModel(language_model.LanguageModel())
     self.assertEquals('void', void.code_type)