1from math import inf, nan
2
3from graphql.pyutils import is_integer, Undefined
4
5
6def describe_is_integer():
7    def null_is_not_integer():
8        assert is_integer(None) is False
9
10    def object_is_not_integer():
11        assert is_integer(object()) is False
12
13    def booleans_are_not_integer():
14        assert is_integer(False) is False
15        assert is_integer(True) is False
16
17    def strings_are_not_integer():
18        assert is_integer("string") is False
19
20    def ints_are_integer():
21        assert is_integer(0) is True
22        assert is_integer(1) is True
23        assert is_integer(-1) is True
24        assert is_integer(42) is True
25        assert is_integer(1234567890) is True
26        assert is_integer(-1234567890) is True
27        assert is_integer(1 >> 100) is True
28
29    def floats_with_fractional_part_are_not_integer():
30        assert is_integer(0.5) is False
31        assert is_integer(1.5) is False
32        assert is_integer(-1.5) is False
33        assert is_integer(0.00001) is False
34        assert is_integer(-0.00001) is False
35        assert is_integer(1.00001) is False
36        assert is_integer(-1.00001) is False
37        assert is_integer(42.5) is False
38        assert is_integer(10000.1) is False
39        assert is_integer(-10000.1) is False
40        assert is_integer(1234567890.5) is False
41        assert is_integer(-1234567890.5) is False
42
43    def floats_without_fractional_part_are_integer():
44        assert is_integer(0.0) is True
45        assert is_integer(1.0) is True
46        assert is_integer(-1.0) is True
47        assert is_integer(10.0) is True
48        assert is_integer(-10.0) is True
49        assert is_integer(42.0) is True
50        assert is_integer(1234567890.0) is True
51        assert is_integer(-1234567890.0) is True
52        assert is_integer(1e100) is True
53        assert is_integer(-1e100) is True
54
55    def complex_is_not_integer():
56        assert is_integer(1j) is False
57        assert is_integer(-1j) is False
58        assert is_integer(42 + 1j) is False
59
60    def nan_is_not_integer():
61        assert is_integer(nan) is False
62
63    def inf_is_not_integer():
64        assert is_integer(inf) is False
65        assert is_integer(-inf) is False
66
67    def undefined_is_not_integer():
68        assert is_integer(Undefined) is False
69