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())
def testNext(self): c = CharObject(u'c') result = c.call(u"next", []) self.assertEqual(result._c, u'd')
def testCategorySymbol(self): c = CharObject(u'¢') result = c.call(u"getCategory", []) self.assertEqual(result._s, u"Sc")
def testAdd(self): c = CharObject(u'c') result = c.call(u"add", [IntObject(2)]) self.assertEqual(result._c, u'e')
def testHashInequalItems(self): a = ConstList([IntObject(42), CharObject(u'é')]) b = ConstList([IntObject(42), CharObject(u'e')]) self.assertNotEqual(a.hash(), b.hash())
def testHashInequal(self): a = CharObject(u'a') b = CharObject(u'b') self.assertNotEqual(a.hash(), b.hash())
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))
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)
def visitCharExpr(self, c, span): return self.dest.LiveExpr(CharObject(c), span)
def testHashEqual(self): a = wrapList([IntObject(42), CharObject(u'é')]) b = wrapList([IntObject(42), CharObject(u'é')]) self.assertEqual(a.samenessHash(), b.samenessHash())
def uncall(self): return wrapList([CharObject(self._c)])
def testHashEqual(self): a = CharObject(u'a') b = CharObject(u'a') self.assertEqual(a.samenessHash(), b.samenessHash())
def testMax(self): c = CharObject(u'c') d = CharObject(u'd') result = c.call(u"max", [d]) self.assertEqual(result.getChar(), d.getChar())
def wrap(self, value): return CharObject(value)
def testQuoteSlashes(self): c = CharObject(u'\\') result = c.call(u"quote", []) self.assertEqual(result._s, u"'\\\\'")
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])
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))
def testHashEqual(self): a = ConstList([IntObject(42), CharObject(u'é')]) b = ConstList([IntObject(42), CharObject(u'é')]) self.assertEqual(a.hash(), b.hash())
def testCategoryUnicode(self): c = CharObject(u'č') result = c.call(u"getCategory", []) self.assertEqual(result._s, u"Ll")
def testPopManyHeterogenous(self): l = FlexList([CharObject(u'm'), IntObject(5)]) result = l.call(u"pop", []) self.assertEqual(result.getInt(), 5)
def testMax(self): c = CharObject(u'c') d = CharObject(u'd') result = c.call(u"max", [d]) self.assertTrue(result is d)
def testNextUnicode(self): c = CharObject(u'¡') result = c.call(u"next", []) self.assertEqual(result._c, u'¢')
def default_value(self): return CharObject(u'▲')