Commit Graph

65 Commits

Author SHA1 Message Date
Dmitri Hrybenko
397d2fb8c3 stdlib: coding style: when colon specifies is-a relationship, we put
spaces on both sides of it

Swift SVN r23935
2014-12-15 06:55:30 +00:00
Chris Lattner
cb8a65e831 Clean up the semantics of 'let' properties in a number of ways:
- We switch to a model where let properties may be "initialized", but never
  reassigned.  Specifically, immutable properties in structs/classes may have
  an init value specified in their declaration (but can then never be reset
  in any init implementation) or not (in which case they must be initialized 
  exactly once on all paths through every init.  This makes a lot more sense 
  for immutability, defines several problems away, and provides a path to
  supporting things like (rdar://16181314)

- We now *never* default initialize an immutable property.  Formerly
  we would default initialize optional let properties to nil, but this
  isn't actually useful, and allows an error of omission with let 
  properties.  

This resolves: <rdar://problem/19035287> let properties should only be initializable, not reassignable
and possibly other radars.





Swift SVN r23779
2014-12-08 20:59:53 +00:00
Maxwell Swadling
55f3289054 Added additional tests and comments to String
Swift SVN r23490
2014-11-20 22:33:13 +00:00
David Farler
14159d942b Use string description in test sequence comparison
Using ObjectIdentifiers on the 32-bit simulator isn't a reliable
comparison method. For the purposes of these tests, it's better to
do a string comparison of the description instead.

rdar://problem/19013004

Swift SVN r23415
2014-11-18 21:55:32 +00:00
Maxwell Swadling
da227795a7 [stdlib-unittest] Added expectEqualsUnordered
Also added isSequenceType function.

Swift SVN r23215
2014-11-11 00:24:19 +00:00
Greg Parker
69399885ce Test: Reconcile crashOutputMatches() with its own test, and test multiple uses.
Swift SVN r23157
2014-11-07 05:25:08 +00:00
Greg Parker
4c1f990ca8 Test: Allow multiple crashOutputMatches() on a single StdlibUnittest test.
Swift SVN r23140
2014-11-06 22:50:07 +00:00
Dave Abrahams
9857aaa1de [StdlibUnittest] Use _UnitTestArray now
This commit decouples StdlibUnittest from many details of
[Contiguous]Array, so tests can give useful feedback even in the
presence of a broken [Contiguous]Array implementation while we refactor.

Unfortunately, it wasn't practical to make _UnitTestArray use a
storage class other than _ContiguousArrayStorage[Base], so we still have
to watch out when making changes there.

Swift SVN r22875
2014-10-22 05:28:23 +00:00
Dave Abrahams
c799f3687c [StdlibUnittest] Try to use ContiguousArray
ContiguousArray is a simpler component, thus less prone to breakage.
Builting the unit testing framework atop broken components is a very bad
idea, so let's not.

This is a reinstatement of an earlier commit, plus changes to make the
validation tests work.

Swift SVN r22867
2014-10-21 22:17:06 +00:00
Dave Abrahams
215929b20e Revert "[StdlibUnittest] Try to use ContiguousArray"
This reverts commit r22769, which broke the validation tests

Swift SVN r22792
2014-10-16 03:46:35 +00:00
Dave Abrahams
cf8e450510 [StdlibUnittest] Try to use ContiguousArray
ContiguousArray is a simpler component, thus less prone to breakage.
Builting the unit testing framework atop broken components is a very bad
idea, so let's not.

Swift SVN r22769
2014-10-15 20:27:55 +00:00
Dmitri Hrybenko
fcb7d40f99 StdlibUnittest: move expectType() predicate to the library
Swift SVN r22416
2014-10-01 01:12:11 +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
Dmitri Hrybenko
41a48f258a StdlibUnittest: add Printable and DebugPrintable testing predicates
Swift SVN r22355
2014-09-29 15:41:01 +00:00
Dmitri Hrybenko
83b06926c4 StdlibUnittest: simplify code
Swift SVN r22278
2014-09-25 09:55:58 +00:00
Dmitri Hrybenko
fbd91f7ac3 Add missing 'public' modifiers in StdlibUnittest
Swift SVN r22216
2014-09-23 13:31:24 +00:00
Erik Eckstein
c16c510167 Set SILLinkage according to visibility.
Now the SILLinkage for functions and global variables is according to the swift visibility (private, internal or public).

In addition, the fact whether a function or global variable is considered as fragile, is kept in a separate flag at SIL level.
Previously the linkage was used for this (e.g. no inlining of less visible functions to more visible functions). But it had no effect,
because everything was public anyway.

For now this isFragile-flag is set for public transparent functions and for everything if a module is compiled with -sil-serialize-all,
i.e. for the stdlib.

For details see <rdar://problem/18201785> Set SILLinkage correctly and better handling of fragile functions.

The benefits of this change are:
*) Enable to eliminate unused private and internal functions
*) It should be possible now to use private in the stdlib
*) The symbol linkage is as one would expect (previously almost all symbols were public).

More details:

Specializations from fragile functions (e.g. from the stdlib) now get linkonce_odr,default
linkage instead of linkonce_odr,hidden, i.e. they have public visibility.
The reason is: if such a function is called from another fragile function (in the same module),
then it has to be visible from a third module, in case the fragile caller is inlined but not
the specialized function.

I had to update lots of test files, because many CHECK-LABEL lines include the linkage, which has changed.

The -sil-serialize-all option is now handled at SILGen and not at the Serializer.
This means that test files in sil format which are compiled with -sil-serialize-all
must have the [fragile] attribute set for all functions and globals.

The -disable-access-control option doesn't help anymore if the accessed module is not compiled
with -sil-serialize-all, because the linker will complain about unresolved symbols.

A final note: I tried to consider all the implications of this change, but it's not a low-risk change.
If you have any comments, please let me know.



Swift SVN r22215
2014-09-23 12:33:18 +00:00
Dmitri Hrybenko
ae8c52969b StdlibUnittest: make testing return-autoreleased optimization reliable
On some platforms (for example, x86_64), the first call to
`objc_autoreleaseReturnValue` will always autorelease because it would
fail to verify the instruction sequence in the caller.  On x86_64
certain PLT entries would be still pointing to the resolver function,
and sniffing the call sequence would fail.

This change adds a "warmup" return-autoreleased sequence to the test
harness.

rdar://18385128

Swift SVN r22127
2014-09-19 14:06:57 +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
8237d2a604 StdlibUnittest: remove compatibility typealias
rdar://18028805

Swift SVN r21627
2014-09-01 09:30:16 +00:00
Greg Parker
121e65cdfc [test] No seriously, don't stop StdlibUnittest when the debugger interrupts select().
Swift SVN r21404
2014-08-22 04:56:18 +00:00
Greg Parker
afb85f012a [test] Don't stop StdlibUnittest when the debugger interrupts select().
Swift SVN r21401
2014-08-22 04:36:53 +00:00
Dmitri Hrybenko
f1c3d879ef StdlibUnittest: add setUp and tearDown functions, which are executed before and
after every test


Swift SVN r21362
2014-08-21 16:56:49 +00:00
Dmitri Hrybenko
61f9b11e5f StdlibUnittest: add expectEqualUnicodeScalars() assertion function for precise
String comparison


Swift SVN r21229
2014-08-15 10:11:31 +00:00
Dmitri Hrybenko
823291e735 StdlibUnittest: add a compatibility typealias to allow PlaygroundLogger to
transition to the new APIs


Swift SVN r21225
2014-08-15 08:11:36 +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
Dmitri Hrybenko
d812966d32 stdlib: remove Optional.hasValue property
rdar://17931456


Swift SVN r21172
2014-08-13 10:51:26 +00:00
Dmitri Hrybenko
3a04e0809f stdlib: add a function to squeeze a number in a given range from a hash value
This function mixes the bits in the hash value, which improves Dictionary
performance for keys with bad hashes.

PrecommitBenchmark changes with greater than 7% difference:

``````````Dictionary2`,```1456.00`,```1508.00`,```1502.00`,````624.00`,````607.00`,````592.00`,`864.00`,``145.9%
``````````Dictionary3`,```1379.00`,```1439.00`,```1408.00`,````585.00`,````567.00`,````552.00`,`827.00`,``149.8%
````````````Histogram`,````850.00`,````849.00`,````851.00`,```1053.00`,```1049.00`,```1048.00`,`199.00`,``-19.0%
````````````````Prims`,```1999.00`,```2005.00`,```2018.00`,```1734.00`,```1689.00`,```1701.00`,`310.00`,```18.4%
``````````StrSplitter`,```2365.00`,```2334.00`,```2316.00`,```1979.00`,```1997.00`,```2000.00`,`337.00`,```17.0%
```````````````TwoSum`,```1551.00`,```1568.00`,```1556.00`,```1771.00`,```1741.00`,```1716.00`,`165.00`,```-9.6%

Regressions are in benchmarks that use `Int` as dictionary key: we are just
doing more work than previously (hashing an `Int` was an identity function).

rdar://17962402


Swift SVN r21142
2014-08-12 12:02:26 +00:00
Dmitri Hrybenko
4b9c318c05 stdlib: correct trap messages for float to integer conversion
rdar://17943841


Swift SVN r21128
2014-08-09 18:02:28 +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
ab8b14f2d5 StdlibUnittest: allow xfail and skip annotations on tests
rdar://17906092


Swift SVN r21040
2014-08-05 15:03:54 +00:00
Dave Abrahams
23ee8d34be [stdlib] Make Array RangeReplaceable test generic
...and uncover memory leaks in the process: <rdar://problem/17892507>

Swift SVN r20936
2014-08-02 01:08:57 +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
Joe Pamer
94dac129d4 Remove the BooleanType conformance from optional types (rdar://problem/17110911)
To limit user confusion when using conditional expressions of type Bool?, we've decided to remove the BooleanType (aka "LogicValue") conformance from optional types. (If users would like to use an expression of type Bool? as a conditional, they'll need to check against nil.)

Note: This change effectively regresses the "case is" pattern over types, since it currently demands a BooleanType conformance. I've filed rdar://problem/17791533 to track reinstating it if necessary.

Swift SVN r20637
2014-07-28 19:20:39 +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
Dmitri Hrybenko
eff383932c stdlib/Character: add Hashable conformance
Swift SVN r20539
2014-07-25 10:32:00 +00:00
Dmitri Hrybenko
a38b282a7b StdlibUnittest: move checkHashable to unit testing library, it is a
utility that is useful in general

Swift SVN r20536
2014-07-25 10:06:22 +00:00
Dmitri Hrybenko
27cbb5a9d5 stdlib/String: change == to perform string comparison after NFD
normalization

There is still some obscure bug with != on NSString, probably caused by
an ill-thought overload somewhere.

Part of rdar://17498444

Swift SVN r20518
2014-07-24 21:36:01 +00:00
Dmitri Hrybenko
2324d843ec StdlibUnittest: demangle names in error output
Swift SVN r20515
2014-07-24 21:19:21 +00:00
Dmitri Hrybenko
c2adafc897 Revert "stdlib/String: change == to perform string comparison after NFD"
This breaks consistency between == comparison and hash value.

Swift SVN r20500
2014-07-24 17:28:40 +00:00
Dmitri Hrybenko
a3d5a8a0de stdlib/String: change == to perform string comparison after NFD
normalization

There is still some obscure bug with != on NSString, probably caused by
an ill-thought overload somewhere.

Part of rdar://17498444

Swift SVN r20495
2014-07-24 16:51:48 +00:00
Dmitri Hrybenko
d14f17beef Change 'getLogicValue()' into a property 'boolValue'; change
'getArrayBoundValue()' into a property 'arrayBoundValue'.

rdar://17156123


Swift SVN r20304
2014-07-22 12:08:10 +00:00
Dave Abrahams
079b5e57ef [stdlib] += no longer appends array elements
+= only extends arrays with another sequence of the same element type.

Fixes <rdar://problem/17151420> The use of the overloaded += operator in
Swift is inconsistent and confusing with Arrays.

Note that this commits generated 3 new radars against the type checker:

  <rdar://problem/17751308>
  <rdar://problem/17750582>
  <rdar://problem/17751359>

Swift SVN r20274
2014-07-21 20:07:13 +00:00
Dave Abrahams
11e196abcf [StdlibUnittest] expectEqualSequence, refactor
Swift SVN r20124
2014-07-18 00:11:43 +00:00
Dave Abrahams
cbcf9aba21 s/LogicValueType/BooleanType/
We're moving toward using that protocol for straight-up Bool types

Swift SVN r19884
2014-07-12 18:58:18 +00:00
Dave Abrahams
6d1095f44e Protocol names end in "Type," "ible," or "able"
Mechanically add "Type" to the end of any protocol names that don't end
in "Type," "ible," or "able."  Also, drop "Type" from the end of any
associated type names, except for those of the *LiteralConvertible
protocols.

There are obvious improvements to make in some of these names, which can
be handled with separate commits.

Fixes <rdar://problem/17165920> Protocols `Integer` etc should get
uglier names.

Swift SVN r19883
2014-07-12 17:29:57 +00:00