mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Fix several problems with FixedPointConversion generation code. The first problem is that at some point `repr(value)` was being used, which turn the number into a string. That was great for printing the number, but make the test against the value of the number (like `testValue < otherMin` always false. There were a number of tests that were never performed, specifically the integer tests. The second problem was using doubles in the Python code. For Float32 and Float64 the tests were generated correctly, but in the case of Float80, the test adding or removing a quantity to the maximum/minimum were failing because of the lack of precission (Adding 0.1 to a very big/small number is the same as not adding anything). Switching to Decimal should keep enough precission for the tests. Finally the last problem was that the bounds of the conversions are not actually `selfMin` and `selfMax`, but the values returned by the utility function `getFtoIBounds`. For example for unsigned types, the lower bound is always -1, not zero (every value between -1 and zero is rounded to zero, and doesn't fail). Instead of using nested gyb templates, use lit.cfg %target-ptrsize, which should be faster, cleaner, and provides correct line-directive output. Remove a bunch of warnings in Swift when compiling the generated result of FixedPointConversion.swift.gyb. Co-authored-by: Gwynne Raskind <gwynne@users.noreply.github.com>
7.7 KiB
7.7 KiB