Exemple #1
0
 def testHashEqual(self):
     d = monteSet()
     d[IntObject(42)] = None
     d[CharObject(u'¡')] = None
     a = ConstSet(d)
     b = ConstSet(d)
     self.assertEqual(a.hash(), b.hash())
Exemple #2
0
 def testNext(self):
     c = CharObject(u'c')
     result = c.call(u"next", [])
     self.assertEqual(result._c, u'd')
Exemple #3
0
 def testCategorySymbol(self):
     c = CharObject(u'¢')
     result = c.call(u"getCategory", [])
     self.assertEqual(result._s, u"Sc")
Exemple #4
0
 def testAdd(self):
     c = CharObject(u'c')
     result = c.call(u"add", [IntObject(2)])
     self.assertEqual(result._c, u'e')
Exemple #5
0
 def testHashInequalItems(self):
     a = ConstList([IntObject(42), CharObject(u'é')])
     b = ConstList([IntObject(42), CharObject(u'e')])
     self.assertNotEqual(a.hash(), b.hash())
Exemple #6
0
 def testHashInequal(self):
     a = CharObject(u'a')
     b = CharObject(u'b')
     self.assertNotEqual(a.hash(), b.hash())
Exemple #7
0
 def testContains(self):
     l = FlexList([IntObject(5), CharObject(u'a')])
     self.assertTrue(l.contains(IntObject(5)))
     self.assertFalse(l.contains(IntObject(42)))
     self.assertFalse(l.contains(l))
Exemple #8
0
 def testHashInequalItems(self):
     a = wrapList([IntObject(42), CharObject(u'é')])
     b = wrapList([IntObject(42), CharObject(u'e')])
     self.assertNotEqual(a.samenessHash(), b.samenessHash())
 def testCharEquality(self):
     first = CharObject(u'c')
     second = CharObject(u'c')
     self.assertEqual(optSame(first, second), EQUAL)
Exemple #10
0
 def visitCharExpr(self, c, span):
     return self.dest.LiveExpr(CharObject(c), span)
Exemple #11
0
 def testHashEqual(self):
     a = wrapList([IntObject(42), CharObject(u'é')])
     b = wrapList([IntObject(42), CharObject(u'é')])
     self.assertEqual(a.samenessHash(), b.samenessHash())
Exemple #12
0
 def uncall(self):
     return wrapList([CharObject(self._c)])
Exemple #13
0
 def testHashEqual(self):
     a = CharObject(u'a')
     b = CharObject(u'a')
     self.assertEqual(a.samenessHash(), b.samenessHash())
Exemple #14
0
 def testMax(self):
     c = CharObject(u'c')
     d = CharObject(u'd')
     result = c.call(u"max", [d])
     self.assertEqual(result.getChar(), d.getChar())
Exemple #15
0
 def testHashInequal(self):
     a = CharObject(u'a')
     b = CharObject(u'b')
     self.assertNotEqual(a.hash(), b.hash())
Exemple #16
0
 def testMax(self):
     c = CharObject(u'c')
     d = CharObject(u'd')
     result = c.call(u"max", [d])
     self.assertEqual(result.getChar(), d.getChar())
Exemple #17
0
 def wrap(self, value):
     return CharObject(value)
Exemple #18
0
 def testHashEqual(self):
     a = CharObject(u'a')
     b = CharObject(u'a')
     self.assertEqual(a.samenessHash(), b.samenessHash())
Exemple #19
0
 def testQuoteSlashes(self):
     c = CharObject(u'\\')
     result = c.call(u"quote", [])
     self.assertEqual(result._s, u"'\\\\'")
Exemple #20
0
        def default_value(self):
            return exemplar

    return UnboxedListStrategy


def unboxUnconnectedRef(value):
    assert isinstance(value, UnconnectedRef), "Implementation detail"
    return value._problem


unboxedStrategies = [
    makeUnboxedListStrategy(cls, box, unbox, exemplar)
    for (cls, box, unbox, exemplar) in [
        # Chars.
        (CharObject, CharObject, unwrapChar, CharObject(u'▲')),
        # Small ints.
        (IntObject, IntObject, unwrapInt, IntObject(42)),
        # Unicode strings.
        (StrObject, StrObject, unwrapStr, StrObject(u"▲")),
        # Bytestrings.
        (BytesObject, BytesObject, unwrapBytes, BytesObject("M")),
        # _booleanFlow-generated lists of unconnected refs.
        (UnconnectedRef, UnconnectedRef, unboxUnconnectedRef,
         UnconnectedRef(StrObject(u"Implementation detail leaked"))),
    ]
]


@rstrategies.strategy(generalize=[NullListStrategy] + unboxedStrategies +
                      [GenericListStrategy])
Exemple #21
0
 def testPutSize(self):
     l = FlexList([IntObject(5), CharObject(u'a')])
     l.put(1, IntObject(7))
     expected = [IntObject(5), IntObject(7)]
     self.assertEqual(l.strategy.size(l), len(expected))
Exemple #22
0
 def testAdd(self):
     c = CharObject(u'c')
     result = c.call(u"add", [IntObject(2)])
     self.assertEqual(result._c, u'e')
Exemple #23
0
 def testHashEqual(self):
     a = ConstList([IntObject(42), CharObject(u'é')])
     b = ConstList([IntObject(42), CharObject(u'é')])
     self.assertEqual(a.hash(), b.hash())
Exemple #24
0
 def testCategoryUnicode(self):
     c = CharObject(u'č')
     result = c.call(u"getCategory", [])
     self.assertEqual(result._s, u"Ll")
Exemple #25
0
 def testPopManyHeterogenous(self):
     l = FlexList([CharObject(u'm'), IntObject(5)])
     result = l.call(u"pop", [])
     self.assertEqual(result.getInt(), 5)
Exemple #26
0
 def testCategorySymbol(self):
     c = CharObject(u'¢')
     result = c.call(u"getCategory", [])
     self.assertEqual(result._s, u"Sc")
Exemple #27
0
 def testCategoryUnicode(self):
     c = CharObject(u'č')
     result = c.call(u"getCategory", [])
     self.assertEqual(result._s, u"Ll")
Exemple #28
0
 def testMax(self):
     c = CharObject(u'c')
     d = CharObject(u'd')
     result = c.call(u"max", [d])
     self.assertTrue(result is d)
Exemple #29
0
 def testMax(self):
     c = CharObject(u'c')
     d = CharObject(u'd')
     result = c.call(u"max", [d])
     self.assertTrue(result is d)
Exemple #30
0
 def testNext(self):
     c = CharObject(u'c')
     result = c.call(u"next", [])
     self.assertEqual(result._c, u'd')
Exemple #31
0
 def testNextUnicode(self):
     c = CharObject(u'¡')
     result = c.call(u"next", [])
     self.assertEqual(result._c, u'¢')
Exemple #32
0
 def testNextUnicode(self):
     c = CharObject(u'¡')
     result = c.call(u"next", [])
     self.assertEqual(result._c, u'¢')
Exemple #33
0
 def testQuoteSlashes(self):
     c = CharObject(u'\\')
     result = c.call(u"quote", [])
     self.assertEqual(result._s, u"'\\\\'")
Exemple #34
0
 def default_value(self):
     return CharObject(u'▲')