Commit Graph

15 Commits

Author SHA1 Message Date
Arnold Schwaighofer
e113ef8c93 Add a mode to test implicit dynamic with private imports 2019-03-20 14:34:01 -07: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
practicalswift
cc852042c9 [gardening] Fix accidental trailing whitespace. 2016-10-29 10:22:58 +02:00
Andrew Trick
2c9cde1c71 [stdlib] fix UnsafePointer.withMemoryRebound(to:capacity:) argument type.
SE-0107 states that UnsafePointer.withMemoryRebound(to:capacity:) should produce
a const UnsafePointer, but the implementation that I committed in Whitney
produces an UnsafeMutablePointer.

As a result Swift 3 accepts code, that we would like to reject:

func takesUInt(_: UnsafeMutablePointer<UInt>) {}
func takesConstUInt(_: UnsafePointer<UInt>) {}

func foo(p: UnsafePointer<Int>) {
  p.withMemoryRebound(to: UInt.self, capacity: 1) {
    takesUInt($0) // <========= implicitly converts to a mutable pointer
    takesConstUInt($0)
  }
}

We would like to reject this in favor of:

func takesUInt(_: UnsafeMutablePointer<UInt>) {}
func takesConstUInt(_: UnsafePointer<UInt>) {}

func foo(p: UnsafePointer<Int>) {
  p.withMemoryRebound(to: UInt.self, capacity: 1) {
    takesUInt(UnsafeMutablePointer(mutating: $0))
    takesConstUInt($0)
  }
}

This looks to me like an experimental change accidentally creeped onto my branch
and it was hard to spot in .gyb code. I needed to write the unit test
in terms of UnsafeMutablePointer in order to use expectType, so didn't
catch this.

rdar://28409842 UnsafePointer.withMemoryRebound(to:capacity:) incorrectly produces a mutable pointer argument
2016-09-21 13:58:51 -07:00
Dmitri Gribenko
39a3a1fb43 Eliminate boilerplate from stdlib tests 2016-09-15 10:20:09 -07:00
Dmitri Gribenko
c9041beea3 Migrate callsites from 'expectNotEmpty()' to 'expectNotNil()' 2016-09-10 20:05:43 -07: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
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
f7eb94bb96 Change the test to actually test the API it advertises to test
Swift SVN r21416
2014-08-22 18:13:44 +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
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
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
aaaedefb63 stdlib/pointer types: give all pointers to objects (COpaquePointer,
Unsafe*Pointer) equivalent APIs, and change the initializer from a bare integer
to require a 'bitPattern:' label.

rdar://17895306


Swift SVN r20979
2014-08-03 21:47:31 +00:00