Commit Graph

39 Commits

Author SHA1 Message Date
Karoy Lorentey
b7e08accb1 [stdlib] Slice: customize withContiguous[Mutable]StorageIfAvailable (#28883)
* [stdlib] Slice: customize withContiguous[Mutable]StorageIfAvailable

We can easily make an UnsafeBufferPointer that slices another UnsafeBufferPointer, so let’s allow Slice to vend a slice of the base collection’s contiguous storage, if it provides access to one.

We need to do some index distance calculations to implement this, but those will be constant-time in the usual case where the base collection is a RAC.

https://bugs.swift.org/browse/SR-11957
rdar://58090587

* [test] UnsafeBufferPointer: fix some warnings

* [stdlib] Slice: don’t calculate index distances unless the base provides contiguous mutable storage
2020-01-06 12:32:30 -05:00
Ben Cohen
83823f5f7f [stdlib] Obsolete various compatibility shims in 5.0 (#19008)
* Obsolete ModifierSlice typealiases in 5.0

* Obsolete *Indexable in 5.0

* Obsolete IteratorOverOne/EmptyIterator in 5.0

* Obsolete lazy typealiases in 5.0

* Drop .characters from tests

* Obsolete old literal protocols in 5.0

* Obsolete Range conversion helpers in 5.0

* Obsolete IndexDistance helpers in 5.0

* Obsolete Unsafe compat helpers in 5.0

* Obsolete flatMap compatibility helper in 5.0

* Obsolete withMutableCharacters in 5.0

* Obsolete customPlaygroundQuickLook in 5.0

* Deprecate Zip2Sequence streams in 5.0

* Replace * with swift on lotsa stuff

* Back off obsoleting playground conformances for now
2018-08-28 13:20:25 -07:00
Ben Cohen
ca6c6b1d36 [stdlib] Cleanup DefaultIndices, delete dead code (#13952)
* Remove a bunch of Default(Bidirectional|RandomAccess)Indices usage from stdlib and test

* Remove some DefaultRandomAccessIndices and IndexDistance usage from Foundation

* Remove no-longer-used internal type in Existentials.swift

* Get rid of indicesForTraversal
2018-01-15 13:48:08 -08:00
Ben Cohen
4ddac3fbbd [stdlib] Eradicate IndexDistance associated type (#12641)
* Eradicate IndexDistance associated type, replacing with Int everywhere

* Consistently use Int for ExistentialCollection’s IndexDistance type.

* Fix test for IndexDistance removal

* Remove a handful of no-longer-needed explicit types

* Add compatibility shims for non-Int index distances

* Test compatibility shim

* Move IndexDistance typealias into the Collection protocol
2017-12-08 12:00:23 -08:00
Ben Cohen
85d190cd7d [stdlib] Replace various uses of BlahSlice with Slice to reduce warnings (#13263)
* Kill the slice variants from the gybbed collection test types

* Handful more SDK instances

* Fix SequencesCollections.swift.gyb
2017-12-05 19:09:56 -08:00
Ben Cohen
e3a4ca22d5 [stdlib] Implement slice Indices using their base Indices (#12277)
* Implement slice Indices using their base Indices

* Fix expected type test for Slice
2017-10-05 10:46:04 -07:00
Andrew Trick
da0c4db530 Fix and enable testing stdlib Collection instances.
Top-level entry points fully testing a collection instance:
check${Traversal}Collection

One level of recursion into all slices of the collection instance
O(n^2). (Not combinatorial).

Previously, checkCollection() did nothing. So much of the testing infrastructure was inactive. Now it runs all forward collection tests.

Fixes a bug in subscriptRangeTests.

The UnsafeRawBufferPointer and Data collection testing is disabled and
will be fixed in the following commit.
2017-04-06 17:12:18 -07:00
Andrew Trick
849421799a Revert "SE-0138: Proposed amendment to SE-0138: Normalize UnsafeRawBufferPointer Slices (#8222)"
This reverts commit 1d32586d28.
2017-04-06 10:38:52 -07:00
Andrew Trick
1d32586d28 SE-0138: Proposed amendment to SE-0138: Normalize UnsafeRawBufferPointer Slices (#8222)
* Add sliceability tests for Unsafe(Raw)BufferPointer.

Improve the generic sliceability tests to verify that SubSequence indices are
compatible with their parents indices.

* Fix and enable testing stdlib Collection instances.

Top-level entry points fully testing a collection instance:
check${Traversal}Collection

One level of recursion into all slices of the collection instance
O(n^2). (Not combinatorial).

Previously, checkCollection() did nothing. So much of the testing infrastructure was inactive. Now it runs all forward collection tests.

Fixes a bug in subscriptRangeTests.

The UnsafeRawBufferPointer and Data collection testing is disabled and
will be fixed in the following commit.

* Give UnsafeRawBufferPointer a distinct slice type.

SubSequence = RandomAccessSlice<Self>

* Fix raw buffer pointer tests after changing the API

* Add UnsafeRawBuffer(rebasing:) initializers.

Allows converting a raw slice into a zero-based raw buffer,
which is a common operation on flat memory.

Add and update UnsafeRawBufferPointer unit tests.

* Do not run recursive O(n^2) collection slice testing on large collections.

Now, even with collection unit testing wired up, the validation tests
take the same amount of time to execute.

* Add init(rebasing:) to UnsafeBufferPointer.

This is required for consistency with UnsafeRawBufferPointer.

* Update CHANGELOG.md for SE-0138 amendment: UnsafeRawBufferPointer slice type.
2017-04-06 10:08:09 -07:00
Dmitri Gribenko
e3a32a7044 stdlib tests: coding style fixes 2016-08-08 17:49:42 -07:00
Rintaro Ishizaki
38b31c6419 [validation-test] Remove unused SwiftPrivate import 2016-06-20 13:09:10 +09:00
rintaro ishizaki
4b51d85abb [test] Add %target-run-simple-swiftgyb
* Utilize %target-run-simple-swiftgyb where possible
2016-06-15 11:49:44 +09:00
Rintaro Ishizaki
1bdce7ced6 [lit] Add substitutions: %utils and %line-directive
%utils => ${SWIFT_SOURCE_DIR}/utils
%line-directive => ${SWIFT_SOURCE_DIR}/utils/line-directive
2016-06-11 02:41:15 +09:00
Chris Williams
d08cbd6a60 Test for Slice.base 2016-06-07 16:04:27 -07:00
Dmitri Gribenko
9c392bfdcb StdlibCollectionUnittest: generalize MutableCollection.SubSequence.subscript(_: Range)/Set tests 2016-04-04 18:38:11 -07:00
Dmitri Gribenko
6985b958fd Merge remote-tracking branch 'origin/master' into swift-3-indexing-model 2016-04-04 11:42:17 -07:00
Dmitri Gribenko
a5ad2b802c Remove a test that was migrated to StdlibCollectionUnittest 2016-04-02 02:50:12 -07:00
Slava Pestov
49c54870c1 Serialization: Auto-linking recursively walks modules imported from -sil-serialize-all modules 2016-04-01 12:21:36 -07:00
Dmitri Gribenko
3e8ffae660 New indexing model: update the test generator for Slice* tests 2016-03-29 17:34:03 -07:00
Dmitri Gribenko
941235c25e New indexing model: remove a duplicate API 2016-03-18 23:03:19 -07:00
Dave Abrahams
f493b54e44 [stdlib] indexing model: Interval/Range merge
This is step 1; we still need to introduce ClosedRange.
2016-03-16 15:59:10 -07:00
Max Moiseev
bb3eaaf308 Merging in latest master 2016-02-24 15:10:25 -08:00
Max Moiseev
61c837209b Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-02-04 16:13:39 -08:00
Dmitri Gribenko
aeeb9c1325 Move collection testing code from StdlibUnittest to a new library
This brings down StdlibUnittest build time to 90 seconds with either
a DebugAssert or a ReleaseAssert compiler.

The new library, StdlibCollectionTests, is only built when running
validation tests.
2016-01-26 18:58:03 -08:00
Dmitri Gribenko
62f73f4469 Rename CollectionDefaultIterator to IndexingIterator 2016-01-21 11:49:03 -08:00
Dmitri Gribenko
06577273e9 var Sequence.enumerated => func 2015-12-18 16:22:24 -08:00
Maxim Moiseev
9e50505970 internal or public // @testable initializers 2015-12-17 17:02:49 -08:00
Max Moiseev
2021dd5a4d Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-15 12:49:22 -08:00
Erik Eckstein
0830c36974 [tests] add import statements to prevent unresolved symbols when compiling StdlibUnittest with -sil-serialize-all.
This is the second part of 308f39fe56.
It fixes (better: works-around) linker errors when testing in optimized mode.
2015-12-15 10:46:10 -08:00
Max Moiseev
806be29941 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-14 12:05:35 -08:00
Arsen Gasparyan
52890e5c30 Replace if true {} with do {} 2015-12-13 10:54:54 +03:00
Dmitri Gribenko
d72b5ab575 func SequenceType.enumerate() => var SequenceType.enumerated 2015-12-09 17:13:21 -08:00
Maxim Moiseev
7e2466c14e CollectionType => Collection 2015-12-09 17:12:48 -08:00
Dmitri Gribenko
99d3f96c6d Rename IndexingGenerator to CollectionDefaultIterator 2015-12-09 17:12:07 -08:00
Dmitri Gribenko
2cf172160c Rename SequenceType.Generator associated type to SequenceType.Iterator 2015-12-09 17:11:05 -08:00
Dmitri Gribenko
31598d41bf Rename GeneratorType to IteratorProtocol 2015-12-07 17:08:32 -08:00
Dmitri Hrybenko
ff1680c7ea stdlib: expand the test boilerplate from Slice.swift.gyb
This test organization allows running more tests in parallel.

Part of rdar://22297353

Swift SVN r31287
2015-08-18 03:54:13 +00:00
David Farler
311baf73cf Index protocol extensions
- Remove free Swift functions for advance and distance and replace
  them with protocol extension methods:
  - advancedBy(n)
  - advancedBy(n, limit:)
  - distanceTo(end)
- Modernize the Index tests
  - Use StdlibUnittest
  - Test for custom implementation dispatch

Perf impact: No significant changes reported in the
Swift Performance Measurement Tool.

rdar://problem/22085119

Swift SVN r30958
2015-08-03 20:06:44 +00:00
David Farler
91d182154f Explode Algorithm.swift.gyb into separate test files
- Added CollectionType and SequenceType.swift.gyb
- Added Slice.swift.gyb
- Added a template file for shared lazy flatMap code between sequences
  and collections
- Moved some test structs into the respective Check* files in
  StdlibUnittest.
- Slice.swift.gyb is still too slow for Debug-Assert stdlib builds.
  I've added a requirement to use the optimized standard library but
  we should split this file out even further.

rdar://problem/22095015

Swift SVN r30894
2015-08-01 00:34:58 +00:00