def test_pickle_sequence(self) -> None: control = I32List([1, 2, 3, 4]) self.pickle_round_robin(control) digits = Digits(data=[Integers(tiny=1), Integers(tiny=2), Integers(large=0)]) assert digits.data self.pickle_round_robin(digits.data)
def test_map_key_value(self) -> None: x = StrStrIntListMapMap({"a": StrI32ListMap({"b": I32List([7, 8, 9])})}) self.assertTrue(inspectable(x)) self.assertTrue(inspectable(StrStrIntListMapMap)) r = inspect(x) self.assertEqual(r.key, str) self.assertEqual(r.value, StrI32ListMap)
def test_splicing(self) -> None: x = I32List([1, 2, 3, 4, 1, 2, 3, 4]) y = list(x) self.assertEqual(x[2:], y[2:]) self.assertEqual(x[:5], y[:5]) self.assertEqual(x[:0], y[:0]) self.assertEqual(x[-5:-1], y[-5:-1])
def test_rpc_container_autoboxing(self): client = TestingService() client.takes_a_list([1, 2, 3]) client.takes_a_list(I32List([1, 2, 3])) loop = asyncio.get_event_loop() with self.assertRaises(TypeError): # This is safe because we do type checks before we touch # state checks loop.run_until_complete(client.takes_a_list([1, 'b', 'three']))
def test_index(self) -> None: x = I32List([1, 2, 3, 4, 1, 2, 3, 4]) y = list(x) self.assertEqual(x.index(2), y.index(2)) self.assertEqual(x.index(2, 3), y.index(2, 3)) self.assertEqual(x.index(2, 0, 2), y.index(2, 0, 2)) with self.assertRaises(ValueError): raise Exception(x.index(4, 0, 2)) with self.assertRaises(ValueError): y.index(4, 0, 2) self.assertEqual(x.index(4, -20, -2), y.index(4, -20, -2))
def test_comparisons(self) -> None: x = I32List([1, 2, 3, 4]) y = I32List([1, 2, 3, 4, 5]) z = I32List([1, 2, 3, 1, 10]) self.assertLess(x, y) self.assertLess(z, x) self.assertLess(z, y) self.assertNotEqual(z, y) self.assertNotEqual(x, y) self.assertNotEqual(z, x) self.assertGreater(y, x) self.assertGreater(x, z) self.assertGreaterEqual(x, z) self.assertLessEqual(x, y) x2 = I32List([1, 2, 3, 4]) self.assertEqual(x, x2) self.assertLessEqual(x, x2) self.assertGreaterEqual(x, x2)
def test_comparisons(self) -> None: x = I32List([1, 2, 3, 4]) y = I32List([1, 2, 3, 4, 5]) z = I32List([1, 2, 3, 1, 10]) # pyre-fixme[6]: For 2nd param expected `SupportsDunderGT[Variable[_T]]` but # got `List__i32`. self.assertLess(x, y) # pyre-fixme[6]: For 2nd param expected `SupportsDunderGT[Variable[_T]]` but # got `List__i32`. self.assertLess(z, x) # pyre-fixme[6]: For 2nd param expected `SupportsDunderGT[Variable[_T]]` but # got `List__i32`. self.assertLess(z, y) self.assertNotEqual(z, y) self.assertNotEqual(x, y) self.assertNotEqual(z, x) # pyre-fixme[6]: For 2nd param expected `SupportsDunderLT[Variable[_T]]` but # got `List__i32`. self.assertGreater(y, x) # pyre-fixme[6]: For 2nd param expected `SupportsDunderLT[Variable[_T]]` but # got `List__i32`. self.assertGreater(x, z) # pyre-fixme[6]: For 2nd param expected `SupportsDunderLE[Variable[_T]]` but # got `List__i32`. self.assertGreaterEqual(x, z) # pyre-fixme[6]: For 2nd param expected `SupportsDunderGT[Variable[_T]]` but # got `List__i32`. self.assertLessEqual(x, y) x2 = I32List([1, 2, 3, 4]) self.assertEqual(x, x2) # pyre-fixme[6]: For 2nd param expected `SupportsDunderGT[Variable[_T]]` but # got `List__i32`. self.assertLessEqual(x, x2) # pyre-fixme[6]: For 2nd param expected `SupportsDunderLE[Variable[_T]]` but # got `List__i32`. self.assertGreaterEqual(x, x2)
def test_rpc_container_autoboxing(self) -> None: client = TestingService() with self.assertRaises(asyncio.InvalidStateError): client.takes_a_list([1, 2, 3]) with self.assertRaises(asyncio.InvalidStateError): client.takes_a_list(I32List([1, 2, 3])) loop = asyncio.get_event_loop() with self.assertRaises(TypeError): # This is safe because we do type checks before we touch # state checks loop.run_until_complete( client.takes_a_list([1, "b", "three"]) # type: ignore )
def test_rpc_container_autoboxing(self) -> None: client = TestingService() with self.assertRaises(asyncio.InvalidStateError): client.takes_a_list([1, 2, 3]) with self.assertRaises(asyncio.InvalidStateError): client.takes_a_list(I32List([1, 2, 3])) loop = asyncio.get_event_loop() with self.assertRaises(TypeError): # This is safe because we do type checks before we touch # state checks loop.run_until_complete( # pyre-fixme[6]: Expected `Sequence[int]` for 1st param but got # `Sequence[typing.Union[int, str]]`. client.takes_a_list([1, "b", "three"]))
def test_list_creation(self) -> None: I32List(range(10)) with self.assertRaises(TypeError): I32List([1, "b", "c", "four"]) # type: ignore
def test_hashability(self) -> None: hash(easy().val_list) hash(I32List(range(10)))
def test_list_creation(self) -> None: I32List(range(10)) with self.assertRaises(TypeError): # pyre-fixme[6]: Expected `Optional[typing.Sequence[int]]` for 1st param # but got `List[typing.Union[int, str]]`. I32List([1, "b", "c", "four"])
def test_list_of_None(self) -> None: with self.assertRaises(TypeError): # pyre-fixme[6]: Expected `Optional[typing.Sequence[int]]` for 1st param # but got `List[None]`. I32List([None, None, None])
def test_is_container(self) -> None: self.assertIsInstance(int_list, Container) self.assertIsInstance(I32List([1, 2, 3]), Container) self.assertIsInstance(StrList2D([["a", "b"], ["c", "d"]]), Container)
def test_list_creation(self) -> None: I32List(range(10)) with self.assertRaises(TypeError): I32List([1, 'b', 'c', 'four']) # type: ignore
def test_list_of_None(self): with self.assertRaises(TypeError): I32List([None, None, None])
def test_list_of_None(self) -> None: with self.assertRaises(TypeError): I32List([None, None, None]) # type: ignore