File tree Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Expand file tree Collapse file tree 1 file changed +22
-0
lines changed Original file line number Diff line number Diff line change @@ -50,3 +50,25 @@ def test_hash_file(tmpdir):
50
50
helpers_file .hash_file (outdir / "test.file" )
51
51
== "9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08"
52
52
)
53
+
54
+
55
+ def test_hashfun_float ():
56
+ import math
57
+
58
+ pi_50 = 3.14159265358979323846264338327950288419716939937510
59
+ pi_15 = 3.141592653589793
60
+ pi_10 = 3.1415926536
61
+ # comparing for x that have the same x.as_integer_ratio()
62
+ assert (
63
+ math .pi .as_integer_ratio ()
64
+ == pi_50 .as_integer_ratio ()
65
+ == pi_15 .as_integer_ratio ()
66
+ )
67
+ assert (
68
+ helpers .hash_function (math .pi )
69
+ == helpers .hash_function (pi_15 )
70
+ == helpers .hash_function (pi_50 )
71
+ )
72
+ # comparing for x that have different x.as_integer_ratio()
73
+ assert math .pi .as_integer_ratio () != pi_10 .as_integer_ratio ()
74
+ assert helpers .hash_function (math .pi ) != helpers .hash_function (pi_10 )
You can’t perform that action at this time.
0 commit comments