Commit Graph

102 Commits

Author SHA1 Message Date
Doug Gregor
6a1b7348e0 Make trailing closure syntax match the last parameter, always.
Previously, trailing closures would try to match the first parameter
of (possibly optional) function type that didn't seem to have an
argument already, but in practice this broke when there were
parameters with default arguments before the function parameter.

The new rule is far simpler: a trailing closure matches the last
parameter. Fixes rdar://problem/17965209.

Swift SVN r24898
2015-02-02 19:47:31 +00:00
Maxwell Swadling
16bad7f7d3 [stdlib] improved a unittest error backtrace
Swift SVN r24895
2015-02-02 18:47:46 +00:00
Dmitri Hrybenko
203175909d StdlibUnittest: add a command line option to run specific tests
rdar://19572835

Swift SVN r24841
2015-01-30 04:17:44 +00:00
Joe Pamer
6a70bd085e These changes implement some oft-requested tweaks and fixes to our closure implementation:
- Closures that are comprised of only a single return statement are now considered to be "single expression" closures. (rdar://problem/17550847)
- Unannotated single expression closures with non-void return types can now be used in void contexts. (rdar://problem/17228969)
- Situations where a multi-statement closure's type could not be inferred because of the lack of a return-type annotation are now properly diagnosed. (rdar://problem/17212107)

I also encountered a number of crashers along the way, which should now be fixed.

Swift SVN r24817
2015-01-29 18:48:39 +00:00
Joe Groff
f02ba53d97 Reenable the weak reference runtime tests in weak.mm.
Instead of directly referencing a long-dead constructor from the standard library, put a purpose-built function in StdlibUnittest to feed a Swift object reference to the test C code. rdar://problem/18498737

Swift SVN r24816
2015-01-29 17:49:08 +00:00
Dave Abrahams
574bd0a58d StdlibUnitTest: add pair equality expectation
Swift SVN r24812
2015-01-29 02:05:45 +00:00
Dmitri Hrybenko
ff771d0984 stdlib: use fixed-width Builtin.IntXX types for Swift.Int and UInt
Using the unknown-sized Builtin.Word types complicates producing
compile-time overflow diagnostics.  If we don't know the target Word
size, we don't know if there is an overflow.  But SIL optimizer does not
know the size of Word, this is the point of having the Word type in the
first place.

Also, this opens up more possibilities for optimizations.

rdar://17604532

Swift SVN r24788
2015-01-28 05:22:42 +00:00
Dmitri Hrybenko
bbf79427ac stdlib: remove bitwise operations on Bool
Bitwise operations on Bool are redundant with other logic operations
that stdlib already provides.  The only reason to have them was to avoid
branching in the short-circuiting && and ||.

rdar://19340952

Surprisingly, replacing & and | in the standard library with && and ||
brought performance improvements and no significant performance
regressions:

RecursiveOwnedParameter 1.14
SelectionSort 1.19

Swift SVN r24674
2015-01-23 03:09:55 +00:00
Dmitri Hrybenko
6670bb76ec Rewrite the CMake build system
Swift SVN r24124
2014-12-23 22:15:30 +00:00
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
Dmitri Hrybenko
d56fd34d0c StdlibUnittest: remove redundant initializers for pthread_*_t types
The compiler can generate these automatically now.

Swift SVN r23735
2014-12-05 08:26:41 +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
Dmitri Hrybenko
c57bde235d CMake: add a (disabled) flag for serializing StdlibUnittest
It would speed up testing if it actually worked.

Swift SVN r23175
2014-11-08 04:41:08 +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
Erik Eckstein
b51b3ed123 Mark public compiler intrinsics with // COMPILER_INTRINSIC
I followed Joe's example in Process.swift and used COMPILER_INTRINSIC (and not just INTRINSIC)



Swift SVN r22723
2014-10-14 07:32:03 +00:00
Erik Eckstein
60dcb9a435 Make compiler intrinsics public (part 2).
With the changed SILLinkage and dead function removal of internal functions this is necessary.



Swift SVN r22490
2014-10-03 13:58:50 +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
Dave Abrahams
d8122fd010 [testing] Purge use of mixed-sign arithmetic
Swift SVN r22401
2014-09-30 20:21:00 +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
a3724588cb Fix and expand the AtomicInt test
The previous version of this test was disallowing some thread
interleavings that I did not consider.  See comments in the test for
more details.

Swift SVN r22300
2014-09-26 10:29:56 +00:00
Dmitri Hrybenko
2ab8f0c50b StdlibUnittest: remove debug output from race tests
Swift SVN r22299
2014-09-26 10:29:52 +00:00
Dmitri Hrybenko
1410688b8f StdlibUnittest: add an autorelease pool to the master race thread to
stabilize memory consumption

Swift SVN r22282
2014-09-25 14:10:09 +00:00
Dmitri Hrybenko
83b06926c4 StdlibUnittest: simplify code
Swift SVN r22278
2014-09-25 09:55:58 +00:00
Dave Abrahams
c38e3201b2 [stdlib] Propagate ForwardIndexType docs to models
200 undocumented public APIs remain in core

Swift SVN r22222
2014-09-23 19:20:48 +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
Dmitri Hrybenko
d3be963abf RaceTest: add radar references for bug workarounds
Swift SVN r21876
2014-09-11 16:07:42 +00:00
Dmitri Hrybenko
d68a5c4c98 stdlib: finish implementation of atomics for initializing an ARC
reference, add tests

Swift SVN r21873
2014-09-11 14:52:58 +00:00
Dmitri Hrybenko
756d129ec6 Rename StdlibUnittest.{getPtr -> getPointer}
Swift SVN r21839
2014-09-10 14:41:20 +00:00
Dmitri Hrybenko
b68d147ca1 stdlib/Unmanaged: trap when attempting to create an Unmanaged from a
null pointer

Swift SVN r21838
2014-09-10 14:15:06 +00:00
Dmitri Hrybenko
96d00d70b5 StdlibUnittest: add infrastructure for race tests (see examples)
This will be used to test rdar://18191358

Swift SVN r21836
2014-09-10 11:58:45 +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
Dave Abrahams
06414d842e [stdlib] Add LifetimeTracked to StdlibUnitTest
Swift SVN r21603
2014-08-30 01:54:31 +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
Dmitri Hrybenko
2124857300 Use withUnsafeMutableBufferPointer when mutating the buffer instead of
getting an immutable buffer and casting it

Swift SVN r21415
2014-08-22 17:57:58 +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