def test_range_intersection(self): self.assertEqual(AnyRange().range_intersection([NR(0, None, 1)]), [NR(0, None, 1)]) self.assertEqual( NR(0, None, 1).range_intersection([AnyRange()]), [NR(0, None, 1)]) self.assertEqual( NR(0, None, -1).range_intersection([AnyRange()]), [NR(0, None, -1)])
def test_range_relational(self): a = AnyRange() b = AnyRange() self.assertTrue(a.issubset(b)) self.assertEqual(a, a) self.assertEqual(a, b) c = NR(None, None, 0) self.assertFalse(a.issubset(c)) self.assertTrue(c.issubset(b)) self.assertNotEqual(a, c) self.assertNotEqual(c, a)
def test_range_difference(self): self.assertEqual( AnyRange().range_difference([NR(0,None,1)]), [AnyRange()] ) self.assertEqual( NR(0,None,1).range_difference([AnyRange()]), [] ) self.assertEqual( AnyRange().range_difference([AnyRange()]), [] )
def test_range_relational(self): a = RP([[NR(0, 10, 1)], [NR(0, 10, 0), NNR('a')]]) aa = RP([[NR(0, 10, 1)], [NR(0, 10, 0), NNR('a')]]) b = RP([[NR(0, 10, 1)], [NR(0, 10, 0), NNR('a'), NNR('b')]]) c = RP([[NR(0, 10, 1)], [NR(0, 10, 0), NNR('b')]]) d = RP([[NR(0, 10, 0)], [NR(0, 10, 0), NNR('a')]]) d = RP([[NR(0, 10, 0)], [AnyRange()]]) self.assertTrue(a.issubset(aa)) self.assertTrue(a.issubset(b)) self.assertFalse(a.issubset(c)) self.assertTrue(a.issubset(d)) self.assertFalse(a.issubset(NNR('a'))) self.assertFalse(a.issubset(NR(None, None, 0))) self.assertTrue(a.issubset(AnyRange()))
def test_isdisjoint(self): a = NNR('a') b = NR(0, 5, 0) c = NR(5, 10, 1) x = RP([[a], [b, c]]) y = RP([[a], [c]]) z = RP([[a], [b], [c]]) w = RP([[AnyRange()], [b]]) self.assertFalse(x.isdisjoint(x)) self.assertFalse(x.isdisjoint(y)) self.assertTrue(x.isdisjoint(z)) self.assertFalse(x.isdisjoint(w)) self.assertTrue(x.isdisjoint(a)) self.assertFalse(y.isdisjoint(w)) self.assertFalse(x.isdisjoint(AnyRange())) v = RP([[AnyRange()], [NR(0, 5, 0, (False, False))]]) self.assertTrue(y.isdisjoint(v))
def test_range_difference(self): a = NNR('a') b = NR(0, 5, 0) c = NR(5, 10, 1) x = RP([[a], [b, c]]) y = RP([[a], [c]]) z = RP([[a], [b], [c]]) w = RP([list(Any.ranges()), [b]]) self.assertEqual(x.range_difference([x]), []) self.assertEqual(x.range_difference([y]), [RP([[a], [b]])]) self.assertEqual(x.range_difference([z]), [x]) self.assertEqual(x.range_difference(Any.ranges()), []) self.assertEqual(x.range_difference([w]), [RP([[a], [NR(6, 10, 1)]])]) v = RP([[AnyRange()], [NR(0, 5, 0, (False, False))]]) self.assertEqual(y.range_difference([v]), [y])
def test_pickle(self): a = AnyRange() b = pickle.loads(pickle.dumps(a)) self.assertIsNot(a, b) self.assertEqual(a, b)
def test_info_methods(self): a = AnyRange() self.assertFalse(a.isdiscrete()) self.assertFalse(a.isfinite())
def test_contains(self): a = AnyRange() self.assertIn(None, a) self.assertIn(0, a) self.assertIn('a', a)
def test_str(self): self.assertEqual(str(AnyRange()), '[*]')