mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[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>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("ArraySliceWithNonZeroStartIndex_MutableRandomAccessCollectionRef")
|
||||
|
||||
|
||||
func ArraySliceWithNonZeroStartIndex<T>(_ elements: [T]) -> ArraySlice<T> {
|
||||
var r = ArraySlice<T>(_startIndex: 1000)
|
||||
r.append(contentsOf: elements)
|
||||
expectEqual(1000, r.startIndex)
|
||||
return r
|
||||
}
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
|
||||
// Test MutableCollectionType conformance with reference type elements.
|
||||
tests.addMutableRandomAccessCollectionTests(
|
||||
"ArraySliceWithNonZeroStartIndex.",
|
||||
makeCollection: { (elements: [LifetimeTracked]) in
|
||||
return ArraySliceWithNonZeroStartIndex(elements)
|
||||
},
|
||||
wrapValue: { (element: OpaqueValue<Int>) in
|
||||
LifetimeTracked(element.value, identity: element.identity)
|
||||
},
|
||||
extractValue: { (element: LifetimeTracked) in
|
||||
OpaqueValue(element.value, identity: element.identity)
|
||||
},
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ArraySliceWithNonZeroStartIndex(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
makeCollectionOfComparable: { (elements: [MinimalComparableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ArraySliceWithNonZeroStartIndex(elements)
|
||||
},
|
||||
wrapValueIntoComparable: identityComp,
|
||||
extractValueFromComparable: identityComp,
|
||||
resiliencyChecks: resiliencyChecks,
|
||||
withUnsafeMutableBufferPointerIsSupported: true,
|
||||
isFixedLengthCollection: false)
|
||||
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("ArraySliceWithNonZeroStartIndex_MutableRandomAccessCollectionVal")
|
||||
|
||||
|
||||
func ArraySliceWithNonZeroStartIndex<T>(_ elements: [T]) -> ArraySlice<T> {
|
||||
var r = ArraySlice<T>(_startIndex: 1000)
|
||||
r.append(contentsOf: elements)
|
||||
expectEqual(1000, r.startIndex)
|
||||
return r
|
||||
}
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
|
||||
// Test MutableCollectionType conformance with value type elements.
|
||||
tests.addMutableRandomAccessCollectionTests(
|
||||
"ArraySliceWithNonZeroStartIndex.",
|
||||
makeCollection: { (elements: [OpaqueValue<Int>]) in
|
||||
return ArraySliceWithNonZeroStartIndex(elements)
|
||||
},
|
||||
wrapValue: identity,
|
||||
extractValue: identity,
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
return ArraySliceWithNonZeroStartIndex(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
makeCollectionOfComparable: { (elements: [MinimalComparableValue]) in
|
||||
return ArraySliceWithNonZeroStartIndex(elements)
|
||||
},
|
||||
wrapValueIntoComparable: identityComp,
|
||||
extractValueFromComparable: identityComp,
|
||||
resiliencyChecks: resiliencyChecks,
|
||||
withUnsafeMutableBufferPointerIsSupported: true,
|
||||
isFixedLengthCollection: false)
|
||||
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("ArraySliceWithNonZeroStartIndex_RangeReplaceableRandomAccessCollectionRef")
|
||||
|
||||
|
||||
func ArraySliceWithNonZeroStartIndex<T>(_ elements: [T]) -> ArraySlice<T> {
|
||||
var r = ArraySlice<T>(_startIndex: 1000)
|
||||
r.append(contentsOf: elements)
|
||||
expectEqual(1000, r.startIndex)
|
||||
return r
|
||||
}
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
|
||||
// Test RangeReplaceableCollectionType conformance with reference type elements.
|
||||
tests.addRangeReplaceableRandomAccessSliceTests(
|
||||
"ArraySliceWithNonZeroStartIndex.",
|
||||
makeCollection: { (elements: [LifetimeTracked]) in
|
||||
return ArraySliceWithNonZeroStartIndex(elements)
|
||||
},
|
||||
wrapValue: { (element: OpaqueValue<Int>) in LifetimeTracked(element.value) },
|
||||
extractValue: { (element: LifetimeTracked) in OpaqueValue(element.value) },
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ArraySliceWithNonZeroStartIndex(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
resiliencyChecks: resiliencyChecks)
|
||||
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("ArraySliceWithNonZeroStartIndex_RangeReplaceableRandomAccessCollectionVal")
|
||||
|
||||
|
||||
func ArraySliceWithNonZeroStartIndex<T>(_ elements: [T]) -> ArraySlice<T> {
|
||||
var r = ArraySlice<T>(_startIndex: 1000)
|
||||
r.append(contentsOf: elements)
|
||||
expectEqual(1000, r.startIndex)
|
||||
return r
|
||||
}
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
|
||||
// Test RangeReplaceableCollectionType conformance with value type elements.
|
||||
tests.addRangeReplaceableRandomAccessSliceTests(
|
||||
"ArraySliceWithNonZeroStartIndex.",
|
||||
makeCollection: { (elements: [OpaqueValue<Int>]) in
|
||||
return ArraySliceWithNonZeroStartIndex(elements)
|
||||
},
|
||||
wrapValue: identity,
|
||||
extractValue: identity,
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
return ArraySliceWithNonZeroStartIndex(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
resiliencyChecks: resiliencyChecks)
|
||||
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("ArraySlice_MutableRandomAccessCollectionRef")
|
||||
|
||||
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
|
||||
// Test MutableCollectionType conformance with reference type elements.
|
||||
tests.addMutableRandomAccessCollectionTests(
|
||||
"ArraySlice.",
|
||||
makeCollection: { (elements: [LifetimeTracked]) in
|
||||
return ArraySlice(elements)
|
||||
},
|
||||
wrapValue: { (element: OpaqueValue<Int>) in
|
||||
LifetimeTracked(element.value, identity: element.identity)
|
||||
},
|
||||
extractValue: { (element: LifetimeTracked) in
|
||||
OpaqueValue(element.value, identity: element.identity)
|
||||
},
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ArraySlice(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
makeCollectionOfComparable: { (elements: [MinimalComparableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ArraySlice(elements)
|
||||
},
|
||||
wrapValueIntoComparable: identityComp,
|
||||
extractValueFromComparable: identityComp,
|
||||
resiliencyChecks: resiliencyChecks,
|
||||
withUnsafeMutableBufferPointerIsSupported: true,
|
||||
isFixedLengthCollection: false)
|
||||
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("ArraySlice_MutableRandomAccessCollectionVal")
|
||||
|
||||
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
|
||||
// Test MutableCollectionType conformance with value type elements.
|
||||
tests.addMutableRandomAccessCollectionTests(
|
||||
"ArraySlice.",
|
||||
makeCollection: { (elements: [OpaqueValue<Int>]) in
|
||||
return ArraySlice(elements)
|
||||
},
|
||||
wrapValue: identity,
|
||||
extractValue: identity,
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
return ArraySlice(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
makeCollectionOfComparable: { (elements: [MinimalComparableValue]) in
|
||||
return ArraySlice(elements)
|
||||
},
|
||||
wrapValueIntoComparable: identityComp,
|
||||
extractValueFromComparable: identityComp,
|
||||
resiliencyChecks: resiliencyChecks,
|
||||
withUnsafeMutableBufferPointerIsSupported: true,
|
||||
isFixedLengthCollection: false)
|
||||
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("ArraySlice_RangeReplaceableRandomAccessCollectionRef")
|
||||
|
||||
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
|
||||
// Test RangeReplaceableCollectionType conformance with reference type elements.
|
||||
tests.addRangeReplaceableRandomAccessSliceTests(
|
||||
"ArraySlice.",
|
||||
makeCollection: { (elements: [LifetimeTracked]) in
|
||||
return ArraySlice(elements)
|
||||
},
|
||||
wrapValue: { (element: OpaqueValue<Int>) in LifetimeTracked(element.value) },
|
||||
extractValue: { (element: LifetimeTracked) in OpaqueValue(element.value) },
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ArraySlice(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
resiliencyChecks: resiliencyChecks)
|
||||
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("ArraySlice_RangeReplaceableRandomAccessCollectionVal")
|
||||
|
||||
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
|
||||
// Test RangeReplaceableCollectionType conformance with value type elements.
|
||||
tests.addRangeReplaceableRandomAccessSliceTests(
|
||||
"ArraySlice.",
|
||||
makeCollection: { (elements: [OpaqueValue<Int>]) in
|
||||
return ArraySlice(elements)
|
||||
},
|
||||
wrapValue: identity,
|
||||
extractValue: identity,
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
return ArraySlice(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
resiliencyChecks: resiliencyChecks)
|
||||
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("Array_MutableRandomAccessCollectionRef")
|
||||
|
||||
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
|
||||
// Test MutableCollectionType conformance with reference type elements.
|
||||
tests.addMutableRandomAccessCollectionTests(
|
||||
"Array.",
|
||||
makeCollection: { (elements: [LifetimeTracked]) in
|
||||
return Array(elements)
|
||||
},
|
||||
wrapValue: { (element: OpaqueValue<Int>) in
|
||||
LifetimeTracked(element.value, identity: element.identity)
|
||||
},
|
||||
extractValue: { (element: LifetimeTracked) in
|
||||
OpaqueValue(element.value, identity: element.identity)
|
||||
},
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return Array(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
makeCollectionOfComparable: { (elements: [MinimalComparableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return Array(elements)
|
||||
},
|
||||
wrapValueIntoComparable: identityComp,
|
||||
extractValueFromComparable: identityComp,
|
||||
resiliencyChecks: resiliencyChecks,
|
||||
withUnsafeMutableBufferPointerIsSupported: true,
|
||||
isFixedLengthCollection: false)
|
||||
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("Array_MutableRandomAccessCollectionVal")
|
||||
|
||||
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
|
||||
// Test MutableCollectionType conformance with value type elements.
|
||||
tests.addMutableRandomAccessCollectionTests(
|
||||
"Array.",
|
||||
makeCollection: { (elements: [OpaqueValue<Int>]) in
|
||||
return Array(elements)
|
||||
},
|
||||
wrapValue: identity,
|
||||
extractValue: identity,
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
return Array(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
makeCollectionOfComparable: { (elements: [MinimalComparableValue]) in
|
||||
return Array(elements)
|
||||
},
|
||||
wrapValueIntoComparable: identityComp,
|
||||
extractValueFromComparable: identityComp,
|
||||
resiliencyChecks: resiliencyChecks,
|
||||
withUnsafeMutableBufferPointerIsSupported: true,
|
||||
isFixedLengthCollection: false)
|
||||
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("Array_RangeReplaceableRandomAccessCollectionRef")
|
||||
|
||||
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
|
||||
// Test RangeReplaceableCollectionType conformance with reference type elements.
|
||||
tests.addRangeReplaceableRandomAccessCollectionTests(
|
||||
"Array.",
|
||||
makeCollection: { (elements: [LifetimeTracked]) in
|
||||
return Array(elements)
|
||||
},
|
||||
wrapValue: { (element: OpaqueValue<Int>) in LifetimeTracked(element.value) },
|
||||
extractValue: { (element: LifetimeTracked) in OpaqueValue(element.value) },
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return Array(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
resiliencyChecks: resiliencyChecks)
|
||||
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("Array_RangeReplaceableRandomAccessCollectionVal")
|
||||
|
||||
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
|
||||
// Test RangeReplaceableCollectionType conformance with value type elements.
|
||||
tests.addRangeReplaceableRandomAccessCollectionTests(
|
||||
"Array.",
|
||||
makeCollection: { (elements: [OpaqueValue<Int>]) in
|
||||
return Array(elements)
|
||||
},
|
||||
wrapValue: identity,
|
||||
extractValue: identity,
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
return Array(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
resiliencyChecks: resiliencyChecks)
|
||||
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("ContiguousArray_MutableRandomAccessCollectionRef")
|
||||
|
||||
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
|
||||
// Test MutableCollectionType conformance with reference type elements.
|
||||
tests.addMutableRandomAccessCollectionTests(
|
||||
"ContiguousArray.",
|
||||
makeCollection: { (elements: [LifetimeTracked]) in
|
||||
return ContiguousArray(elements)
|
||||
},
|
||||
wrapValue: { (element: OpaqueValue<Int>) in
|
||||
LifetimeTracked(element.value, identity: element.identity)
|
||||
},
|
||||
extractValue: { (element: LifetimeTracked) in
|
||||
OpaqueValue(element.value, identity: element.identity)
|
||||
},
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ContiguousArray(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
makeCollectionOfComparable: { (elements: [MinimalComparableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ContiguousArray(elements)
|
||||
},
|
||||
wrapValueIntoComparable: identityComp,
|
||||
extractValueFromComparable: identityComp,
|
||||
resiliencyChecks: resiliencyChecks,
|
||||
withUnsafeMutableBufferPointerIsSupported: true,
|
||||
isFixedLengthCollection: false)
|
||||
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("ContiguousArray_MutableRandomAccessCollectionVal")
|
||||
|
||||
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
|
||||
// Test MutableCollectionType conformance with value type elements.
|
||||
tests.addMutableRandomAccessCollectionTests(
|
||||
"ContiguousArray.",
|
||||
makeCollection: { (elements: [OpaqueValue<Int>]) in
|
||||
return ContiguousArray(elements)
|
||||
},
|
||||
wrapValue: identity,
|
||||
extractValue: identity,
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
return ContiguousArray(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
makeCollectionOfComparable: { (elements: [MinimalComparableValue]) in
|
||||
return ContiguousArray(elements)
|
||||
},
|
||||
wrapValueIntoComparable: identityComp,
|
||||
extractValueFromComparable: identityComp,
|
||||
resiliencyChecks: resiliencyChecks,
|
||||
withUnsafeMutableBufferPointerIsSupported: true,
|
||||
isFixedLengthCollection: false)
|
||||
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("ContiguousArray_RangeReplaceableRandomAccessCollectionRef")
|
||||
|
||||
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
|
||||
// Test RangeReplaceableCollectionType conformance with reference type elements.
|
||||
tests.addRangeReplaceableRandomAccessCollectionTests(
|
||||
"ContiguousArray.",
|
||||
makeCollection: { (elements: [LifetimeTracked]) in
|
||||
return ContiguousArray(elements)
|
||||
},
|
||||
wrapValue: { (element: OpaqueValue<Int>) in LifetimeTracked(element.value) },
|
||||
extractValue: { (element: LifetimeTracked) in OpaqueValue(element.value) },
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ContiguousArray(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
resiliencyChecks: resiliencyChecks)
|
||||
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("ContiguousArray_RangeReplaceableRandomAccessCollectionVal")
|
||||
|
||||
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
|
||||
// Test RangeReplaceableCollectionType conformance with value type elements.
|
||||
tests.addRangeReplaceableRandomAccessCollectionTests(
|
||||
"ContiguousArray.",
|
||||
makeCollection: { (elements: [OpaqueValue<Int>]) in
|
||||
return ContiguousArray(elements)
|
||||
},
|
||||
wrapValue: identity,
|
||||
extractValue: identity,
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
return ContiguousArray(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
resiliencyChecks: resiliencyChecks)
|
||||
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
@@ -0,0 +1,144 @@
|
||||
%{
|
||||
# This is a template for validation-test/stdlib/Array/*.swift
|
||||
#
|
||||
# Run it as follows:
|
||||
# cd validation-test/stdlib/Array
|
||||
# ../../../utils/gyb --line-directive="" Inputs/ArrayConformanceTests.swift.gyb | ../../../utils/split_file.py
|
||||
}%
|
||||
|
||||
% all_array_types = ['ContiguousArray', 'ArraySlice', 'Array', 'ArraySliceWithNonZeroStartIndex']
|
||||
|
||||
% for array_type in all_array_types:
|
||||
% for conformance in [
|
||||
% 'MutableRandomAccessCollectionVal',
|
||||
% 'MutableRandomAccessCollectionRef',
|
||||
% 'RangeReplaceableRandomAccessCollectionVal',
|
||||
% 'RangeReplaceableRandomAccessCollectionRef']:
|
||||
% collection_or_slice = 'Slice' if 'Slice' in array_type else 'Collection'
|
||||
% test_name = array_type + '_' + conformance
|
||||
% file_name = test_name + '.swift'
|
||||
// BEGIN ${file_name}
|
||||
//===----------------------------------------------------------------------===//
|
||||
// Automatically Generated From validation-test/stdlib/Array/Inputs/ArrayConformanceTests.swift.gyb
|
||||
// Do Not Edit Directly!
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
// RUN: %target-run-simple-swift
|
||||
// REQUIRES: executable_test
|
||||
|
||||
import StdlibUnittest
|
||||
import StdlibCollectionUnittest
|
||||
|
||||
|
||||
let tests = TestSuite("${test_name}")
|
||||
|
||||
|
||||
% if array_type == 'ArraySliceWithNonZeroStartIndex':
|
||||
func ArraySliceWithNonZeroStartIndex<T>(_ elements: [T]) -> ArraySlice<T> {
|
||||
var r = ArraySlice<T>(_startIndex: 1000)
|
||||
r.append(contentsOf: elements)
|
||||
expectEqual(1000, r.startIndex)
|
||||
return r
|
||||
}
|
||||
% end
|
||||
|
||||
do {
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
% if conformance == 'MutableRandomAccessCollectionVal':
|
||||
|
||||
// Test MutableCollectionType conformance with value type elements.
|
||||
tests.addMutableRandomAccessCollectionTests(
|
||||
"${array_type}.",
|
||||
makeCollection: { (elements: [OpaqueValue<Int>]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValue: identity,
|
||||
extractValue: identity,
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
makeCollectionOfComparable: { (elements: [MinimalComparableValue]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoComparable: identityComp,
|
||||
extractValueFromComparable: identityComp,
|
||||
resiliencyChecks: resiliencyChecks,
|
||||
withUnsafeMutableBufferPointerIsSupported: true,
|
||||
isFixedLengthCollection: false)
|
||||
|
||||
% elif conformance == 'MutableRandomAccessCollectionRef':
|
||||
|
||||
// Test MutableCollectionType conformance with reference type elements.
|
||||
tests.addMutableRandomAccessCollectionTests(
|
||||
"${array_type}.",
|
||||
makeCollection: { (elements: [LifetimeTracked]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValue: { (element: OpaqueValue<Int>) in
|
||||
LifetimeTracked(element.value, identity: element.identity)
|
||||
},
|
||||
extractValue: { (element: LifetimeTracked) in
|
||||
OpaqueValue(element.value, identity: element.identity)
|
||||
},
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
makeCollectionOfComparable: { (elements: [MinimalComparableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoComparable: identityComp,
|
||||
extractValueFromComparable: identityComp,
|
||||
resiliencyChecks: resiliencyChecks,
|
||||
withUnsafeMutableBufferPointerIsSupported: true,
|
||||
isFixedLengthCollection: false)
|
||||
|
||||
% elif conformance == 'RangeReplaceableRandomAccessCollectionVal':
|
||||
|
||||
// Test RangeReplaceableCollectionType conformance with value type elements.
|
||||
tests.addRangeReplaceableRandomAccess${collection_or_slice}Tests(
|
||||
"${array_type}.",
|
||||
makeCollection: { (elements: [OpaqueValue<Int>]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValue: identity,
|
||||
extractValue: identity,
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
resiliencyChecks: resiliencyChecks)
|
||||
|
||||
% else: # conformance == 'RangeReplaceableRandomAccessCollectionRef'
|
||||
|
||||
// Test RangeReplaceableCollectionType conformance with reference type elements.
|
||||
tests.addRangeReplaceableRandomAccess${collection_or_slice}Tests(
|
||||
"${array_type}.",
|
||||
makeCollection: { (elements: [LifetimeTracked]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValue: { (element: OpaqueValue<Int>) in LifetimeTracked(element.value) },
|
||||
extractValue: { (element: LifetimeTracked) in OpaqueValue(element.value) },
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
resiliencyChecks: resiliencyChecks)
|
||||
|
||||
% end
|
||||
|
||||
} // do
|
||||
|
||||
runAllTests()
|
||||
|
||||
% end
|
||||
@@ -376,109 +376,4 @@ for (step, evilBoundsCheck) in [ (1, true), (-1, false), (-1, true) ] {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func ArraySliceWithNonZeroStartIndex<T>(_ elements: [T]) -> ArraySlice<T> {
|
||||
var r = ArraySlice<T>(_startIndex: 1000)
|
||||
r.append(contentsOf: elements)
|
||||
expectEqual(1000, r.startIndex)
|
||||
return r
|
||||
}
|
||||
|
||||
% for array_type in all_array_types + ['ArraySliceWithNonZeroStartIndex']:
|
||||
% collection_or_slice = 'Slice' if 'Slice' in array_type else 'Collection'
|
||||
|
||||
do {
|
||||
// `Array`, `ArraySlice`, and `ContiguousArrayBuffer` have no expectation of
|
||||
// failure for advancing their indexes "out of bounds", because they are just
|
||||
// `Int`.
|
||||
var resiliencyChecks = CollectionMisuseResiliencyChecks.all
|
||||
resiliencyChecks.creatingOutOfBoundsIndicesBehavior = .none
|
||||
|
||||
// Test MutableCollectionType conformance with value type elements.
|
||||
ArrayTestSuite.addMutableRandomAccessCollectionTests(
|
||||
"${array_type}.",
|
||||
makeCollection: { (elements: [OpaqueValue<Int>]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValue: identity,
|
||||
extractValue: identity,
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
makeCollectionOfComparable: { (elements: [MinimalComparableValue]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoComparable: identityComp,
|
||||
extractValueFromComparable: identityComp,
|
||||
resiliencyChecks: resiliencyChecks,
|
||||
withUnsafeMutableBufferPointerIsSupported: true,
|
||||
isFixedLengthCollection: false)
|
||||
|
||||
|
||||
// Test MutableCollectionType conformance with reference type elements.
|
||||
ArrayTestSuite.addMutableRandomAccessCollectionTests(
|
||||
"${array_type}.",
|
||||
makeCollection: { (elements: [LifetimeTracked]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValue: { (element: OpaqueValue<Int>) in
|
||||
LifetimeTracked(element.value, identity: element.identity)
|
||||
},
|
||||
extractValue: { (element: LifetimeTracked) in
|
||||
OpaqueValue(element.value, identity: element.identity)
|
||||
},
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
makeCollectionOfComparable: { (elements: [MinimalComparableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoComparable: identityComp,
|
||||
extractValueFromComparable: identityComp,
|
||||
resiliencyChecks: resiliencyChecks,
|
||||
withUnsafeMutableBufferPointerIsSupported: true,
|
||||
isFixedLengthCollection: false)
|
||||
|
||||
|
||||
// Test RangeReplaceableCollectionType conformance with value type elements.
|
||||
ArrayTestSuite.addRangeReplaceableRandomAccess${collection_or_slice}Tests(
|
||||
"${array_type}.",
|
||||
makeCollection: { (elements: [OpaqueValue<Int>]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValue: identity,
|
||||
extractValue: identity,
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
resiliencyChecks: resiliencyChecks)
|
||||
|
||||
|
||||
// Test RangeReplaceableCollectionType conformance with reference type elements.
|
||||
ArrayTestSuite.addRangeReplaceableRandomAccess${collection_or_slice}Tests(
|
||||
"${array_type}.",
|
||||
makeCollection: { (elements: [LifetimeTracked]) in
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValue: { (element: OpaqueValue<Int>) in LifetimeTracked(element.value) },
|
||||
extractValue: { (element: LifetimeTracked) in OpaqueValue(element.value) },
|
||||
makeCollectionOfEquatable: { (elements: [MinimalEquatableValue]) in
|
||||
// FIXME: use LifetimeTracked.
|
||||
return ${array_type}(elements)
|
||||
},
|
||||
wrapValueIntoEquatable: identityEq,
|
||||
extractValueFromEquatable: identityEq,
|
||||
resiliencyChecks: resiliencyChecks)
|
||||
}
|
||||
|
||||
% end
|
||||
|
||||
runAllTests()
|
||||
|
||||
Reference in New Issue
Block a user