1# This file is dual licensed under the terms of the Apache License, Version
2# 2.0, and the BSD License. See the LICENSE file in the root of this repository
3# for complete details.
4
5import pytest
6
7from packaging._structures import Infinity, NegativeInfinity
8
9
10def test_infinity_repr():
11    repr(Infinity) == "Infinity"
12
13
14def test_negative_infinity_repr():
15    repr(NegativeInfinity) == "-Infinity"
16
17
18def test_infinity_hash():
19    assert hash(Infinity) == hash(Infinity)
20
21
22def test_negative_infinity_hash():
23    assert hash(NegativeInfinity) == hash(NegativeInfinity)
24
25
26@pytest.mark.parametrize("left", [1, "a", ("b", 4)])
27def test_infinity_comparison(left):
28    assert left < Infinity
29    assert left <= Infinity
30    assert not left == Infinity
31    assert left != Infinity
32    assert not left > Infinity
33    assert not left >= Infinity
34
35
36@pytest.mark.parametrize("left", [1, "a", ("b", 4)])
37def test_negative_infinity_lesser(left):
38    assert not left < NegativeInfinity
39    assert not left <= NegativeInfinity
40    assert not left == NegativeInfinity
41    assert left != NegativeInfinity
42    assert left > NegativeInfinity
43    assert left >= NegativeInfinity
44
45
46def test_infinity_equal():
47    assert Infinity == Infinity
48
49
50def test_negative_infinity_equal():
51    assert NegativeInfinity == NegativeInfinity
52
53
54def test_negate_infinity():
55    assert isinstance(-Infinity, NegativeInfinity.__class__)
56
57
58def test_negate_negative_infinity():
59    assert isinstance(-NegativeInfinity, Infinity.__class__)
60