Commit Graph

547 Commits

Author SHA1 Message Date
Karoy Lorentey
5ab67115dc [test] MinimalHashable types: Replace hashValue hook with hash(into:) 2018-04-20 19:22:19 +01:00
Karoy Lorentey
8d18d1a55d [test] checkHashable: Check that unequal values produce different hashes
This is safe to do with hash(into:), because random hash collisions can be eliminated with awesome certainty by trying a number of different hash seeds. (Unless there is a weakness in SipHash.)

In some cases, we intentionally want hashing to produce looser equivalency classes than equality — to let those cases keep working, add an optional hashEqualityOracle parameter.

Review usages of checkHashable and add hash oracles as needed.
2018-04-20 19:22:19 +01:00
Karoy Lorentey
d55b14b193 [test] MinimalHashable{Value,Class}: Implement CustomStringConvertible
This makes it easier to understand failure traces in test logs.
2018-04-20 17:42:02 +01:00
Karoy Lorentey
f873a5193e [test] MinimalTypes: Move ==, < definitions into the corresponding type (NFC) 2018-04-20 17:40:42 +01:00
Michael Ilseman
c4614a9208 [test] De-gyb stdlib unittest.
StdlibUnittest uses gyb to avoid duplicating many source-context
arguments. However, this means that any test that wishes to add new
expect helpers has to also be gybbed. Given that this structure hasn't
changed in years, and we should have a real language support
eventually, de-gyb it.
2018-04-19 13:06:14 -07:00
Michael Ilseman
cdfeb88cfe [string] Simplify creation logic, especially for C strings.
Streamline internal String creation. Previously, everything funneled
into a single generic function, however, every single call of the
generic funnel had relevant specific information that could be used
for a more efficient algorithm.

In preparation for efficiently forming small strings, refactor this
logic into a handful of more specialized subroutines to preserve more
specific information from the callers.
2018-03-27 10:49:02 -07:00
Karoy Lorentey
3e90284883 [test] Disable hash randomization using environment variables
The hash seed is not settable at runtime anymore; update lit config to set the SWIFT_DETERMINISTIC_HASHING environment variable instead.
2018-03-13 16:15:09 +00:00
Karoy Lorentey
ab0c74b85c Merge pull request #14913 from lorentey/resilient-hashing
Switch to a resilient hashing interface, currently implementing SipHash-1-3.
Compiler-synthesized Hashable conformances still use the old _combineHashValues interface for now.
2018-03-09 19:57:03 +00:00
Karoy Lorentey
8cf5bc8bdc [stdlib] Switch to using SipHash-1-3 as the standard hash function
Beyond switching hashing algorithms, this also enables per-execution hash seeds, fulfilling a long-standing prophecy in Hashable’s documentation.

To reduce the possibility of random test failures, StdlibUnittest’s TestSuite overrides the random hash seed on initialization.

rdar://problem/24109692
rdar://problem/35052153
2018-03-09 14:48:59 +00:00
Sho Ikeda
6263b582a0 [stdlib/private][gardening] Prefer os(macOS) over os(OSX) 2018-03-09 22:41:55 +09:00
Ben Cohen
9ee856f386 [stdlib][WIP] Eliminate (Closed)CountableRange using conditional conformance (#13342)
* Make Range conditionally a Collection

* Convert ClosedRange to conditionally a collection

* De-gyb Range/ClosedRange, refactoring some methods.

* Remove use of Countable{Closed}Range from stdlib

* Remove Countable use from Foundation

* Fix test errors and warnings resulting from Range/CountableRange collapse

* fix prespecialize test for new mangling

* Update CoreAudio use of CountableRange

* Update SwiftSyntax use of CountableRange

* Restore ClosedRange.Index: Hashable conformance

* Move fixed typechecker slowness test for array-of-ranges from slow to fast, yay

* Apply Doug's patch to loosen test to just check for error
2018-02-01 20:59:28 -08:00
Michael Gottesman
5f3dfcfa36 [stdlibunittest] Update getMetadataKindOf for +0 parameters.
rdar://34222540
2018-01-23 16:04:34 -08:00
Arsen Gasparyan
c4c1589b84 Make expectCrash(executing:_) safer 2017-12-14 15:31:30 +03:00
Arsen Gasparyan
5d6935af04 Rename param name in expectCrash function 2017-12-13 21:23:33 +03:00
Arsen Gasparyan
a6d2c2f05d Add expectCrash function to StdlibUnittest 2017-12-13 12:16:25 +03: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
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
Ben Cohen
35452c2e62 [stdlib] Remove _Strideable protocol 2017-11-16 13:38:24 -08:00
Greg Parker
58c9b45c78 [runtime] Clean up symbols in StdlibUnittest and the internal leak checker.
* Export fewer symbols.
* Prefix exported but not-public symbols with `_swift_`.
2017-10-24 13:13:43 -07:00
Roman Levenstein
5047e1b475 Enable the serialization of sil_vtables by default and completely remove the -sil-serialize-vtables option
Only sil_vtables of public classes with fixed layout are serialized.
2017-10-21 11:36:12 -07:00
Roman Levenstein
48d9b99675 Remove -sil-serialize-witness-tables flag completely
The functionality is always enabled now and there is no need to have a dedicated flag for it.
2017-10-20 19:45:29 -07:00
Roman Levenstein
5e67f755e0 Remove the -sil-serialize-all option 2017-10-04 14:20:53 -07:00
Slava Pestov
c272d41e2f Re-apply "SIL: Remove special meaning for @_semantics("stdlib_binary_only")"
With -sil-serialize-all gone, this no longer means anything; just
don't declare the function as @_inlineable instead.

Fixes <rdar://problem/34564380>.
2017-10-04 14:07:52 -07:00
Jordan Rose
aab5f7aa4f Revert "SIL: Remove special meaning for @_semantics("stdlib_binary_only")" (#12270)
It still affects StdlibUnittest, which is still using -sil-serialize-all.
2017-10-04 12:49:21 -07:00
Slava Pestov
0fad13eeba SIL: Remove special meaning for @_semantics("stdlib_binary_only")
With -sil-serialize-all gone, this no longer means anything; just
don't declare the function as @_inlineable instead.

Fixes <rdar://problem/34564380>.
2017-10-03 13:48:22 -07:00
Doug Gregor
52eb618abc [Collections] Constrain Indices type to Collection.
Make the Indices types conform to the appropriate Collection protocol:
* Collection.Indices: Collection
* BidirectionalCollection.Indices: BidirectionalCollection
* RandomAccessCollection.Indices: RandomAccessCollection
2017-10-01 15:08:22 -07:00
Doug Gregor
6b51806b54 [SE-0157] Make *Collection.SubSequence conform to corresponding *Collection.
Introduce (recursive) constraints that make the *Collection constraint
of SubSequence match that of its enclosing *Collection, e.g.,
MutableCollection.SubSequence conforms to MutableCollection.

Fixes rdar://problem/20715031 and more of SR-3453.
2017-10-01 15:08:22 -07:00
Doug Gregor
e5f893bc59 [Sequence] Make Sequence.SubSequence conform to Sequence.
Addressed ABI FIXME’s #4, #5, #104 and #105, making Sequence’s
SubSequence conform to Sequence, with the same element type, and for
which the SubSequence of a SubSequence is the same SubSequence.

Fixes SR-318 / rdar://problem/31418206.
2017-10-01 15:08:22 -07:00
Calvin Hill
aee81d272f Add Initial platform support for Haiku. (#11583) 2017-09-22 21:06:56 -04:00
Doug Gregor
0793f6c8c5 Revert "[Sequence] Make Sequence.SubSequence conform to Sequence."
This reverts commit 7dc8737c9c.
2017-09-14 09:12:56 -07:00
Doug Gregor
7dc8737c9c [Sequence] Make Sequence.SubSequence conform to Sequence.
Addressed ABI FIXME’s #4, #5, #104 and #105, making Sequence’s
SubSequence conform to Sequence, with the same element type, and for
which the SubSequence of a SubSequence is the same SubSequence.

Fixes SR-318 / rdar://problem/31418206.
2017-09-12 06:52:01 -07:00
Harlan
ade67ca899 [Syntax] Swift libSyntax API (#11320)
* Create Swift libSyntax API

This patch is an initial implementation of the Swift libSyntax API. It
aims to provide all features of the C++ API but exposed to Swift.

It currently resides in SwiftExperimental and will likely exist in a
molten state for a while.

* Only build SwiftSyntax on macOS
2017-08-14 16:47:48 -07:00
Michael Ilseman
6cb48529a9 [stdlib] Refactor out StdlibUnittest SPI from the stdlib.
Move _lines and _split out of the standard library and into
StdlibUnittest, which is why they were there in the first place. NFC.
2017-07-26 15:58:04 -07:00
Michael Gottesman
ec5a92fd04 Disable some tests this time for real. 2017-07-21 13:14:18 -07:00
swift-ci
92898618cb Merge pull request #10982 from apple/stdlib-swift4-modernization 2017-07-20 18:56:23 -07:00
Michael Gottesman
ab6a4f5249 Disable some failing tests.
rdar://33358110
2017-07-19 16:25:39 -07:00
Dave Abrahams
c497969987 [stdlib] Swift4 Modernizations Compatible with Swift 3.2 2017-07-14 17:54:33 -07:00
Robert Widmann
0cf1b52452 Treat Cygwin as a separate OS
Cygwin is considered a distinct target with a distinct ABI, environment
conditions, and data types.  Though the goal of the project is
native Windows integration with UNIX-likes, that is not compatible with
the idea that the platform can be ignored as Win-like enough to have the
existing os(Windows) condition apply.
2017-06-28 13:31:05 -07:00
Jordan Rose
2b415a3848 [StdlibUnittest] Avoid serializing references to ObjC runtime APIs.
Specifically, objc_setUncaughtExceptionHandler, whose nullability is
now annotated in Swift 4 mode when using the Xcode 9 SDKs. That means
it has a different signature in Swift 3 and Swift 4 mode, which means
that references from SIL will fail when deserialized in the other
mode. (The recovery support added in earlier commits doesn't cover
serialized SIL.)

This resulted in crashes when building with
-build-serialized-stdlib-unittest, which enables -sil-serialize-all /
"magic performance mode" when building the StdlibUnittest module like
it does the standard libarry.

None of this affects developer code, because developer code doesn't
serialize anything (if they're playing by the rules).
2017-06-15 11:14:12 -07:00
Dave Abrahams
2cb11675cf Merge pull request #9531 from apple/core-team-resolution-2017-05-10.1
Implementing resolutions of core team meeting 2017-05-10
2017-05-12 13:15:08 -07:00
Dave Abrahams
ddf7ad517f UnicodeScalar => Unicode.Scalar 2017-05-11 15:23:25 -07:00
Ben Cohen
c03b14e93f Revert "Merge pull request #9379 from airspeedswift/redundant-where"
95e9681d10
2017-05-11 11:43:54 -07:00
ben-cohen
e4af80d39c Remove redudant constraints to supress warnings 2017-05-07 11:30:01 -07:00
Greg Parker
9c80b23953 [stdlib] Make StdlibUnittest nullability-agnostic for ObjC runtime functions. 2017-04-28 18:08:41 -07:00
Max Moiseev
a2d3914e02 Disambiguating expectEqual for String/Substring 2017-04-26 12:31:22 -07:00
Max Moiseev
b1898ab768 Porting String APIs to Subtring and fixing some tests 2017-04-25 14:58:06 -07:00
Doug Gregor
13f6c79b2a [Stdlib] For Collections, the SubSequence of a Subsequence is SubSequence.
Part of ABI FIXME #99, this gives us some nice consistency that
ensures that slicing a SubSequence gives us another SubSequence. There
are two source-compatibility implications to this change:

* Collections now need to satisfy this property, which could not be
  expressed in Swift 3. There might be some Collections that don't
  satisfy this property, and will break with the Swift 4 compiler
  *even in Swift 3 compatibility mode*. Case in point...
* The Lazy collection types were formulated as a lazy collection of
  the base slice (e.g., LazyCollection<ArraySlice<T>>) rather than as
  a slice of the lazy collection (e.g.,
  Slice<LazyCollection<Array<T>>). The former doesn't meet the new
  requirements, so change to the latter.
2017-04-20 13:18:32 -07:00
Doug Gregor
29a15ce402 [Stdlib] Apply SE-0142 to fix ABI FIXME #92, part of ABI FIXME #99. 2017-04-19 23:15:33 -07:00
Doug Gregor
0dd1da35d4 [Stdlib] Use SE-0142 to address ABI FIXMEs #68, #89, #90, #91.
Address ABI FIXME #68 by using same-type constraints directly on an
associated type to describe the requirements on the Indices associated
type of the Collection protocol. ABI FIXMEs #89, #90, #91 are all in
StdlibUnittest, and provoke warnings once #68 is fixed, but it's nice
to clear them out.

Fixes SR-2121.
2017-04-19 23:15:32 -07:00
Max Moiseev
a3a3351bd8 Merge branch 'master' into new-integer-protocols 2017-04-10 15:41:13 -07:00