Commit Graph

197 Commits

Author SHA1 Message Date
David Smith
bcfa805635 Zero trailing bytes of SmallStrings more efficiently (#59823) 2022-07-11 11:46:15 -07: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
Alejandro Alonso
657c17fa39 Setup grapheme breaking tests 2022-02-15 17:16:36 -08:00
Alejandro Alonso
c0e1ef01f9 Fix backwards count of Indic graphemes 2022-02-15 15:28:37 -08:00
Alejandro Alonso
54ff7cfa2c Add availability around the indic sequence tests 2022-01-18 22:17:07 -08:00
Alejandro Alonso
4a451829f8 Implement the Indic grapheme breaking rules 2022-01-05 16:18:54 -08:00
Robert Widmann
0149ccd0ca Add arm64_32 support for Swift
Commit the platform definition and build script work necessary to
cross-compile for arm64_32.

arm64_32 is a variant of AARCH64 that supports an ILP32 architecture.
2021-04-20 14:59:04 -07:00
Kuba (Brecka) Mracek
d7dfa3e942 Bring up tests + validation tests for the 'freestanding' build and the standalone_minimal preset (#34386) 2020-10-26 16:32:36 -07:00
Robert Widmann
cddf73ecdb [Gardening] Clean Up OS-Test Patterns Across The Codebase
Clean up a few general patterns that are now obviated by canImport

This aligns more generally with the cleanup that the Swift Package
Manager has already done in their automated XCTest-plumbing tool in
apple/swift-package-manager#1826.
2020-06-30 22:55:58 -07:00
Ben Rimmington
f2c952cb69 [stdlib] Remove more unneeded numericCasts 2020-05-10 12:31:55 +01:00
Erik Eckstein
79fb67f5df tests: exclude some very long running tests from jobs with a non-optimized stdlib
Those are tests which take > 1000s on some simulator configurations with a non-optimized stdlib.
We run those tests anyway with an optimized stdlib. So we don’t lose test coverage by disabling them for debug-stdlib.

This fixes some sporadic time outs on the CI jobs.
2020-01-17 16:51:02 +01:00
Michael Ilseman
774788ac18 [test] Disable misaligned indices test prior to 5.1
Misaligned indices were fixed in 5.1, but we should disable the test
when testing back deployment.

Adds a shared helper to StdlibUnittest for the run time check.
2019-08-27 15:13:38 -07:00
Michael Ilseman
9e8993551b [test] Disable some tests in back-deployment scenarios.
Bugs relating to scalar alignment and grapheme stride caching were
fixed in 5.1, so they shouldn't be tested when back deploying.
2019-08-26 16:06:52 -07:00
Michael Ilseman
4cd1e812b7 [String] Scalar-alignment bug fixes.
Fixes a general category (pun intended) of scalar-alignment bugs
surrounding exchanging non-scalar-aligned indices between views and
for slicing.

SE-0180 unifies the Index type of String and all its views and allows
non-scalar-aligned indices to be used across views. In order to
guarantee behavior, we often have to check and perform scalar
alignment. To speed up these checks, we allocate a bit denoting
known-to-be-aligned, so that the alignment check can skip the
load. The below shows what views need to check for alignment before
they can operate, and whether the indices they produce are aligned.

┌───────────────╥────────────────────┬──────────────────────────┐
│ View          ║ Requires Alignment │ Produces Aligned Indices │
╞═══════════════╬════════════════════╪══════════════════════════╡
│ Native UTF8   ║ no                 │ no                       │
├───────────────╫────────────────────┼──────────────────────────┤
│ Native UTF16  ║ yes                │ no                       │
╞═══════════════╬════════════════════╪══════════════════════════╡
│ Foreign UTF8  ║ yes                │ no                       │
├───────────────╫────────────────────┼──────────────────────────┤
│ Foreign UTF16 ║ no                 │ no                       │
╞═══════════════╬════════════════════╪══════════════════════════╡
│ UnicodeScalar ║ yes                │ yes                      │
├───────────────╫────────────────────┼──────────────────────────┤
│ Character     ║ yes                │ yes                      │
└───────────────╨────────────────────┴──────────────────────────┘

The "requires alignment" applies to any operation taking a
String.Index that's not defined entirely in terms of other operations
taking a String.Index. These include:

* index(after:)
* index(before:)
* subscript
* distance(from:to:) (since `to` is compared against directly)
* UTF16View._nativeGetOffset(for:)
2019-06-26 16:42:58 -07:00
Michael Ilseman
93d65fc9c3 [gardening] Remove trailing whitespace 2019-06-26 09:22:17 -07:00
Saleem Abdulrasool
62cb79b536 Merge pull request #25213 from compnerd/standard-validation
validation-test: adjust stdlib tests for Windows
2019-06-10 11:35:04 -07:00
Saleem Abdulrasool
551c1be926 validation-test: make stdlib.string compile on Win32
The C library functions used here do not appear without the C runtime
being imported (ucrt or MSVCRT).  Adjust the test as such.  This exposes
a stack corruption in the test which needs to be resolved.
2019-06-04 09:43:13 -07:00
Saleem Abdulrasool
1c41c0887c validation-test: adjust stdlib tests for Windows
The embedded shell script in the RUN command for lit is problematic for
non-sh shell environments (i.e. Windows).  This adjusts the tests to
uniformly build the code for the ObjC runtime.  However, the Objective-C
code is only built under the same circumstances that it is currently
enabled - the availability of the needed frameworks.  The empty object
on other runtimes will have no material impact.  The swift side of it
checks whether the runtime is built with ObjC interop.  This allows us
to largely use the same command line for all the targets.  The last
missing piece is that the `-fobjc-runtime` requires that we run a modern
ObjC runtime.  We enable this unconditionally in lit for the non-Apple
targets.

This improves the validation test coverage for the standard library on
Windows.
2019-06-03 08:36:22 -07:00
Michael Ilseman
0ece62d911 [String] Add Substring.base
Adds Substring.base, analogous to Slice.base, to access the entire
String.

Tests added.
2019-03-29 15:43:00 -07:00
Michael Ilseman
415cc8fb0c [String.Index] Deprecate encodedOffset var/init
String.Index has an encodedOffset-based initializer and computed
property that exists for serialization purposes. It was documented as
UTF-16 in the SE proposal introducing it, which was String's
underlying encoding at the time, but the dream of String even then was
to abstract away whatever encoding happend to be used.

Serialization needs an explicit encoding for serialized indices to
make sense: the offsets need to align with the view. With String
utilizing UTF-8 encoding for native contents in Swift 5, serialization
isn't necessarily the most efficient in UTF-16.

Furthermore, the majority of usage of encodedOffset in the wild is
buggy and operates under the assumption that a UTF-16 code unit was a
Swift Character, which isn't even valid if the String is known to be
all-ASCII (because CR-LF).

This change introduces a pair of semantics-preserving alternatives to
encodedOffset that explicitly call out the UTF-16 assumption. These
serve as a gentle off-ramp for current mis-uses of encodedOffset.
2019-02-13 18:42:40 -08:00
Daniel Rodríguez Troitiño
d08b46c47e [tests] Standarize the checks for Darwin, Glibc and MSVCRT.
Different tests used different os checks for importing Darwin, Glibc and
MSVCRT. This commit use the same pattern for importing those libraries,
in order to avoid the #else branches of the incorrect patterns to be
applied to the wrong platform. This was very normal for Android, which
normally should follow the Linux branches, but sometimes was trying to
import Darwin or not importing anything.

The standarized pattern imports Darwin for macOS, iOS, tvOS and watchOS.
It imports Glibc for Linux, FreeBSD, PS4, Android, Cygwin and Haiku; and
imports MSVCRT for Windows. If a new platform is introduced, the else
branch will report an error, so the new platform can be added to one of
the branches (or maybe add a new specific branch).

In some cases  the standard pattern was modified because some test required
it (importing extra modules, or extra type aliases), and in some other
cases some branches were removed because the test will not have used
them (but it is not exhaustive, so there might be some unnecessary
branches).

This should, at least, fix three tests for Android (the three
dynamic_replacement*.swift ones).
2019-02-06 10:51:55 -08:00
Lance Parker
15aaa1e777 [stdlib]String normalization functions (#21026)
* fast/foreignNormalize functions
2019-01-08 13:55:29 -08:00
Michael Ilseman
c0c530aef8 [String] Speed up constant factors on comparison.
Include some tuning and tweaking to reduce the constant factors
involved in string comparison. This yields considerable improvement on
our micro-benchmarks, and allows us to make less inlinable code and
have a smaller ABI surface area.

Adds more extensive testing of corner cases in our existing
fast-paths.
2018-12-03 15:49:38 -08:00
Michael Ilseman
94942c5b3b [String] Fix corner case in comparison fast-path. (#20937)
When in a post-binary-prefix-scan fast-path, we need to make sure we
are comparing a full-segment scalar, otherwise we miss situations
where a combining end-of-segment scalar would be reordered with a
prior combining scalar in the same segment under normalization in one
string but not the other.

This was hidden by the fact that many combining scalars are not
NFC_QC=maybe, but those which are not present in any precomposed form
have NFC_QC=yes. Added tests.
2018-12-03 10:41:45 -08:00
Lance Parker
17187344df Make the NormalizationCheck test compare code units 2018-11-16 14:43:04 -08:00
Lance Parker
12bf2978e3 Michael's feedback 2018-11-16 10:20:46 -08:00
Lance Parker
0009b21533 properly promote stack buffer to heap buffer when necessary 2018-11-16 10:19:48 -08:00
Michael Ilseman
75943350d2 [String] Give String a custom iterator
Gives us modest wins on complex grapheme strings, but up to 40% on
heavy-ASCII strings.
2018-11-08 18:25:01 -08:00
Michael Ilseman
ec6729a3a3 [String] Assertion logic and isASCII bug fix.
Fix bugs in assertion logic and properly update the isASCII bit on
RRC. RRC tests added.
2018-11-04 10:42:44 -08:00
Michael Ilseman
948655e850 [String] Cleanups, comments, documentation
After rebasing on master and incorporating more 32-bit support,
perform a bunch of cleanup, documentation updates, comments, move code
back to String declaration, etc.
2018-11-04 10:42:42 -08:00
Michael Ilseman
e6582c37ee [test] Adjust String tests for UTF-8 representation.
Adjust tests for the UTF-8 representation, in preparation for 32-bit
support. Includes UTF-8 literal update.
2018-11-04 10:42:41 -08:00
Michael Ilseman
b87bff4fac [test] Test the unique-native String RRC optimization path 2018-11-04 10:42:41 -08:00
Lance Parker
f1a35bd1c9 String comparison iterator for UTF8 strings 2018-11-04 10:42:41 -08:00
Ben Cohen
e338344bae Remove overloads that were needed pre-conditional conformance 2018-09-11 21:00:36 -07:00
Jordan Rose
01a0de27ec [test] Update for remote-run-ing tests on a different macOS (#18966)
Most of this is just "remember to specify the inputs and outputs on
the command line, so remote-run can see them". A bit is "prefix
environment variables with '%env-'". And the last few are "yeah,
this was never going to work in a remote environment".

In the few cases where I couldn't think of anything reasonable, I just
marked the test as "UNSUPPORTED: remote_run", a new "feature".
2018-08-27 14:50:40 -07:00
Arnold Schwaighofer
b62c6e64ff Codesign validation-test/stdlib 2018-08-10 09:39:09 -07:00
Michael Ilseman
8294c0003a [string] Drop _StringGuts subscript; NFC
_StringGuts shouldn't expose a subscript, implying efficient
access. Switch to the explicit code unit fetch method. Update tests
accordingly, and switch off of deprecated typealiases.
2018-08-02 16:34:22 -07:00
Michael Ilseman
ba6158d74e [test] Internalize _StringGuts; Add shared testing struct; NFC
Create a _StringRepresentation struct to standardize internal testing
on. Internalize much of _StringGuts, except for some SPI hacks, and
update tests to use _StringRepresentation.
2018-08-01 14:23:56 -07:00
Michael Ilseman
a7d3c7079b [test] Adjust String.swift tests for non-small strings on 32b; NFC 2018-07-31 11:23:51 -07:00
Michael Ilseman
534a17aebb [test] Migrate String.swift off of Swift 3; NFC 2018-07-30 17:38:25 -07:00
Michael Ilseman
c8ed8f9a2f [test] Update String tests for older iOS versions 2018-07-13 16:08:36 -07:00
Ben Cohen
685f31b0e2 [stdlib] Migrate stdlib tests of Swift 3 (#17427)
* First sweep of Swift 3 stdlib test upgrades

* Review feedback

* Remove a handful more #if >=4.0

* Fix up Dictionary tests
2018-07-08 09:37:01 -07:00
Ben Cohen
a51cc89b11 Replace _CharacterView with a typealias (#17472) 2018-06-25 13:22:09 -07:00
Slava Pestov
5d2752f7d2 Run tests with -swift-version 4 by default
Some test now fail, so add an explicit -swift-version 3.
2018-06-19 23:24:19 -07:00
Michael Ilseman
1fe5fb717d [string] Skip allocation in reserveCapacity if smol
If the requested capacity is small enough to fit in our small string
representation, don't allocate a UTF-16 buffer, instead just return
early.
2018-05-18 21:26:59 -07:00
Michael Ilseman
459833725e [String] Streamline more String creation logic.
Streamline and de-genericize non-inlinable internal functions to
create a String from UTF-8 efficiently.
2018-05-13 07:38:55 -07:00
Michael Ilseman
715003c206 [gardening] Internalize many non-API String interfaces 2018-04-28 15:36:05 -07:00
Michael Ilseman
93d6130066 [string] Integrate small strings.
Switch StringObject and StringGuts from opaquely storing tagged cocoa
strings into storing small strings. Plumb small string support
throughout the standard library's routines.
2018-03-27 14:00:59 -07:00
Michael Ilseman
cdfeb88cfe [string] Simplify creation logic, especially for C strings.
Streamline internal String creation. Previously, everything funneled
into a single generic function, however, every single call of the
generic funnel had relevant specific information that could be used
for a more efficient algorithm.

In preparation for efficiently forming small strings, refactor this
logic into a handful of more specialized subroutines to preserve more
specific information from the callers.
2018-03-27 10:49:02 -07:00
Lance Parker
e0e50e9b3e Add failing test 2018-02-28 11:27:40 -08:00