Commit Graph

60 Commits

Author SHA1 Message Date
Guillaume Lessard
d463723e15 [test] guard a behavioral change
These two edge cases were fixed in https://github.com/apple/swift/pull/71369, and fail when run against an older standard library. Ensure they run only against a Swift 6.0 or newer stdlib

Addresses rdar://123810713
2024-02-29 08:24:48 -08:00
Oscar Byström Ericsson
306eaefb5b Apply suggestions from code review
- Changed 128 integer literal to Int(Int8.max)+1 in unit tests (Int8.Stride is Int).

Co-authored-by: Guillaume Lessard <glessard@users.noreply.github.com>
2024-02-04 08:27:27 +01:00
Oscar Byström Ericsson
17187e38f5 This patch fixes two unnecessary traps in BinaryInteger's advanced(to:) method.
- `Int8.min.advanced(by: 128)`, etc.
- `UInt.max.advanced(by: Int.min)`, etc.
2024-02-03 13:56:33 +01:00
Anthony Latsis
52ce15ee9d Gardening: Migrate test suite to GH issues: stdlib 2022-09-22 03:21:39 +03:00
Josh Soref
624a54b9cf Spelling stdlib (#42544)
* spelling: abcdefghijklmnopqrstuvwxyz

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: clazz

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: collection

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: compressible

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: constituent

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: contiguous

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: convertibility

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: element

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: enforce

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: exhaustive

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: exhausts

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: existential

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: facilitate

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: ignored

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: incorporated

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: intersection

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: laziness

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: misaligned

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: overhaul

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: preamble

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: precondition

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: replacement

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: trailing

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: unambiguous

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: uncompressible

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

* spelling: world

Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>

Co-authored-by: Josh Soref <jsoref@users.noreply.github.com>
2022-04-22 19:18:38 -07:00
Daniel Duan
3dfc40898c [NFC] Remove Python 2 imports from __future__ (#42086)
The `__future__` we relied on is now,  where the 3 specific things are
all included [since Python 3.0](https://docs.python.org/3/library/__future__.html):

* absolute_import
* print_function
* unicode_literals
* division

These import statements are no-ops and are no longer necessary.
2022-04-13 14:01:30 -07:00
Mishal Shah
a3cd8bc9e9 [Tests] Codesign the binary before executing the test 2020-08-07 00:26:07 -07:00
Saleem Abdulrasool
cb1aeea9af test: make stdlib/Integer.swift.gyb python 3 friendly
Adjust the division operation to ensure that we get an integral value
back.  Without this, we would attempt to shift a floating point value
by bitwise operations which is not supported.
2020-07-10 14:28:49 -07:00
Arnold Schwaighofer
b31b7a9d8e Remove some UNSUPPORTED swift_test_mode_optimize_none_with_implicit_dynamic
rdar://51228899
2019-05-31 08:45:37 -07:00
Arnold Schwaighofer
e113ef8c93 Add a mode to test implicit dynamic with private imports 2019-03-20 14:34:01 -07:00
Pavol Vaskovic
ac04995089 [Gardening] Remove DoubleWidth dead code from test 2019-03-01 20:51:43 +01:00
Karoy Lorentey
666a22feff [test] Modernize hashing throughout the test suite 2018-11-29 17:38:29 +00:00
Doug Gregor
0a8058ca6a [Integer protocols] Make BinaryInteger.Words conform to RandomAccessCollection.
Require that BinaryInteger.Words conform to RandomAccessCollection with
an Index type of Int, simplifying clients.

Fixes rdar://problem/36410936.
2018-09-05 16:22:27 -07:00
Stephen Canon
190c7d6b9f Default implementation of isMultiple(of:) on BinaryInteger
In order to provide source compatibility with existing user types conforming to BinaryInteger, we want to have a default implementation available. It's somewhat difficult to provide a good default implementation that correctly handles arbitrary non-symmetrical ranges in the face of negative divisors, so fall back on testing divisibility of the magnitudes, which avoids the problem.

On the plus side, this default implementation works fine for types conforming to UnsignedInteger, which lets us move the FixedWidthInteger implementation down to FixedWidthInteger & SignedInteger, and simplify it in the process.
2018-09-04 16:32:14 -04:00
Stephen Canon
c1f25e0673 [SE-0225] Implementation of isMultiple for BinaryInteger. (#18689)
* Implement SE-0225 (BinaryInteger.isMultiple(of:))

A default implementation is provided for FixedWidthInteger, with very basic test coverage included.
2018-09-04 10:31:05 -04:00
Stephen Canon
35db40c9f9 Make BinaryInteger._binaryLogarithm() return Int instead of Self (#18219)
Returning `Self` was probably a hack from when shifts were required to be homogenous and we didn't have good generic inits between integer types. Returning Int is more natural, because:

1. Dimensional analysis says that we shouldn't expect the logarithm to have the same type.
2. Int is guaranteed to be able to represent any object size, and BinaryInteger does not admit sparse representations, so the logarithm of the value cannot exceed allocated storage size.
3. Every single use case in the stdlib and tests is either unchanged or simplified by this change.
2018-07-25 14:04:32 -04:00
Max Moiseev
141fefc06b Update tests after removal of DoubleWidth 2018-03-23 17:14:46 -07:00
bruno-rocha-movile
08610df3e7 [stdlib] Improve masked operator tests 2018-03-19 18:45:09 -03:00
bruno-rocha-movile
16d793afbd [stdlib] Add overflow operator tests 2018-03-19 17:46:21 -03:00
Saleem Abdulrasool
b67d5f0cf7 test: convert rm -rf && mkdir -p into %empty-directory
This converts the instances of the pattern for which we have a proper
substitution in lit.  This will make it easier to replace it
appropriately with Windows equivalents.
2018-03-06 14:30:54 -08:00
Xiaodi Wu
cc0e64dec4 Implement efficient DoubleWidth division and fix division-related bugs 2018-01-28 14:01:06 -06:00
Xiaodi Wu
7e03829aab Improve _binaryLogarithm implementation and add tests 2018-01-18 16:45:41 -06:00
Paul Menage
428d95b32c Fix typo in 32-bit portion of Integers test 2017-11-29 17:25:37 -08:00
Nate Cook
5dbfa2d947 Update tests for larger integer sizes 2017-11-24 23:06:12 -06:00
Nate Cook
1acb38aa9e [stdlib] Add more tests for strideable behavior 2017-09-29 22:57:46 -05:00
Nate Cook
4e45358a49 Merge branch 'master' into nc-dwformatting 2017-08-02 14:54:56 -05:00
Maxim Moiseev
52259b714b Merge pull request #11193 from xwu/lossless-integers
[stdlib] Conform fixed-width integer types to LosslessStringConvertible
2017-07-28 20:10:07 -07:00
Xiaodi Wu
7578822e27 Another minor fixup for type inference in expectEqualSequence 2017-07-27 18:55:41 -05:00
Xiaodi Wu
f99f03c157 Minor fixup for type inference in expectEqualSequence 2017-07-27 18:53:10 -05:00
Xiaodi Wu
14a7c78454 Update integer parsing test to use expectEqualSequence 2017-07-27 18:49:22 -05:00
Xiaodi Wu
add2bce944 Revise doc comments and add test 2017-07-26 22:57:28 -05:00
Max Moiseev
1c3e597928 [stdlib] Get rid of ArithmeticOverflow type 2017-07-26 11:09:36 -07:00
Maxim Moiseev
a5ff35cd41 [stdlib] extendingOrTruncating: => truncatingIfNeeded: 2017-07-26 11:09:36 -07:00
Nate Cook
e3e36f75a8 [test] Increase DoubleWidth bit shifting test coverage 2017-07-24 19:35:59 -05:00
Károly Lőrentey
735fe97242 [stdlib] Fix sign extension in word -> multi-word integer conversions
This fixes integer conversion issues on 32-bit platforms.
2017-07-11 04:33:14 +02:00
Károly Lőrentey
6ae2040c42 [stdlib][test] Update integer tests. 2017-07-10 22:40:52 +02:00
Nate Cook
1149eeac16 Incorporate feedback from @moiseev
- Also clean up some 80-column issues
- And improve some tests from before literal expressibility
2017-05-25 18:32:15 -05:00
Nate Cook
5ab34bf6f0 Add floating-point initializers and tests 2017-05-24 19:16:26 -05:00
Nate Cook
40f6869b80 More tests for DoubleWidth 2017-05-24 19:16:26 -05:00
Nate Cook
4a24a968ca Slightly better DoubleWidth testing 2017-05-24 19:16:26 -05:00
Nate Cook
c8f4c4bb8e A few tests for DoubleWidth 2017-05-24 19:16:26 -05:00
Max Moiseev
0a466e3ca0 Revert "[stdlib] Implementing copy constructors for integer types"
This reverts commit 3f0d1e61aa.

The copy constructors don't really solve any problems, but produce extra
work for the overload resolution.
2017-05-13 12:27:43 -07:00
Max Moiseev
3f0d1e61aa [stdlib] Implementing copy constructors for integer types 2017-05-12 17:37:04 -07:00
Dave Abrahams
ddf7ad517f UnicodeScalar => Unicode.Scalar 2017-05-11 15:23:25 -07:00
Maxim Moiseev
e868ca7035 [stdlib] Better BinaryInteger.signum and tests 2017-05-11 14:02:59 -07:00
Maxim Moiseev
13abb9a0a7 [stdlib] BinaryInteger func word(at:) => var words: Words (#8984)
* [stdlib] Underscoring BinaryInteger.word(at:)

* [stdlib] Implementing var words in terms of _word(at:)
2017-04-25 08:45:01 -07:00
swift-ci
20dcfcb425 Merge pull request #8860 from moiseev/unsigned-minus-one 2017-04-19 11:50:53 -07:00
Max Moiseev
830b2edf54 [stdlib] Check overflow in integer init from literal
Fixes: <rdar://problem/29911715>
And partially: <rdar://problem/29937936>
2017-04-19 11:06:26 -07:00
practicalswift
a029589093 [gardening] Use consistent headers 2017-04-18 19:51:08 +02:00
Max Moiseev
2e67c13d15 Fixing some tests 2017-04-14 16:19:06 -07:00