test_compile_flags.py 1.3 KB

1234567891011121314151617181920212223242526272829
  1. ##############################################################################
  2. #
  3. # Copyright (c) 2022 Zope Foundation and Contributors.
  4. # All Rights Reserved.
  5. #
  6. # This software is subject to the provisions of the Zope Public License,
  7. # Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
  8. # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
  9. # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  10. # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
  11. # FOR A PARTICULAR PURPOSE
  12. #
  13. ##############################################################################
  14. import struct
  15. import unittest
  16. import zope.interface # noqa: try to load a C module for side effects
  17. class TestFloatingPoint(unittest.TestCase):
  18. def test_no_fast_math_optimization(self):
  19. # Building with -Ofast enables -ffast-math, which sets certain FPU
  20. # flags that can cause breakage elsewhere. A library such as BTrees
  21. # has no business changing global FPU flags for the entire process.
  22. zero_bits = struct.unpack("!Q", struct.pack("!d", 0.0))[0]
  23. next_up = zero_bits + 1
  24. smallest_subnormal = struct.unpack("!d", struct.pack("!Q", next_up))[0]
  25. self.assertNotEqual(smallest_subnormal, 0.0)