Skip to content

Commit a817409

Browse files
committed
test: make stdlib.NumericParsing Python 3 friendly
Use the proper division operation as the test otherwise generates different patterns.
1 parent bbbe67e commit a817409

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

test/stdlib/NumericParsing.swift.gyb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
// RUN: %line-directive %t/NumericParsing.swift -- %target-run %t/a.out
1818
// REQUIRES: executable_test
1919
%{
20+
from __future__ import division
2021
from SwiftIntTypes import all_integer_types
2122

2223
word_bits = int(CMAKE_SIZEOF_VOID_P)
@@ -36,7 +37,7 @@ Note: the third parameter, zero, is not for user consumption.
3637
else:
3738
r = n % radix
3839
digit = chr((ord('0') + r) if r < 10 else (ord('a') + r - 10))
39-
return inRadix(radix, int(n / radix), '') + digit
40+
return inRadix(radix, int(n // radix), '') + digit
4041

4142
# The maximal legal radix
4243
max_radix = ord('z') - ord('a') + 1 + 10
@@ -96,7 +97,7 @@ tests.test("${Self}/success") {
9697
% for radix in radices_to_test:
9798
% for n in required_values + list(range(
9899
% minValue + 1, maxValue - 1,
99-
% int((maxValue - minValue - 2) / (number_of_values - len(required_values))))):
100+
% int((maxValue - minValue - 2) // (number_of_values - len(required_values))))):
100101
% prefix = '+' if n > 0 and n % 2 == 0 else '' # leading '+'
101102
% text = inRadix(radix, n)
102103
expectEqual(${n}, ${Self}("${prefix + text}", radix: ${radix}))

0 commit comments

Comments
 (0)