Lines Matching refs:int
48 class IntSubclass(int):
71 ntype = int
74 self.assertEqual(int(314), 314)
75 self.assertEqual(int(3.14), 3)
76 self.assertEqual(int(314L), 314)
78 self.assertEqual(int(-3.14), -3)
79 self.assertEqual(int(3.9), 3)
80 self.assertEqual(int(-3.9), -3)
81 self.assertEqual(int(3.5), 3)
82 self.assertEqual(int(-3.5), -3)
84 self.assertEqual(int("10",16), 16L)
86 self.assertEqual(int(unicode("10"),16), 16L)
96 self.assertEqual(int(ss), vv)
101 x = int(s)
103 self.assertIsInstance(x, int)
105 self.assertEqual(int(s[1:]), sys.maxint+1)
108 x = int(1e100)
110 x = int(-1e100)
120 self.assertRaises(ValueError, int, '123\0')
121 self.assertRaises(ValueError, int, '53', 40)
125 self.assertRaises(ValueError, int, '123\0', 10)
126 self.assertRaises(ValueError, int, '123\x00 245', 20)
128 x = int('1' * 600)
132 x = int(unichr(0x661) * 600)
135 self.assertRaises(TypeError, int, 1, 12)
137 self.assertEqual(int('0123', 0), 83)
138 self.assertEqual(int('0x123', 16), 291)
141 self.assertRaises(ValueError, int, "0x", 16)
142 self.assertRaises(ValueError, int, "0x", 0)
144 self.assertRaises(ValueError, int, "0o", 8)
145 self.assertRaises(ValueError, int, "0o", 0)
147 self.assertRaises(ValueError, int, "0b", 2)
148 self.assertRaises(ValueError, int, "0b", 0)
155 self.assertEqual(int('100000000000000000000000000000000', 2), 4294967296L)
156 self.assertEqual(int('102002022201221111211', 3), 4294967296L)
157 self.assertEqual(int('10000000000000000', 4), 4294967296L)
158 self.assertEqual(int('32244002423141', 5), 4294967296L)
159 self.assertEqual(int('1550104015504', 6), 4294967296L)
160 self.assertEqual(int('211301422354', 7), 4294967296L)
161 self.assertEqual(int('40000000000', 8), 4294967296L)
162 self.assertEqual(int('12068657454', 9), 4294967296L)
163 self.assertEqual(int('4294967296', 10), 4294967296L)
164 self.assertEqual(int('1904440554', 11), 4294967296L)
165 self.assertEqual(int('9ba461594', 12), 4294967296L)
166 self.assertEqual(int('535a79889', 13), 4294967296L)
167 self.assertEqual(int('2ca5b7464', 14), 4294967296L)
168 self.assertEqual(int('1a20dcd81', 15), 4294967296L)
169 self.assertEqual(int('100000000', 16), 4294967296L)
170 self.assertEqual(int('a7ffda91', 17), 4294967296L)
171 self.assertEqual(int('704he7g4', 18), 4294967296L)
172 self.assertEqual(int('4f5aff66', 19), 4294967296L)
173 self.assertEqual(int('3723ai4g', 20), 4294967296L)
174 self.assertEqual(int('281d55i4', 21), 4294967296L)
175 self.assertEqual(int('1fj8b184', 22), 4294967296L)
176 self.assertEqual(int('1606k7ic', 23), 4294967296L)
177 self.assertEqual(int('mb994ag', 24), 4294967296L)
178 self.assertEqual(int('hek2mgl', 25), 4294967296L)
179 self.assertEqual(int('dnchbnm', 26), 4294967296L)
180 self.assertEqual(int('b28jpdm', 27), 4294967296L)
181 self.assertEqual(int('8pfgih4', 28), 4294967296L)
182 self.assertEqual(int('76beigg', 29), 4294967296L)
183 self.assertEqual(int('5qmcpqg', 30), 4294967296L)
184 self.assertEqual(int('4q0jto4', 31), 4294967296L)
185 self.assertEqual(int('4000000', 32), 4294967296L)
186 self.assertEqual(int('3aokq94', 33), 4294967296L)
187 self.assertEqual(int('2qhxjli', 34), 4294967296L)
188 self.assertEqual(int('2br45qb', 35), 4294967296L)
189 self.assertEqual(int('1z141z4', 36), 4294967296L)
193 self.assertEqual(int(' 0123 ', 0), 83)
194 self.assertEqual(int(' 0123 ', 0), 83)
195 self.assertEqual(int('000', 0), 0)
196 self.assertEqual(int('0o123', 0), 83)
197 self.assertEqual(int('0x123', 0), 291)
198 self.assertEqual(int('0b100', 0), 4)
199 self.assertEqual(int(' 0O123 ', 0), 83)
200 self.assertEqual(int(' 0X123 ', 0), 291)
201 self.assertEqual(int(' 0B100 ', 0), 4)
202 self.assertEqual(int('0', 0), 0)
203 self.assertEqual(int('+0', 0), 0)
204 self.assertEqual(int('-0', 0), 0)
205 self.assertEqual(int('00', 0), 0)
206 self.assertRaises(ValueError, int, '08', 0)
207 self.assertRaises(ValueError, int, '-012395', 0)
210 self.assertEqual(int('0123'), 123)
211 self.assertEqual(int('0123', 10), 123)
214 self.assertEqual(int('0x123', 16), 291)
215 self.assertEqual(int('0o123', 8), 83)
216 self.assertEqual(int('0b100', 2), 4)
217 self.assertEqual(int('0X123', 16), 291)
218 self.assertEqual(int('0O123', 8), 83)
219 self.assertEqual(int('0B100', 2), 4)
223 self.assertRaises(ValueError, int, '0b2', 2)
224 self.assertRaises(ValueError, int, '0b02', 2)
225 self.assertRaises(ValueError, int, '0B2', 2)
226 self.assertRaises(ValueError, int, '0B02', 2)
227 self.assertRaises(ValueError, int, '0o8', 8)
228 self.assertRaises(ValueError, int, '0o08', 8)
229 self.assertRaises(ValueError, int, '0O8', 8)
230 self.assertRaises(ValueError, int, '0O08', 8)
231 self.assertRaises(ValueError, int, '0xg', 16)
232 self.assertRaises(ValueError, int, '0x0g', 16)
233 self.assertRaises(ValueError, int, '0Xg', 16)
234 self.assertRaises(ValueError, int, '0X0g', 16)
238 self.assertEqual(int('100000000000000000000000000000001', 2), 4294967297L)
239 self.assertEqual(int('102002022201221111212', 3), 4294967297L)
240 self.assertEqual(int('10000000000000001', 4), 4294967297L)
241 self.assertEqual(int('32244002423142', 5), 4294967297L)
242 self.assertEqual(int('1550104015505', 6), 4294967297L)
243 self.assertEqual(int('211301422355', 7), 4294967297L)
244 self.assertEqual(int('40000000001', 8), 4294967297L)
245 self.assertEqual(int('12068657455', 9), 4294967297L)
246 self.assertEqual(int('4294967297', 10), 4294967297L)
247 self.assertEqual(int('1904440555', 11), 4294967297L)
248 self.assertEqual(int('9ba461595', 12), 4294967297L)
249 self.assertEqual(int('535a7988a', 13), 4294967297L)
250 self.assertEqual(int('2ca5b7465', 14), 4294967297L)
251 self.assertEqual(int('1a20dcd82', 15), 4294967297L)
252 self.assertEqual(int('100000001', 16), 4294967297L)
253 self.assertEqual(int('a7ffda92', 17), 4294967297L)
254 self.assertEqual(int('704he7g5', 18), 4294967297L)
255 self.assertEqual(int('4f5aff67', 19), 4294967297L)
256 self.assertEqual(int('3723ai4h', 20), 4294967297L)
257 self.assertEqual(int('281d55i5', 21), 4294967297L)
258 self.assertEqual(int('1fj8b185', 22), 4294967297L)
259 self.assertEqual(int('1606k7id', 23), 4294967297L)
260 self.assertEqual(int('mb994ah', 24), 4294967297L)
261 self.assertEqual(int('hek2mgm', 25), 4294967297L)
262 self.assertEqual(int('dnchbnn', 26), 4294967297L)
263 self.assertEqual(int('b28jpdn', 27), 4294967297L)
264 self.assertEqual(int('8pfgih5', 28), 4294967297L)
265 self.assertEqual(int('76beigh', 29), 4294967297L)
266 self.assertEqual(int('5qmcpqh', 30), 4294967297L)
267 self.assertEqual(int('4q0jto5', 31), 4294967297L)
268 self.assertEqual(int('4000001', 32), 4294967297L)
269 self.assertEqual(int('3aokq95', 33), 4294967297L)
270 self.assertEqual(int('2qhxjlj', 34), 4294967297L)
271 self.assertEqual(int('2br45qc', 35), 4294967297L)
272 self.assertEqual(int('1z141z5', 36), 4294967297L)
316 self.assertEqual(int(float(int(value))), value)
319 self.assertEqual(int(float(2**53+1)), 2**53)
320 self.assertEqual(int(float(2**53+2)), 2**53+2)
321 self.assertEqual(int(float(2**53+3)), 2**53+4)
322 self.assertEqual(int(float(2**53+5)), 2**53+4)
323 self.assertEqual(int(float(2**53+6)), 2**53+6)
324 self.assertEqual(int(float(2**53+7)), 2**53+8)
326 self.assertEqual(int(float(-2**53-1)), -2**53)
327 self.assertEqual(int(float(-2**53-2)), -2**53-2)
328 self.assertEqual(int(float(-2**53-3)), -2**53-4)
329 self.assertEqual(int(float(-2**53-5)), -2**53-4)
330 self.assertEqual(int(float(-2**53-6)), -2**53-6)
331 self.assertEqual(int(float(-2**53-7)), -2**53-8)
333 self.assertEqual(int(float(2**54-2)), 2**54-2)
334 self.assertEqual(int(float(2**54-1)), 2**54)
335 self.assertEqual(int(float(2**54+2)), 2**54)
336 self.assertEqual(int(float(2**54+3)), 2**54+4)
337 self.assertEqual(int(float(2**54+5)), 2**54+4)
338 self.assertEqual(int(float(2**54+6)), 2**54+8)
339 self.assertEqual(int(float(2**54+10)), 2**54+8)
340 self.assertEqual(int(float(2**54+11)), 2**54+12)
358 self.assertEqual(int(x), 100, msg=msg)
360 self.assertEqual(int(x, 2), 4, msg=msg)
367 int(x, 2)
371 int(f('A' * 0x10))
375 self.assertEqual(int(buffer('123', 1, 2)), 23)
376 self.assertEqual(int(buffer('123\x00', 1, 2)), 23)
377 self.assertEqual(int(buffer('123 ', 1, 2)), 23)
378 self.assertEqual(int(buffer('123A', 1, 2)), 23)
379 self.assertEqual(int(buffer('1234', 1, 2)), 23)
382 self.assertRaises(ValueError, int, '1.2')
385 self.assertRaises(TypeError, int, bytearray('100'), 2)
389 self.assertRaises(ValueError, int, '100', base)
392 self.assertRaises(TypeError, int, 100, base='foo')
396 self.assertIs(int('10'), 10)
397 self.assertIs(int('-1'), -1)
399 self.assertIs(int(u'10'), 10)
400 self.assertIs(int(u'-1'), -1)
406 self.assertRaises(AttributeError, int, ClassicMissingMethods())
410 self.assertRaises(TypeError, int, MissingMethods())
420 class Foo2(int):
424 class Foo3(int):
428 class Foo4(int):
432 class Foo5(int):
436 self.assertEqual(int(Foo0()), 42)
437 self.assertEqual(int(Foo1()), 42)
438 self.assertEqual(int(Foo2()), 42)
439 self.assertEqual(int(Foo3()), 0)
440 self.assertEqual(int(Foo4()), 42L)
441 self.assertRaises(TypeError, int, Foo5())
451 self.assertEqual(int(IntOverridesTrunc()), 42)
456 self.assertEqual(int(JustTrunc()), 42)
466 self.assertEqual(int(TruncReturnsNonInt()), 42)
477 int(TruncReturnsNonIntegral())
490 n = int(good_int)