Ejemplo n.º 1
0
    def test_default_property(self):
        prop = QmlProperty()
        prop.doc = "/// Children"
        prop.type = "list<Item>"
        prop.is_default = True

        self.assertEqual(str(prop),
                         "/// Children\n" + QmlProperty.DEFAULT_PROPERTY_COMMENT + "\nQ_PROPERTY(list<Item> )")
Ejemplo n.º 2
0
    def test_no_property_type(self):
        prop = QmlProperty()
        prop.doc = "/// The user age"
        prop.type = "int"

        prop.post_process_doc()

        self.assertEqual(prop.type, "int")
        self.assertEqual(prop.doc, "/// The user age")
Ejemplo n.º 3
0
    def test_default_property(self):
        prop = QmlProperty()
        prop.doc = "/// Children"
        prop.type = "list<Item>"
        prop.is_default = True

        self.assertEqual(
            str(prop), "/// Children\n" +
            QmlProperty.DEFAULT_PROPERTY_COMMENT + "\nQ_PROPERTY(list<Item> )")
Ejemplo n.º 4
0
    def test_property_type(self):
        prop = QmlProperty()
        prop.doc = "/// type:User The current user"
        prop.type = "alias"

        prop.post_process_doc()

        self.assertEqual(prop.type, "User")
        self.assertEqual(prop.doc, "/// The current user")
Ejemplo n.º 5
0
def parse_property(reader, property_token_value):
    prop = QmlProperty()
    prop.is_default = property_token_value.startswith("default")
    prop.is_readonly = property_token_value.startswith("readonly")

    token = reader.consume_expecting(lexer.ELEMENT)
    prop.type = token.value

    token = reader.consume_expecting(lexer.ELEMENT)
    prop.name = token.value
    return prop
Ejemplo n.º 6
0
    def test_default_property(self):
        prop = QmlProperty()
        prop.doc = "/// Children"
        prop.type = "list<Item>"
        prop.is_default = True

        prop.post_process_doc()

        self.assertEqual(prop.doc, "/// Children\n" + QmlProperty.DEFAULT_PROPERTY_COMMENT)
Ejemplo n.º 7
0
    def test_no_property_type(self):
        prop = QmlProperty()
        prop.doc = "/// The user age"
        prop.type = "int"

        prop.post_process_doc()

        self.assertEqual(prop.type, "int")
        self.assertEqual(prop.doc, "/// The user age")
Ejemplo n.º 8
0
    def test_property_type(self):
        prop = QmlProperty()
        prop.doc = "/// type:User The current user"
        prop.type = "alias"

        prop.post_process_doc()

        self.assertEqual(prop.type, "User")
        self.assertEqual(prop.doc, "/// The current user")
Ejemplo n.º 9
0
def parse_property(reader, property_token_value):
    prop = QmlProperty()
    prop.is_default = property_token_value.startswith("default")
    prop.is_readonly = property_token_value.startswith("readonly")

    token = reader.consume_expecting(lexer.ELEMENT)
    prop.type = token.value

    token = reader.consume_expecting(lexer.ELEMENT)
    prop.name = token.value
    return prop