Commit Graph

200 Commits

Author SHA1 Message Date
Dmitri Hrybenko
9da0b57178 stdlib: Add an initializer to RangeReplaceableCollectionType from SequenceType
rdar://19815116

Swift SVN r32213
2015-09-24 23:20:13 +00:00
Dmitri Hrybenko
db77b54b3c StdlibUnittest: if the stacktrace is empty, don't print "stacktrace:"
Swift SVN r32057
2015-09-18 01:30:15 +00:00
Dmitri Hrybenko
67944589d6 stdlib: improve index invalidation guarantees for removeFirst()
Slice types that are RangeReplaceable (like ArraySlice) now slice
themselves in removeFirst().  Previously, these types were picking up
the wrong default implementation, and they were going through
replaceRange(), which caused all indices to be invalidated.  The new
implementation preserves all indices.

rdar://22536664

Swift SVN r31918
2015-09-12 04:35:51 +00:00
Arnold Schwaighofer
eb3d5e4d4a Revert "stdlib: Move the darwin String implementation over to use the ICU library."
Revert "Add test cases to exercise the native String vs cocoa buffer String path."
Revert "stdlib: Add back a test I removed"
Revert "stdlib: Fix hasPrefix,hasSuffix tests"
Revert "stdlib: Add documentation for the cached ascii collation tables"

This reverts commit 31493, 31492, 31491, 31490, 31489.

There are linking errors in SwiftExternalProjects (we probably have to link
against libicucore somewhere).

Swift SVN r31543
2015-08-27 21:02:32 +00:00
Arnold Schwaighofer
e1131ce3ee stdlib: Add back a test I removed
Reapply of 31476.

Swift SVN r31491
2015-08-26 15:14:20 +00:00
Arnold Schwaighofer
2d8f29e710 Revert "stdlib: Fix hasPrefix,hasSuffix tests"
Revert "stdlib: Add back a test I removed"
Revert "Add test cases to exercise the native String vs cocoa buffer String path."
Revert "stdlib: Move the darwin String implementation over to use the ICU library."

This reverts commit r31477, r31476, r31475, r31474.

Commit r31474 broke the ASAN build.

Swift SVN r31488
2015-08-26 13:09:03 +00:00
Arnold Schwaighofer
2588f44d83 stdlib: Add back a test I removed
Swift SVN r31476
2015-08-26 03:57:24 +00:00
Dmitri Hrybenko
3f7d64c532 Diagnose invalid arguments for '#if _runtime()'
rdar://problem/20117677

Swift SVN r31336
2015-08-19 16:55:39 +00:00
David Farler
313a4c93c6 Review: Index protocol extensions
- Add Strict/Defaulted Index types to StdlibUnittest
- Test whether a random access index calls its more efficient
  customization by tracking successor calls.
- Fix the RandomAccessIndex.advancedBy(n, limit:) API by de-underscoring
  the limit parameter
- Inline some internal transparent default implementations to their only
  call site
- Attach _RandomAccessAmbiguity type to RandomAccessIndex

rdar://problem/22085119

Swift SVN r30979
2015-08-04 03:13:14 +00:00
Joe Pamer
828eb68e72 Commit DaveA's API changes to 'print', along with the compiler changes necessary to support them.
There's still work left to do. In terms of next steps, there's still rdar://problem/22126141, which covers removing the 'workaround' overloads for print (that prevent bogus overload resolution failures), as well as providing a decent diagnostic when users invoke print with 'appendNewline'.

Swift SVN r30976
2015-08-04 01:57:11 +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
Dave Abrahams
ad43a596bd [stdlib] Retire the old lazy subsystem...
...replacing it with the new, after passing API review!

* The lazy free function has become a property.

* Before we could extend protocols, we lacked a means for value types to
  share implementations, and each new lazy algorithm had to be added to
  each of up to four types: LazySequence, LazyForwardCollection,
  LazyBidirectionalCollection, and LazyRandomAccessCollection. These
  generic adapters hid the usual algorithms by defining their own
  versions that returned new lazy generic adapters. Now users can extend
  just one of two protocols to do the same thing: LazySequenceType or
  LazyCollectionType.

* To avoid making the code duplication worse than it already was, the
  generic adapters mentioned above were used to add the lazy generic
  algorithms around simpler adapters such as MapSequence that just
  provided the basic requirements of SequenceType by applying a
  transformation to some base sequence, resulting in deeply nested
  generic types as shown here. Now, MapSequence is an instance of
  LazySequenceType (and is renamed LazyMapSequence), and thus transmits
  laziness to its algorithms automatically.

* Documentation comments have been rewritten.

* The .array property was retired

* various renamings

* A bunch of Gyb files were retired.

Swift SVN r30902
2015-08-01 03:52:13 +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
Dmitri Hrybenko
d9088afe4b stdlib: add MutableSlice
See doc comments on MutableSlice for more information about what it is.

MutableSlice was one of the reasons to clarify and tighten index
invalidation rules.  After that change, existing MinimalCollection
test types were performing checks that are too strict according to the
model.  Existing algorithms and collections could provide them, but not
MutableSlice.  This commit updates MinimalCollection types to perform
index invalidation checks that correspond to new rules.

Part of rdar://20722366.  This commit adds the type, but does not wire
it up completely yet.

Swift SVN r30839
2015-07-31 03:21:56 +00:00
Dmitri Hrybenko
739cceba3d stdlib: lazy FlattenCollection: don't invoke the closure as frequently
FlattenCollection used to evaluate the closure three times per element.
That's acceptable from the technical standpoint, given its lazy
semantics, but not acceptable in practice.  This commit fixes it to only
evaluate it two times when it is converted into an array.

This commit also improves tests.  The new checks used to fail before the
standard library was fixed.

But there are larger issues with FlattenCollection -- it does not model
CollectionType properly.  See next commit.

Swift SVN r30616
2015-07-25 02:18:12 +00:00
Dmitri Hrybenko
4b008e6f31 stdlib: rename RangeReplaceableCollectionType.splice() to insertContentsOf()
rdar://21972324

Swift SVN r30608
2015-07-25 00:36:39 +00:00
Dmitri Hrybenko
d97ac3e64c stdlib: rename RangeReplaceableCollectionType.extend() to appendContentsOf()
rdar://21972324

Swift SVN r30607
2015-07-25 00:36:37 +00:00
Dmitri Hrybenko
f5de8757e4 stdlib: remove Word and UWord
These types are leftovers from the early pre-1.0 times when Int and UInt
were always 64-bit on all platforms.  They serve no useful purpose
today.  Int and UInt are defined to be word-sized and should be used
instead.

rdar://18693488

Swift SVN r30564
2015-07-24 05:01:32 +00:00
Dmitri Hrybenko
bbed5aae68 StdlibUnittest: fix the definition of a 'slice type'
Swift SVN r30508
2015-07-22 22:13:25 +00:00
Dmitri Hrybenko
0525573de7 stdlib: use syntax sugar for Array
Swift SVN r30489
2015-07-22 04:16:22 +00:00
David Farler
0d1b03086d Add slicing extensions to SequenceType and CollectionType.
rdar://problem/21663830

Add the following new requirements to SequenceType with default implementations:

- dropFirst(n)
- dropLast(n)
- prefix(n)
- suffix(n)
- split(n)

In addition, provide specialized default implementations of these for CollectionTypes with forward, bidirectional, and random-access Index types where possible.

Add the following new requirements to CollectionType with default implementations:

- prefixThrough(n)
- prefixUpTo(n)
- suffixFrom(n)
- split() // isSeparator closure

Add the following convenience APIs:

- dropFirst() -> calls dropFirst(1)
- dropLast() -> calls dropLast(1)

Add a tentative underscored API:

- split() // takes Equatable separator.

Some APIs have undefined behavior when creating slices where the endpoints go beyond the bounds of the underlying collection. This will be fixed later by trapping creation of slices with invalid indices (rdar://problem/21822657).

Swift SVN r30371
2015-07-18 06:51:22 +00:00
Joe Groff
6608221a72 stdlib: Remove _UnitTestArray.
rdar://problem/20246497

Swift SVN r30348
2015-07-18 00:14:28 +00:00
Jordan Rose
aac0342e48 [stdlib] More type annotations to reduce compile time.
The big one, though, is the use of 'lazy' in _masterThreadOneTrial.
Removing it takes the function from 62s to 2s on my machine.
That's rdar://problem/20875936.

Swift SVN r30292
2015-07-17 00:22:03 +00:00
Dmitri Hrybenko
e5e4335fad stdlib: Slice: trap on out-of-bounds indices
rdar://21822657

Swift SVN r30269
2015-07-16 18:22:40 +00:00
Joe Groff
f739f85137 StdlibUnittest: Keep qualified type names in failure output.
The unambiguous qualification is likely desirable to someone figuring out why their tests failed.

Swift SVN r30170
2015-07-13 22:31:37 +00:00
Dmitri Hrybenko
4cfe818c43 StdlibUnittest: extract collection tests into a reusable generic testsuite
Swift SVN r30124
2015-07-12 01:04:38 +00:00
Dmitri Hrybenko
1d38db56da StdlibUnittest: add {Minimal|Default}***MutableCollection types
Swift SVN r30115
2015-07-11 08:48:38 +00:00
Dave Abrahams
9d07acd368 [stdlib] SequenceType's _initializeTo should return the end position
Otherwise, the length of the sequence is in principle lost.  If you know
you have a sequence of less than 100 elements, you still want to know
exactly how many elements you initialized from it.

Swift SVN r30104
2015-07-11 01:43:27 +00:00
Dave Abrahams
6ab88e2ade [stdlibunittest] Add/use checkRandomAccessIndex
Swift SVN r30077
2015-07-10 18:51:19 +00:00
Dave Abrahams
c1f371a5b8 [stdlibunittest] Add checkStrideable
Also, apply it, in a rudimentary way, to our floating point types.

Swift SVN r30068
2015-07-10 14:27:11 +00:00
Dave Abrahams
c2b3005dba [stdlibunittest] Add/use checkComparable that tests laws
Swift SVN r30042
2015-07-09 21:40:58 +00:00
Dave Abrahams
7a614f76fc [stdlibunittest] Add/Use checkBidirectionalIndex
Swift SVN r30022
2015-07-09 17:10:27 +00:00
Dave Abrahams
76ec395dae [stdlibunittest] WIP Adding axiom checking
Check that the expected laws hold for models of Equatable, Hashable,
Incrementable, and ForwardIndexType.

Swift SVN r29988
2015-07-08 20:04:37 +00:00
Dave Abrahams
ef198daa2b [stdlibunittest] Finish threading new trace facility through
Swift SVN r29955
2015-07-08 02:52:27 +00:00
Jordan Rose
1edf9b3ae8 Check access for associated type requirements, too.
This is a straight-up "oops". You could always get to these typealiases via
the protocol, but like the member requirements you should have to say so.

Swift SVN r29952
2015-07-08 00:43:37 +00:00
Dave Abrahams
ce93b0a9e0 [stdlibunittest] Still more de-boilerplating WIP
Swift SVN r29951
2015-07-08 00:28:33 +00:00
Dave Abrahams
70ee2adc84 [stdlibunittest] More de-boilerplating WIP
Step 2.

Swift SVN r29936
2015-07-07 04:54:03 +00:00
Dave Abrahams
9abf32d521 [stdlibunittest] WIP uniformity/de-boilerplating
The way we pass and compose source locations, messages, etc. needs to be
brought under control before too many more tests get written.  This is
the first step.

Swift SVN r29928
2015-07-07 00:46:54 +00:00
Dmitri Hrybenko
4603431bd4 StdlibUnittest: implement more strict checks for using invalid indices
Add a shared buffer to every range replaceable mutable collection to
track logical mutations, and invalidate all indices on every mutation.

Swift SVN r29917
2015-07-06 16:12:03 +00:00
David Farler
402bbd3813 RangeReplaceableCollectionType review changes
- Clean up tests
  - Create API-specific test structures with clearer labels
  - Use `OpaqueValue`s in test collections
  - Make tests non-generic to allow array literal declarations
  - Remove some unused functions
  - Test return values for mutating functions that return a value
  - Add expect* test source locations
- Add _customRemoveLast ad-hoc default implementation for `removeLast`
- Add default implementation for reserveCapacity that does nothing.

Swift SVN r29905
2015-07-03 02:14:22 +00:00
Dmitri Hrybenko
1edcc49ff9 stdlib: remove Slice.Element typealias
It is misleading in generic code.  A testcase that was failing:

  expectEqualType(C.Generator.Element.self, Slice<C>.Element.self)

Swift SVN r29887
2015-07-02 06:44:38 +00:00
David Farler
060b1ab61b Remove redundant MinimalCollection for RangeReplaceable tests
There are usable variants gybbed into StdlibUnittest.

Swift SVN r29864
2015-07-01 23:44:15 +00:00
David Farler
438119d558 Fold ExtensibleCollectionType into RangeRaplaceableCollectionType
ExtensibleCollectionType's operations can all be represented by the
primitive range replacement operation, so fold it into
RangeReplaceableCollectionType.

In addition, provide default implementations of
RangeReplaceableCollectionType's methods.

- New tests added for combinations of (static, generic) calls and
  (default, custom) implementations.
- Mark free Swift functions as unavailable with a message to direct the
  developer to the protocol methods.
- Mark ExtensibleCollectionType as available with a message added to
  direct the developer to the right protocol.

rdar://problem/18220295

Swift SVN r29857
2015-07-01 22:33:04 +00:00
Dmitri Hrybenko
fc0fa96371 stdlib: de-underscore Indexable and add tests for it
Swift SVN r29847
2015-07-01 18:31:31 +00:00
Dmitri Hrybenko
76f5706b50 stdlib: de-underscore the Slice type and add tests for it
Swift SVN r29846
2015-07-01 18:31:29 +00:00
Dmitri Hrybenko
80b1380fe8 stdlib: fold Sliceable into CollectionType and de-underscore SubSequence
Swift SVN r29845
2015-07-01 18:31:25 +00:00
Dave Abrahams
8c855e1ecf [stdlibunittest] automatic LifetimeTracked checking/setup
In setup and teardown, we can initialize and check for leaks

Swift SVN r29789
2015-06-29 20:45:50 +00:00
Dave Abrahams
7aed41190f [stdlibunittest] Automatically reset common test environment
Swift SVN r29787
2015-06-29 20:45:48 +00:00
Dmitri Hrybenko
d3dff3e3a5 stdlib: rename generic parameters from T to Element
... for EmptyGenerator and EmptyCollection.

Part of rdar://21429126

Swift SVN r29622
2015-06-24 20:41:53 +00:00
Dave Abrahams
46e6f767c1 StdlibUnittest: debugDescription for MinimalSequence
Swift SVN r29478
2015-06-18 05:05:09 +00:00