Explicitly skip `expectCrashLater()` tests for WASI, instead of conditionally excluding them from compilation.
In doing so, restored some tests that were wrongly excluded from the WASI tests suite.
This change adds support for WASI in stdlib tests. Some tests that expect a crash to happen had to be disabled, since there's currently no way to observe such crash from a WASI host.
This fix updates various initializers to handle incoming empty buffers
that happen to have a nil base. They should simply create another
buffer with nil base rather than crashing!
It is valid for an Unsafe[Raw]BufferPointer can have a nil base
address. This allows round-tripping with C code that takes a
pointer/length pair and uses `0` as the pointer value.
The original design wrongly assumed that we would use a sentinel value
for empty buffers and was never updated for or tested with the current
design.
Fixes <rdar://problem/47946984> Regression in Foundation.Data's
UnsafeBufferPointer constructor.
The optimized-build behavior of UnsafeBufferPointer bounds/overflow
checking cannot be tested. The standard library always compiles with debug
checking enabled, so the behavior of the optimized test depends on whether
the inlining heuristics decide to inline these methods. To fix this, we need
a way to force @_inlineable UnsafeBufferPointer methods to be emitted inside
the client code, and thereby subject the stdlib implementation to the test
case's compile options.
These subtests were actually meant to test the raw buffer
type itself, not its slice type. So adding an `init(rebasing:)`
does what we want.
Now that the Collection tests are wired up, these test cases will be run on the
slice type automatically. No need to do it here.
Some build configurations seem to be unexpectedly crashing even
in "release" mode. I'm not sure yet why they're hitting an assert.
These sub-tests are affected:
["subscript.get.underflow", "subscript.get.overflow",
"subscript.set.underflow", "subscript.set.overflow",
"subscript.range.get.underflow", "subscript.range.get.overflow",
"subscript.range.set.underflow", "subscript.range.set.overflow"]
Allows converting a raw slice into a zero-based raw buffer,
which is a common operation on flat memory.
Add and update UnsafeRawBufferPointer unit tests.
* Add sliceability tests for Unsafe(Raw)BufferPointer.
Improve the generic sliceability tests to verify that SubSequence indices are
compatible with their parents indices.
* Fix and enable testing stdlib Collection instances.
Top-level entry points fully testing a collection instance:
check${Traversal}Collection
One level of recursion into all slices of the collection instance
O(n^2). (Not combinatorial).
Previously, checkCollection() did nothing. So much of the testing infrastructure was inactive. Now it runs all forward collection tests.
Fixes a bug in subscriptRangeTests.
The UnsafeRawBufferPointer and Data collection testing is disabled and
will be fixed in the following commit.
* Give UnsafeRawBufferPointer a distinct slice type.
SubSequence = RandomAccessSlice<Self>
* Fix raw buffer pointer tests after changing the API
* Add UnsafeRawBuffer(rebasing:) initializers.
Allows converting a raw slice into a zero-based raw buffer,
which is a common operation on flat memory.
Add and update UnsafeRawBufferPointer unit tests.
* Do not run recursive O(n^2) collection slice testing on large collections.
Now, even with collection unit testing wired up, the validation tests
take the same amount of time to execute.
* Add init(rebasing:) to UnsafeBufferPointer.
This is required for consistency with UnsafeRawBufferPointer.
* Update CHANGELOG.md for SE-0138 amendment: UnsafeRawBufferPointer slice type.
The "mutating" keyword should not have been on this API. The example
code in SE-0138 uses it as a nonmutating API.
(The mutating keyword was a temporary workaround that should never
have been carried over to the swift-3.0-branch).
<rdar://28614519> [swift-3.0-branch] Remove "mutating" keyword from Array.withUnsafeBytes
https://github.com/apple/swift-evolution/blob/master/proposals/0138-unsaferawbufferpointer.md
Unsafe[Mutable]RawBufferPointer is a non-owning view over a region of memory as
a Collection of bytes independent of the type of values held in that
memory. Each 8-bit byte in memory is viewed as a `UInt8` value.
Reads and writes on memory via `Unsafe[Mutable]RawBufferPointer` are untyped
operations. Accessing this Collection's bytes does not bind the
underlying memory to `UInt8`. The underlying memory must be bound
to some trivial type whenever it is accessed via a typed operation.
In addition to the `Collection` interface, the following methods from
`Unsafe[Mutable]RawPointer`'s interface to raw memory are
provided with debug mode bounds checks: `load(fromByteOffset:as:)`,
`storeBytes(of:toByteOffset:as:)`, and `copyBytes(from:count:)`.
This is only a view into memory and does not own the memory. Copying a value of
type `UnsafeMutableRawBufferPointer` does not copy the underlying
memory. Assigning an `Unsafe[Mutable]RawBufferPointer` into a value-based
collection, such as `[UInt8]` copies bytes out of memory. Assigning into a
subscript range of UnsafeMutableRawBufferPointer copies into memory.