|
| 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