当前位置: 首页>>代码示例>>Python>>正文


Python equality.optSame函数代码示例

本文整理汇总了Python中typhon.objects.equality.optSame函数的典型用法代码示例。如果您正苦于以下问题:Python optSame函数的具体用法?Python optSame怎么用?Python optSame使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了optSame函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: testRefEqualitySettled

 def testRefEqualitySettled(self):
     with scopedVat(testingVat()):
         first, r = makePromise()
         r.resolve(IntObject(42))
         second, r = makePromise()
         r.resolve(IntObject(42))
         self.assertEqual(optSame(first, second), EQUAL)
开发者ID:dckc,项目名称:typhon,代码行数:7,代码来源:test_equality.py

示例2: testListEqualityRecursion

 def testListEqualityRecursion(self):
     # Yes, this is very hacky.
     first = ConstList([IntObject(42)])
     first.strategy.append(first, [first])
     second = ConstList([IntObject(42)])
     second.strategy.append(second, [second])
     self.assertEqual(optSame(first, second), EQUAL)
开发者ID:markrwilliams,项目名称:typhon,代码行数:7,代码来源:test_equality.py

示例3: eq

 def eq(self, other):
     if not isinstance(other, Proxy):
         return False
     if self.checkSlot() or other.checkSlot():
         raise userError(u"equals comparison of resolved proxy is"
                         u" impossible")
     return optSame(self.handler, other.handler) is EQUAL
开发者ID:monte-language,项目名称:typhon,代码行数:7,代码来源:proxy.py

示例4: testListEqualityRecursion

 def testListEqualityRecursion(self):
     first = wrapList([IntObject(42), NullObject])
     # Hax.
     first.objs.append(first)
     second = wrapList([IntObject(42), NullObject])
     # Hax.
     second.objs.append(second)
     self.assertEqual(optSame(first, second), EQUAL)
开发者ID:dckc,项目名称:typhon,代码行数:8,代码来源:test_equality.py

示例5: startOf

 def startOf(self, needleList, start=0):
     # This is quadratic. It could be better.
     from typhon.objects.equality import EQUAL, optSame
     for index in range(start, self.strategy.size(self)):
         for needleIndex, needle in enumerate(needleList):
             offset = index + needleIndex
             if optSame(self.strategy.fetch(self, offset), needle) is not EQUAL:
                 break
             return index
     return -1
开发者ID:markrwilliams,项目名称:typhon,代码行数:10,代码来源:lists.py

示例6: recv

    def recv(self, atom, args):
        from typhon.nodes import Noun, Method, Obj
        from typhon.objects.equality import optSame, EQUAL
        from typhon.objects.user import Audition

        if atom is _UNCALL_0:
            from typhon.objects.collections.maps import EMPTY_MAP

            return ConstList([subrangeGuardMaker, StrObject(u"get"), ConstList([self.superGuard]), EMPTY_MAP])

        if atom is AUDIT_1:
            audition = args[0]
            if not isinstance(audition, Audition):
                raise userError(u"not invoked with an Audition")
            ast = audition.ast
            if not isinstance(ast, Obj):
                raise userError(u"audition not created with an object expr")
            methods = ast._script._methods
            for m in methods:
                if isinstance(m, Method) and m._verb == u"coerce":
                    mguard = m._g
                    if isinstance(mguard, Noun):
                        rGSG = audition.getGuard(mguard.name)
                        if isinstance(rGSG, FinalSlotGuard):
                            rGSG0 = rGSG.valueGuard
                            if isinstance(rGSG0, SameGuard):
                                resultGuard = rGSG0.value

                                if optSame(resultGuard, self.superGuard) is EQUAL or (
                                    SUPERSETOF_1 in self.superGuard.respondingAtoms()
                                    and self.superGuard.call(u"supersetOf", [resultGuard]) is wrapBool(True)
                                ):
                                    return wrapBool(True)
                                raise userError(
                                    u"%s does not have a result guard implying "
                                    u"%s, but %s" % (audition.fqn, self.superGuard.toQuote(), resultGuard.toQuote())
                                )
                            raise userError(
                                u"%s does not have a determinable "
                                u"result guard, but <& %s> :%s" % (audition.fqn, mguard.name, rGSG.toQuote())
                            )
                    break
            return self
        if atom is PASSES_1:
            return wrapBool(args[0].auditedBy(self))
        if atom is COERCE_2:
            specimen, ej = args[0], args[1]
            if specimen.auditedBy(self):
                return specimen
            c = specimen.call(u"_conformTo", [self])
            if c.auditedBy(self):
                return c
            throw(ej, StrObject(u"%s does not conform to %s" % (specimen.toQuote(), self.toQuote())))

        raise Refused(self, atom, args)
开发者ID:markrwilliams,项目名称:typhon,代码行数:55,代码来源:guards.py

示例7: _startOf

 def _startOf(self, needleCL, start):
     if start < 0:
         raise userError(u"startOf/2: Negative start %d not permitted" %
                 start)
     # This is quadratic. It could be better.
     from typhon.objects.equality import EQUAL, optSame
     for index in range(start, len(self.objs)):
         for needleIndex, needle in enumerate(needleCL):
             offset = index + needleIndex
             if optSame(self.objs[offset], needle) is not EQUAL:
                 break
             return index
     return -1
开发者ID:dckc,项目名称:typhon,代码行数:13,代码来源:lists.py

示例8: auditedBy

    def auditedBy(self, prospect):
        """
        Whether a prospective stamp has been left on this object.
        """

        # The number of different objects that will pass through here is
        # surprisingly low; consider how Python would look if metaclasses were
        # promoted.
        prospect = promote(prospect)

        from typhon.objects.equality import optSame, EQUAL

        # Already audited with an identical stamp?
        for stamp in self.auditorStamps():
            if optSame(prospect, stamp) is EQUAL:
                return True

        # Sorry, but nope.
        return False
开发者ID:washort,项目名称:typhon,代码行数:19,代码来源:root.py

示例9: audit

    def audit(self, audition):
        from typhon.nodes import Noun, Method, Obj
        from typhon.objects.equality import optSame, EQUAL
        from typhon.objects.user import Audition
        if not isinstance(audition, Audition):
            raise userError(u"not invoked with an Audition")
        ast = audition.ast
        if not isinstance(ast, Obj):
            raise userError(u"audition not created with an object expr")
        methods = ast._script._methods
        for m in methods:
            if isinstance(m, Method) and m._verb == u"coerce":
                mguard = m._g
                if isinstance(mguard, Noun):
                    rGSG = audition.getGuard(mguard.name)
                    if isinstance(rGSG, FinalSlotGuard):
                        rGSG0 = rGSG.valueGuard
                        if isinstance(rGSG0, SameGuard):
                            resultGuard = rGSG0.value

                            if (optSame(resultGuard, self.superGuard)
                                is EQUAL or
                                (self.superGuard.call(u"supersetOf",
                                    [resultGuard])
                                 is wrapBool(True))):
                                return True
                            raise userError(
                                u"%s does not have a result guard implying "
                                u"%s, but %s" % (audition.fqn,
                                                 self.superGuard.toQuote(),
                                                 resultGuard.toQuote()))
                        raise userError(u"%s does not have a determinable "
                                        u"result guard, but <& %s> :%s" % (
                                            audition.fqn, mguard.name,
                                            rGSG.toQuote()))
                break
        return False
开发者ID:monte-language,项目名称:typhon,代码行数:37,代码来源:guards.py

示例10: indexOf

 def indexOf(self, needle):
     from typhon.objects.equality import EQUAL, optSame
     for index, specimen in enumerate(self.objs):
         if optSame(needle, specimen) is EQUAL:
             return index
     return -1
开发者ID:dckc,项目名称:typhon,代码行数:6,代码来源:lists.py

示例11: testListEqualityRecursionReflexive

 def testListEqualityRecursionReflexive(self):
     first = ConstList([IntObject(42)])
     first.strategy.append(first, [first])
     self.assertEqual(optSame(first, first), EQUAL)
开发者ID:markrwilliams,项目名称:typhon,代码行数:4,代码来源:test_equality.py

示例12: contains

 def contains(self, needle):
     from typhon.objects.equality import EQUAL, optSame
     for specimen in self.objs:
         if optSame(needle, specimen) is EQUAL:
             return True
     return False
开发者ID:dckc,项目名称:typhon,代码行数:6,代码来源:lists.py

示例13: testListEquality

 def testListEquality(self):
     first = wrapList([IntObject(42)])
     second = wrapList([IntObject(42)])
     self.assertEqual(optSame(first, second), EQUAL)
开发者ID:dckc,项目名称:typhon,代码行数:4,代码来源:test_equality.py

示例14: testListEqualityRecursionReflexive

 def testListEqualityRecursionReflexive(self):
     first = wrapList([IntObject(42), NullObject])
     # Hax.
     first.objs.append(first)
     self.assertEqual(optSame(first, first), EQUAL)
开发者ID:dckc,项目名称:typhon,代码行数:5,代码来源:test_equality.py

示例15: testStrInequality

 def testStrInequality(self):
     first = StrObject(u"false")
     second = StrObject(u"true")
     self.assertEqual(optSame(first, second), INEQUAL)
开发者ID:dckc,项目名称:typhon,代码行数:4,代码来源:test_equality.py


注:本文中的typhon.objects.equality.optSame函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。