示例#1
0
    def setUp(self):
        self.fruit_list = DragonflyList("fruit")
        self.fruit_list.append("apple")
        self.fruit_list_ref = ListRef("fruit_ref", self.fruit_list)

        self.dict_list = DragonflyDictList("fruit_dict")
        self.dict_list["apple"] = "yep"
        self.dict_list["mango"] = "nope"
        self.dict_list_ref = DictListRef("fruit_dict_ref", self.dict_list)
示例#2
0
    def test_update_list(self):
        """
        Test support for dragonfly lists.
        """
        # Set up a new list and add an item
        fruit_list = DragonflyList("fruit")
        fruit_list.append("apple")
        fruit_list_ref = ListRef("fruit_ref", fruit_list)

        # Load a new grammar with a rule referencing the fruit list
        grammar = Grammar("test")
        r = Rule("fav_fruit", fruit_list_ref, exported=True)
        grammar.add_rule(r)
        grammar.load()

        self.assert_mimic_success("apple")

        # Try updating the list
        fruit_list.append("banana")
        self.assertListEqual(["apple", "banana"], r.element.list)

        # If mimic fails, then the list wasn't updated correctly.
        self.assert_mimic_success("banana")