當前位置: 首頁>>代碼示例>>Python>>正文


Python OMetaBase.rule_exactly方法代碼示例

本文整理匯總了Python中ometa.runtime.OMetaBase.rule_exactly方法的典型用法代碼示例。如果您正苦於以下問題:Python OMetaBase.rule_exactly方法的具體用法?Python OMetaBase.rule_exactly怎麽用?Python OMetaBase.rule_exactly使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在ometa.runtime.OMetaBase的用法示例。


在下文中一共展示了OMetaBase.rule_exactly方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: test_exactlyFail

# 需要導入模塊: from ometa.runtime import OMetaBase [as 別名]
# 或者: from ometa.runtime.OMetaBase import rule_exactly [as 別名]
    def test_exactlyFail(self):
        """
        L{OMetaBase.rule_exactly} raises L{ParseError} when the requested item
        doesn't match the input. The error contains info on what was expected
        and the position.
        """

        data = "foo"
        o = OMetaBase(data)
        with self.assertRaises(ParseError) as e:
            o.rule_exactly("g")
        self.assertEquals(e.exception[1], expected(None, "g"))
        self.assertEquals(e.exception[0], 0)
開發者ID:jballard1991,項目名稱:software,代碼行數:15,代碼來源:test_runtime.py

示例2: test_many

# 需要導入模塊: from ometa.runtime import OMetaBase [as 別名]
# 或者: from ometa.runtime.OMetaBase import rule_exactly [as 別名]
    def test_many(self):
        """
        L{OMetaBase.many} returns a list of parsed values and the error that
        caused the end of the loop.
        """

        data = "ooops"
        o = OMetaBase(data)
        self.assertEqual(o.many(lambda: o.rule_exactly("o")), (["o"] * 3, ParseError(o.input, 3, expected(None, "o"))))
開發者ID:jballard1991,項目名稱:software,代碼行數:11,代碼來源:test_runtime.py

示例3: test_exactly_multi

# 需要導入模塊: from ometa.runtime import OMetaBase [as 別名]
# 或者: from ometa.runtime.OMetaBase import rule_exactly [as 別名]
    def test_exactly_multi(self):
        """
        L{OMetaBase.rule_exactly} returns the requested item from the input
        string along with its position, if it's there.
        """

        data = "foo"
        o = OMetaBase(data)
        v, e = o.rule_exactly("fo")
        self.assertEqual(v, "fo")
        self.assertEqual(e[0], 0)
開發者ID:jballard1991,項目名稱:software,代碼行數:13,代碼來源:test_runtime.py

示例4: test_label

# 需要導入模塊: from ometa.runtime import OMetaBase [as 別名]
# 或者: from ometa.runtime.OMetaBase import rule_exactly [as 別名]
    def test_label(self):
        """
        L{OMetaBase.label} returns a list of parsed values and the error that
        caused the end of the loop.
        """

        data = "ooops"
        label = 'CustomLabel'
        o = OMetaBase(data)
        exc = self.assertRaises(
            ParseError, o.label, lambda: o.rule_exactly('x'), label)
        self.assertEqual(exc,
                         ParseError(o.input, 0, expected(label)).withMessage([("Custom Exception:", label, None)]))
開發者ID:abenassi,項目名稱:parsley,代碼行數:15,代碼來源:test_runtime.py


注:本文中的ometa.runtime.OMetaBase.rule_exactly方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。