Commit Graph

99 Commits

Author SHA1 Message Date
taylor swift
c85880899d implement SE 184: add allocation methods to Unsafe buffer pointers, drop all parameters from deallocation, adjust namings, and add repeated-value assignment methods 2017-11-17 21:28:03 -08:00
Max Moiseev
7322b63c44 [overlay] Fix Foundation extensions to Substring
When a substring gets bridged to NSString, it loses the initial offset,
therefore APIs that accept or return StringIndex ranges should handle
this case explicitly by adding/subtracting the substring start offset.

Fixes <rdar://problem/33873277>
2017-09-27 20:09:01 -07:00
Mishal Shah
c5ff1f2cac Update master to build with Xcode 9 beta 1, OS X 10.13, iOS 11, tvOS 11, and watchOS 4 SDKs. 2017-06-14 16:20:35 -07:00
Ted Kremenek
ef98f2bd2a Merge branch 'master' into ver-4-bump 2017-04-27 23:19:14 -07:00
Max Moiseev
e1f502f6cd Swift 3 compatible String and Substring range subscripts 2017-04-26 12:13:43 -07:00
Max Moiseev
b1898ab768 Porting String APIs to Subtring and fixing some tests 2017-04-25 14:58:06 -07:00
Ted Kremenek
81b00d46ab These tests explicitly need -swift-version 3.
These tests included sources that are
based on Swift 3.  They can be considered to be updated later to Swift 4, but it did not seem critical for what they were testing.
2017-04-22 22:15:15 -07:00
Greg Parker
48ba095382 Revert "[test] Temporarily disable String.completePath() test."
This reverts commit df7ad7cb12.
2017-02-17 19:27:01 -08:00
Robin Kunde
f7c8a9245b SR-3378: Replace deprecated methods addingPercentEscapes(using:) and replacingPercentEscapes(using:) in test/stdlib/NSStringAPI.swift (#6167)
Resolves SR-3378.
2017-01-06 13:43:10 -08:00
Greg Parker
df7ad7cb12 [test] Temporarily disable String.completePath() test. 2016-12-09 02:19:47 -08:00
Dmitri Gribenko
243a35cd65 Migrate callsites from 'expectEmpty()' to 'expectNil()' 2016-09-10 20:05:42 -07:00
Max Moiseev
9fc37efee4 [test] renaming test/1_stdlib to just test/stdlib 2016-09-01 16:51:43 -07:00
Jordan Rose
e83c117c30 [test] Hack: run stdlib tests first to start long-running tests earlier.
This decreases total testing time by over a minute on my old Mac Pro.
It probably has much less effect on systems with fewer cores, but shouldn't
be any worse there.

Swift SVN r22745
2014-10-15 01:30:51 +00:00
Dave Abrahams
156020de19 [stdlib] Rename 'countElements' => 'count'
The name was not only long and unwieldy, but inconsistent with our
conscious decision to avoid the use of "elements" in APIs as mostly
redundant.

Swift SVN r22408
2014-09-30 22:00:26 +00:00
Doug Gregor
3ebf5cb3da Switch the string literal protocols over to initializer requirements.
Swift SVN r22076
2014-09-18 15:48:42 +00:00
Dave Abrahams
1e9e7734f0 Revert "[stdlib] any/all algorithms, keyword for contains"
This reverts r21810 and r21811 due to lack of design consensus

Swift SVN r21880
2014-09-11 17:42:32 +00:00
Dave Abrahams
c467825bc2 [stdlib] any/all algorithms, keyword for contains
Expose any, all on Array and all the Lazy sequence adapters.  Make the
'contains' algorithm that takes a predecate unavailable in favor of
'any', which does the same thing.

Fixes <rdar://problem/18190149> [algorithm] `contains` syntax is ambiguous

Swift SVN r21810
2014-09-09 20:39:39 +00:00
Dmitri Hrybenko
d9a6a95ff9 stdlib/NSString APIs: update test names
Swift SVN r21714
2014-09-04 18:06:41 +00:00
Doug Gregor
eaefb5e2b0 String's NSString API: Replace factory methods with failable initializers.
Addresses rdar://problem/18225788.


Swift SVN r21710
2014-09-04 17:21:33 +00:00
Doug Gregor
692ff2f52a Enable imports of failable initializers by default.
Swift SVN r21699
2014-09-04 06:32:12 +00:00
Dave Abrahams
6c07fb4ad1 [stdlib] Revert UnsafePointer casting change
The syntax being reverted added busywork and noise to the common case
where you want to say "I have the right address, but the wrong type,"
without adding any real safety.

Also it eliminated the ability to write UnsafePointer<T>(otherPointer),
without adding ".self" to T.  Overall, it was not a win.

This reverts commits r21324 and r21342

Swift SVN r21424
2014-08-22 21:53:12 +00:00
Doug Gregor
fe8213eec3 Cope with leading acronyms when turning factory methods into initializers.
This allows us to properly import, e.g., +[NSURL URLWithString] as the
initializer init(string:). Fixes <rdar://problem/16906469>.

Swift SVN r21366
2014-08-21 17:41:25 +00:00
Dave Abrahams
1fb0f889d7 [stdlib] Make UnsafePointer conversions explicit
Previously, it was possible to write Unsafe[Mutable]Pointer(x) and have
Swift deduce the pointee type based on context.  Since reinterpreting
memory is a fundamentally type-unsafe operation, it's better to be
explicit about conversions from Unsafe[Mutable]Pointer<T> to
Unsafe[Mutable]Pointer<U>.  This change is consistent with the move from
reinterpretCast(x) to unsafeBitCast(x, T.self).

Also, we've encoded the operations of explicitly adding or removing
mutability as properties, so that adding mutability can be separated
from wild reinterpretCast'ing, a much more severe form of unsafety.

Swift SVN r21324
2014-08-20 23:15:56 +00:00
Dmitri Hrybenko
e6c586a932 stdlib/NSString APIs on String: add tests for the rest of the APIs
Finally finishes rdar://17002128


Swift SVN r21233
2014-08-15 15:48:35 +00:00
Dmitri Hrybenko
8342c4a211 stdlib/NSString APIs on String: add more tests
Swift SVN r21232
2014-08-15 14:40:32 +00:00
Dmitri Hrybenko
1dbca014c3 stdlib/NSString APIs on String: add more tests
Swift SVN r21231
2014-08-15 11:05:49 +00:00
Dmitri Hrybenko
8cca039e62 StdlibUnittest: rename TestCase to TestSuite since it contains multiple tests
Thanks, Ben!


Swift SVN r21222
2014-08-15 00:09:58 +00:00
Anna Zaks
ca03e527c3 API Notes File: Add the notes generated as the product of the first nullability audit of Foundation
As well as the required test modifications.

Swift SVN r21126
2014-08-09 01:40:48 +00:00
Dmitri Hrybenko
ff8f68f3c6 StdlibUnittest: use builder syntax for 'xfail' and 'skip' annotations
Swift SVN r21106
2014-08-08 13:41:07 +00:00
Dmitri Hrybenko
4fa064696d NSString APIs test: attempt to fix the test on iOS by removing a dependency on
a file in the source tree


Swift SVN r21105
2014-08-08 11:58:56 +00:00
Dmitri Hrybenko
f2436065db StdlibUnittest: run tests out of process
The test harness now can recover after test crashes, allowing:

- check for crashes themselves (without reporting them to the Python lit driver,
  which is about 10x slower -- even if CrashTracer is disabled);

- recover from unexpected test crashes and run the rest of the tests;

- this lays the groundwork for assertions that end the test execution, but
  allow the rest of the tests to run (rdar://17906801).

Note that we don't spawn a fresh process for every test.  We create a child
process and reuse it until it crashes.


Swift SVN r21090
2014-08-07 15:14:57 +00:00
Dmitri Hrybenko
bc144c313e NSString test: disable the problematic test on iOS simulator and iOS 7.*
Swift SVN r21043
2014-08-05 21:24:51 +00:00
Dmitri Hrybenko
dc6df9307e Attempt to fix a test for NSString API on String when run on OS X 10.9
Swift SVN r21041
2014-08-05 15:05:13 +00:00
Dmitri Hrybenko
8c41e1892b stdlib/NSString APIs on String: change stringByRemovingPercentEncoding property
type to be an optional string; add tests


Swift SVN r21021
2014-08-04 18:02:14 +00:00
Dmitri Hrybenko
0e7e26328c stdlib/NSString APIs on String: add more tests
Swift SVN r21019
2014-08-04 17:01:57 +00:00
Dmitri Hrybenko
67de904c15 stdlib/NSString APIs on String: change stringByAppendingPathExtension() to
return an optional String.  This behavior is not documeted, though.


Swift SVN r21016
2014-08-04 16:41:37 +00:00
Dmitri Hrybenko
a75c7a427a stdlib/NSString APIs on String: add more tests and fix a crash in
_countFormatSpecifiers() that was triggered by non-BMP characters in the format
string


Swift SVN r21014
2014-08-04 15:37:58 +00:00
Dmitri Hrybenko
adab0726ff stdlib/NSString APIs on String: add tests for substringWithRange()
Swift SVN r21009
2014-08-04 14:49:07 +00:00
Dmitri Hrybenko
edc664c36f stdlib/NSString APIs on String: change return type of
stringByAddingPercentEncodingWithAllowedCharacters() and
stringByAddingPercentEscapesUsingEncoding() to String?, and add API notes for
NSString to the same effect


Swift SVN r21007
2014-08-04 14:13:46 +00:00
Dmitri Hrybenko
a79339ee8f stdlib/Assert: adopt new names for trapping functions:
assert() / assertionFailure() -- debug mode
precondition() / preconditionFailure() -- debug and release modes
fatalError() -- always traps


Swift SVN r20890
2014-08-01 10:22:23 +00:00
Greg Parker
3add65de36 [test] Fix un-terminated cstring in test stdlib/NSStringAPI.swift.
Swift SVN r20756
2014-07-30 14:11:24 +00:00
Dmitri Hrybenko
ac0d9b8175 stdlib/CGFloat: GYB'ify initializers that convert between CGFloat and
integer types.  Never miss an integer type again.

rdar://17853313

Swift SVN r20751
2014-07-30 11:24:11 +00:00
Dmitri Hrybenko
8db3907d54 NSStringAPI test: allow to pass under iOS simulator
Swift SVN r20704
2014-07-29 22:07:51 +00:00
Dmitri Hrybenko
3e32ff188f stdlib/String: change String.stringByAbbreviatingWithTildeInPath into a
property, to match recent Foundation headers


Swift SVN r20674
2014-07-29 16:08:39 +00:00
Dmitri Hrybenko
98188d1da9 NSString APIs on String: add more tests
Swift SVN r20673
2014-07-29 16:06:36 +00:00
Dmitri Hrybenko
ca07053adc stdlib: rename fatalError() to debugTrap()
Part of rdar://17792445


Swift SVN r20619
2014-07-28 11:14:52 +00:00
Dmitri Hrybenko
5e82e13234 stdlib: NSString APIs on String: more extensive tests for getCString() and
getFileSystemRepresentation()

rdar://17034216


Swift SVN r20617
2014-07-28 09:54:56 +00:00
Dmitri Hrybenko
b204bed0b8 stdlib: NSString APIs on String: add a test that shows getCString() behavior
when supplied a string with unpaired surrogates

rdar://17034216


Swift SVN r20616
2014-07-28 09:13:01 +00:00
Dave Abrahams
31d6f95452 [stdlib] UnsafeBufferPointer: add ".count"
In answering a forum post I noiced that I wanted this and it was
missing.

Also, extensive comments

Also, rename the length: init parameter to count:.  When writing the
comments for the init function it became painfully clear why we use
"count" is better than "length" especially around pointers and memory:
the former is much less easy to mistake for "length in bytes".  Plus
it's consistent with the new ".count" property

Swift SVN r20609
2014-07-28 01:03:09 +00:00
Dmitri Hrybenko
06a9ea552c stdlib/String: fix hasPrefix() and hasSuffix() to perform proper Unicode
comparison

rdar://17498444


Swift SVN r20603
2014-07-27 18:12:02 +00:00