Skip to content

Commit beeefbc

Browse files
authored
Merge pull request #34770 from tbkka/tbkka/numericParsingTest
Fix back-deployment tests
2 parents 0e6d4f7 + affca54 commit beeefbc

File tree

2 files changed

+61
-5
lines changed

2 files changed

+61
-5
lines changed

test/stdlib/NumericParsing.swift.gyb

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,10 @@ tests.test("${Self}/Basics") {
181181
expectNil(${Self}("0 ")) // Trailing whitespace
182182
expectNil(${Self}("\u{1D7FF}")) // MATHEMATICAL MONOSPACE DIGIT NINE
183183

184-
// Overflow to infinity, underflow to zero.
185-
expectEqual(.infinity, ${Self}("2e99999999999999"))
186-
expectEqual(0.0, ${Self}("2e-99999999999999"))
187-
expectEqual(-.infinity, ${Self}("-2e99999999999999"))
188-
expectEqual(0.0, ${Self}("-2e-99999999999999"))
184+
// Values that are too large/small:
185+
// * Early versions of Swift returned `nil` for e.g., 1e99999 or 1e-99999
186+
// * After 5.3, large/small values return .infinity or zero, respectively
187+
// These are tested in NumericParsing2.swift.gyb
189188
}
190189

191190
% if Self == 'Float80':

test/stdlib/NumericParsing2.swift.gyb

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
//===--- NumericParsing.swift.gyb -----------------------------*- swift -*-===//
2+
//
3+
// This source file is part of the Swift.org open source project
4+
//
5+
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
6+
// Licensed under Apache License v2.0 with Runtime Library Exception
7+
//
8+
// See https://swift.org/LICENSE.txt for license information
9+
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
10+
//
11+
//===----------------------------------------------------------------------===//
12+
// -*- swift -*-
13+
// RUN: %empty-directory(%t)
14+
// RUN: %gyb -DCMAKE_SIZEOF_VOID_P=%target-ptrsize %s -o %t/NumericParsing.swift
15+
// RUN: %line-directive %t/NumericParsing.swift -- %target-build-swift %t/NumericParsing.swift -o %t/a.out
16+
// RUN: %target-codesign %t/a.out
17+
// RUN: %line-directive %t/NumericParsing.swift -- %target-run %t/a.out
18+
// REQUIRES: executable_test
19+
//
20+
// Behaviors below are different in old Swift runtime libraries
21+
// UNSUPPORTED: use_os_stdlib
22+
23+
// ================================================================
24+
//
25+
// This is basically the same as NumericParsing, but exercises a
26+
// handful of behaviors that have changed since that test was written.
27+
// These tests are separated so they can be omitted when the test suite
28+
// is run against older runtime libraries.
29+
//
30+
// ================================================================
31+
32+
import StdlibUnittest
33+
34+
var tests = TestSuite("NumericParsing2")
35+
36+
% for Self in 'Float', 'Double', 'Float80':
37+
38+
% if Self == 'Float80':
39+
#if !os(Windows) && (arch(i386) || arch(x86_64))
40+
% end
41+
42+
tests.test("${Self}/Overflow/Underflow") {
43+
// Overflow to infinity, underflow to zero.
44+
// Note: These all returned `nil` in Swift 5.3 and earlier
45+
expectEqual(.infinity, ${Self}("2e99999999999999"))
46+
expectEqual(0.0, ${Self}("2e-99999999999999"))
47+
expectEqual(-.infinity, ${Self}("-2e99999999999999"))
48+
expectEqual(0.0, ${Self}("-2e-99999999999999"))
49+
}
50+
51+
% if Self == 'Float80':
52+
#endif
53+
% end
54+
55+
% end
56+
57+
runAllTests()

0 commit comments

Comments
 (0)