Commit Graph

72 Commits

Author SHA1 Message Date
Arnold Schwaighofer
b62c6e64ff Codesign validation-test/stdlib 2018-08-10 09:39:09 -07:00
Erik Eckstein
b519d1d873 stdlib: Speed up UTF8View -> Array conversion by using _copyContents 2018-05-08 13:52:05 -07:00
Karoy Lorentey
882462ff8a [stdlib] Array._hash(into:): Include the count as a discriminator value
This makes the hash encoding unambiguous when arrays are hashed in sequence.
2018-04-19 20:05:29 +01:00
Morten Bek Ditlevsen
c9337114d2 [WIP] Conditional conformance to Hashable for Optional, Dictionary and Array types. (#14247)
* Add conditional Hashable conformance to Optional, Dictionary, Array, ArraySlice and ContiguousArray

* Modified hashValue implementations
The hashValues are now calculated similar to the automatically synthesized values when conforming to Hashable.
This entails using _combineHashValues as values of the collections are iterated - as well as calling _mixInt before returning the hash.

* Added FIXMEs as suggested by Max Moiseev

* Use checkHashable to check Hashable conformance

* Use 2 space indentation

* Hashing of Dictionary is now independent of traversal order

* Added a test to proof failure of (previous) wrong implementation of Dictionary hashValue. Unfortunately it does not work.

* Removed '_mixInt' from 'hashValue' implementation of Optional and Array types based on recommendations from lorentey

* Another attempt at detecting bad hashing due to traversal order

* Dictionary Hashable validation tests now detect bad hashing due to dependence on traversal order

* Removed superfluous initial _mixInt call for Dictionary hashValue implementation.

* Add more elements to dictionary in test to increase the number of possible permutations - making it more likely to detect order-dependent hashes

* Added Hashable conformance to CollectionOfOne, EmptyCollection and Range types

* Fix indirect referral to the only member of CollectionOfOne

* Re-added Hashable conformance to Range after merge from master

* Change hashValue based on comment from @lorentey

* Remove tests for conditional Hashable conformance for Range types. This is left for a followup PR

* Added tests for CollectionOfOne and EmptyCollection

* Added conditional conformance fo Equatable and Hashable for DictionaryLiteral. Added tests too.

* Added conditional Equatable and Hashable conformance to Slice

* Use 'elementsEqual' for Slice equality operator

* Fixed documentation comment and indentation

* Fix DictionaryLiteral equality implementation

* Revert "Fix DictionaryLiteral equality implementation"

This reverts commit 7fc1510bc3.

* Fix DictionaryLiteral equality implementation

* Use equalElements(:by:) to compare DictionaryLiteral elements

* Added conditional conformance for Equatable and Hashable to AnyCollection

* Revert "Use 'elementsEqual' for Slice equality operator"

This reverts commit 0ba2278b96.

* Revert "Added conditional Equatable and Hashable conformance to Slice"

This reverts commit 84f9934bb4.

* Added conditional conformance for Equatable and Hashable for ClosedRange
2018-03-23 19:08:38 +00:00
Ben Cohen
7c99c68672 Add test for ArraySlice.popLast 2018-03-02 13:32:27 -08:00
Ben Cohen
072aedcdb7 Use LifetimeTracked for Array.popLast test (#14334) 2018-02-01 19:47:28 -08:00
Lance Parker
276f49af84 Merge pull request #11982 from lancep/comprehensiveArrayTests
[stdlib] Comprehensive array tests
2017-09-20 13:01:59 -07:00
Lance Parker
bd055412d2 Make the reserve capacity test use GT/GE rather than testing for a speicific value 2017-09-20 11:23:42 -07:00
Lance Parker
a386f747ed Removed more occurrences of the incorrect comment 2017-09-19 16:26:36 -07:00
Lance Parker
135b9b0a33 Max's feedback 2017-09-19 16:17:05 -07:00
Lance Parker
f000afea11 Removed debug parameters from build line 2017-09-18 11:55:30 -07:00
Lance Parker
6ff5310260 Moved helpers to a new file 2017-09-18 11:51:59 -07:00
Lance Parker
b484f59202 Iterator tests 2017-09-18 11:51:59 -07:00
Lance Parker
b67f38d940 Killed all the warnings in the Array tests 2017-09-18 11:51:59 -07:00
Lance Parker
36cfba3bfc Array casting tests 2017-09-18 11:51:59 -07:00
Lance Parker
d7a17bcd1f More Array bridging tests 2017-09-18 11:51:59 -07:00
Lance Parker
87e6485a15 Add bridging tests like Dictionary's 2017-09-18 11:51:46 -07:00
Lance Parker
2ae14bbf24 Disable failing test on Linux 2017-09-07 11:09:38 -07:00
Lance Parker
7a37e9ee1d radar in comment 2017-09-06 22:22:04 -07:00
Lance Parker
e06a66587f Use .skip instead of commenting out the test 2017-09-06 10:48:49 -07:00
Lance Parker
787268c412 Disable test that's sometimes failing on Linux 2017-09-05 16:55:36 -07:00
Lance Parker
c049b14bfa Removed useless parts of Array tests 2017-08-30 22:32:07 -06:00
Lance Parker
77b0f39cc2 Max's feedback 2017-08-29 17:23:11 -07:00
Lance Parker
3c8f5fa04a Add COW test for Array 2017-08-28 17:20:18 -07:00
Lance Parker
f42bd011cb Disable ArraySlice.append index test 2017-08-25 10:18:04 -07:00
Lance Parker
f7437689a5 Fix comment from copy/paste 2017-08-23 12:03:40 -07:00
Lance Parker
5847455307 Make index tests more data based 2017-08-23 12:00:17 -07:00
Lance Parker
f17a53468f Remove redundant test 2017-08-21 16:14:58 -07:00
Lance Parker
726fba69ec Remove xfail for ArraySlice/append 2017-08-21 16:07:49 -07:00
Lance Parker
c49b8f98c5 Add index unit tests for Arrays 2017-08-21 13:38:46 -07:00
Erik Eckstein
2be1062cf2 Revert "Disable two stdlib tests in optimization mode."
The problem is fixed, so these tests should pass in optimized mode again.

This reverts commit bdd8626374.
2017-02-20 12:49:18 -08:00
Erik Eckstein
bdd8626374 Disable two stdlib tests in optimization mode.
Until rdar://problem/30579713 is fixed.
2017-02-17 14:28:57 -08:00
Max Moiseev
a552cd45e5 [validation-test] Extracting array and slice types conformance tests
Since these tests take the most time, spliting them into 'one type -
one conformance' pairs to maximize parallelism.

<rdar://problem/30269532>
2017-02-07 11:58:47 -08:00
Max Moiseev
c059b45a0b [validation-test] Splitting Arrays.swift.gyb into multiple files
In order to parallelize tests more and avoid a single long running
bottleneck.

<rdar://problem/30269532>
2017-02-03 17:06:55 -08:00
Ben Cohen
fefc2e40df Migrate _copyContents to be called from UnsafeMutableBufferPointer with checks for overrun. 2017-01-05 11:59:49 -08:00
practicalswift
cc852042c9 [gardening] Fix accidental trailing whitespace. 2016-10-29 10:22:58 +02:00
Andrew Trick
9c729e4c0c SE-0138: UnsafeRawBufferPointer revision.
The withUnsafeMutableBytes closure argument should not be `inout`.

Improve testing, fix comments.

Addresses DaveA's review.
2016-09-25 19:56:21 -07:00
Dmitri Gribenko
243a35cd65 Migrate callsites from 'expectEmpty()' to 'expectNil()' 2016-09-10 20:05:42 -07:00
Xiaodi Wu
f9435b9ce8 [stdlib] Restore MemoryLayout.*(ofValue:) 2016-08-08 10:46:37 -05:00
Dmitri Gribenko
987acd375d stdlib: make tests rely on Array implementation details less 2016-08-07 14:20:36 -07:00
Jordan Rose
f42158b12e Revert "[Sema] ban multi-arguments to tuple coercion" (#3922)
It breaks cases where there really is a single unlabeled argument of tuple type, like this:

  let pairs = [(1, "A"), (2, "B")]
  print(pairs.map { $0.0 })
2016-08-01 19:22:19 -07:00
Daniel Duan
c9b73dacc2 [Sema] ban multi-arguments to tuple coercion
Implements part of SE-0110. Single argument in closures will not be accepted if
there exists explicit type with a number of arguments that's not 1.

```swift
let f: (Int, Int) -> Void = { x in } // this is now an error
```

Note there's a second part of SE-0110 which could be considered additive,
which says one must add an extra pair of parens to specify a single arugment
type that is a tuple:

```swift
let g ((Int, Int)) -> Void = { y in } // y should have type (Int, Int)
```

This patch does not implement that part.
2016-07-31 16:22:57 -07:00
Dmitri Gribenko
bb6c6740ca stdlib: fix a bug in ArraySlice.removeLast() when startIndex != 0
ArraySlice.removeLast() only worked when startIndex was equal to zero.

This change fixes the bug, and uses the proper customization point for
the algorithm.

Fixes SR-1791, rdar://problem/26897658.
2016-07-31 02:04:23 -07:00
Rintaro Ishizaki
c6f4bcd01e [SE-0101] MemoryLayout: Migrate testsuite and benchmarks 2016-07-30 03:11:45 +09:00
Andrew Trick
a18d490d6a Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3773)
* Migrate from `UnsafePointer<Void>` to `UnsafeRawPointer`.

As proposed in SE-0107: UnsafeRawPointer.

`void*` imports as `UnsafeMutableRawPointer`.
`const void*` imports as `UnsafeRawPointer`.

Occurrences of `UnsafePointer<Void>` are replaced with UnsafeRawPointer.

* Migrate overlays from UnsafePointer<Void> to UnsafeRawPointer.

This requires explicit memory binding in several places,
particularly in NSData and CoreAudio.

* Fix a bunch of test cases for Void->Raw migration.

* qsort takes IUO values

* Bridge `Unsafe[Mutable]RawPointer as `void [const] *`.

* Parse #dsohandle as UnsafeMutableRawPointer

* Update a bunch of test cases for Void->Raw migration.

* Trivial fix for the SceneKit test case.

* Add an UnsafeRawPointer self initializer.

This is unfortunately necessary for assignment between types imported from C.

* Tiny simplification of the initializer.
2016-07-26 14:21:15 -07:00
Andrew Trick
0ed9ee8dee Revert "Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3724)"
This reverts commit ece0951924.

This results in lldb failues on linux that I can't readily debug.
Backing out until they can be resolved.
2016-07-26 02:50:57 -07:00
Andrew Trick
ece0951924 Migrate from UnsafePointer<Void> to UnsafeRawPointer. (#3724)
* Migrate from `UnsafePointer<Void>` to `UnsafeRawPointer`.

As proposed in SE-0107: UnsafeRawPointer.

`void*` imports as `UnsafeMutableRawPointer`.
`const void*` imports as `UnsafeRawPointer`.

Occurrences of `UnsafePointer<Void>` are replaced with UnsafeRawPointer.

* Migrate overlays from UnsafePointer<Void> to UnsafeRawPointer.

This requires explicit memory binding in several places,
particularly in NSData and CoreAudio.

* Fix a bunch of test cases for Void->Raw migration.

* qsort takes IUO values

* Bridge `Unsafe[Mutable]RawPointer as `void [const] *`.

* Parse #dsohandle as UnsafeMutableRawPointer

* Update a bunch of test cases for Void->Raw migration.

* Trivial fix for the SceneKit test case.

* Add an UnsafeRawPointer self initializer.

This is unfortunately necessary for assignment between types imported from C.

* Tiny simplification of the initializer.
2016-07-26 02:18:21 -07:00
Dmitri Gribenko
824bccc871 stdlib: change Collection._copyToNativeArrayBuffer() to be defined in terms of public types 2016-07-11 10:54:43 -07:00
Chris Lattner
87db7b4cf2 update validation tests to modern syntax. 2016-07-02 17:10:49 -07:00
rintaro ishizaki
4b51d85abb [test] Add %target-run-simple-swiftgyb
* Utilize %target-run-simple-swiftgyb where possible
2016-06-15 11:49:44 +09:00