mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
Switch the stdlib to use #file instead of __FILE__, and deprecate the __FILE__ identifiers.
This also updates the tests that would otherwise fail.
This commit is contained in:
@@ -699,6 +699,11 @@ ERROR(invalid_label_on_stmt,none,
|
|||||||
NOTE(discard_result_of_closure,none,
|
NOTE(discard_result_of_closure,none,
|
||||||
"explicitly discard the result of the closure by assigning to '_'", ())
|
"explicitly discard the result of the closure by assigning to '_'", ())
|
||||||
|
|
||||||
|
WARNING(snake_case_deprecated,none,
|
||||||
|
"%0 is deprecated and will be removed in Swift 3, please use %1",
|
||||||
|
(StringRef, StringRef))
|
||||||
|
|
||||||
|
|
||||||
// Assignment statement
|
// Assignment statement
|
||||||
ERROR(expected_expr_assignment,none,
|
ERROR(expected_expr_assignment,none,
|
||||||
"expected expression in assignment", ())
|
"expected expression in assignment", ())
|
||||||
|
|||||||
@@ -881,16 +881,31 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case tok::pound_column:
|
|
||||||
case tok::pound_file:
|
|
||||||
case tok::pound_function:
|
|
||||||
case tok::pound_line:
|
|
||||||
case tok::pound_dsohandle:
|
|
||||||
case tok::kw___FILE__:
|
case tok::kw___FILE__:
|
||||||
case tok::kw___LINE__:
|
case tok::kw___LINE__:
|
||||||
case tok::kw___COLUMN__:
|
case tok::kw___COLUMN__:
|
||||||
case tok::kw___FUNCTION__:
|
case tok::kw___FUNCTION__:
|
||||||
case tok::kw___DSO_HANDLE__: {
|
case tok::kw___DSO_HANDLE__: {
|
||||||
|
StringRef replacement = "";
|
||||||
|
switch (Tok.getKind()) {
|
||||||
|
default: llvm_unreachable("can't get here");
|
||||||
|
case tok::kw___FILE__: replacement = "#file"; break;
|
||||||
|
case tok::kw___LINE__: replacement = "#line"; break;
|
||||||
|
case tok::kw___COLUMN__: replacement = "#column"; break;
|
||||||
|
case tok::kw___FUNCTION__: replacement = "#function"; break;
|
||||||
|
case tok::kw___DSO_HANDLE__: replacement = "#dsohandle"; break;
|
||||||
|
}
|
||||||
|
|
||||||
|
diagnose(Tok.getLoc(), diag::snake_case_deprecated,
|
||||||
|
Tok.getText(), replacement)
|
||||||
|
.fixItReplace(Tok.getLoc(), replacement);
|
||||||
|
SWIFT_FALLTHROUGH;
|
||||||
|
}
|
||||||
|
case tok::pound_column:
|
||||||
|
case tok::pound_file:
|
||||||
|
case tok::pound_function:
|
||||||
|
case tok::pound_line:
|
||||||
|
case tok::pound_dsohandle: {
|
||||||
auto Kind = getMagicIdentifierLiteralKind(Tok.getKind());
|
auto Kind = getMagicIdentifierLiteralKind(Tok.getKind());
|
||||||
SourceLoc Loc = consumeToken();
|
SourceLoc Loc = consumeToken();
|
||||||
Result = makeParserResult(
|
Result = makeParserResult(
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public struct SubscriptRangeTest {
|
|||||||
public init(
|
public init(
|
||||||
expected: [Int], collection: [Int], bounds: Range<Int>,
|
expected: [Int], collection: [Int], bounds: Range<Int>,
|
||||||
count: Int,
|
count: Int,
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.expected = expected.map(OpaqueValue.init)
|
self.expected = expected.map(OpaqueValue.init)
|
||||||
self.collection = collection.map(OpaqueValue.init)
|
self.collection = collection.map(OpaqueValue.init)
|
||||||
@@ -49,7 +49,7 @@ public struct PrefixThroughTest {
|
|||||||
|
|
||||||
init(
|
init(
|
||||||
collection: [Int], position: Int, expected: [Int],
|
collection: [Int], position: Int, expected: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.collection = collection
|
self.collection = collection
|
||||||
self.position = position
|
self.position = position
|
||||||
@@ -66,7 +66,7 @@ public struct PrefixUpToTest {
|
|||||||
|
|
||||||
public init(
|
public init(
|
||||||
collection: [Int], end: Int, expected: [Int],
|
collection: [Int], end: Int, expected: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.collection = collection
|
self.collection = collection
|
||||||
self.end = end
|
self.end = end
|
||||||
@@ -83,7 +83,7 @@ internal struct RemoveFirstNTest {
|
|||||||
|
|
||||||
init(
|
init(
|
||||||
collection: [Int], numberToRemove: Int, expectedCollection: [Int],
|
collection: [Int], numberToRemove: Int, expectedCollection: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.collection = collection
|
self.collection = collection
|
||||||
self.numberToRemove = numberToRemove
|
self.numberToRemove = numberToRemove
|
||||||
@@ -100,7 +100,7 @@ public struct SuffixFromTest {
|
|||||||
|
|
||||||
init(
|
init(
|
||||||
collection: [Int], start: Int, expected: [Int],
|
collection: [Int], start: Int, expected: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.collection = collection
|
self.collection = collection
|
||||||
self.start = start
|
self.start = start
|
||||||
@@ -305,10 +305,10 @@ extension TestSuite {
|
|||||||
) {
|
) {
|
||||||
var testNamePrefix = testNamePrefix
|
var testNamePrefix = testNamePrefix
|
||||||
|
|
||||||
if checksAdded.value.contains(__FUNCTION__) {
|
if checksAdded.value.contains(#function) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
checksAdded.value.insert(__FUNCTION__)
|
checksAdded.value.insert(#function)
|
||||||
|
|
||||||
addSequenceTests(
|
addSequenceTests(
|
||||||
testNamePrefix,
|
testNamePrefix,
|
||||||
@@ -842,10 +842,10 @@ self.test("\(testNamePrefix).popFirst()/slice/empty/semantics") {
|
|||||||
outOfBoundsSubscriptOffset: Int = 1
|
outOfBoundsSubscriptOffset: Int = 1
|
||||||
) {
|
) {
|
||||||
var testNamePrefix = testNamePrefix
|
var testNamePrefix = testNamePrefix
|
||||||
if checksAdded.value.contains(__FUNCTION__) {
|
if checksAdded.value.contains(#function) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
checksAdded.value.insert(__FUNCTION__)
|
checksAdded.value.insert(#function)
|
||||||
|
|
||||||
addForwardCollectionTests(
|
addForwardCollectionTests(
|
||||||
testNamePrefix,
|
testNamePrefix,
|
||||||
@@ -1191,10 +1191,10 @@ self.test("\(testNamePrefix).suffix/semantics") {
|
|||||||
) {
|
) {
|
||||||
var testNamePrefix = testNamePrefix
|
var testNamePrefix = testNamePrefix
|
||||||
|
|
||||||
if checksAdded.value.contains(__FUNCTION__) {
|
if checksAdded.value.contains(#function) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
checksAdded.value.insert(__FUNCTION__)
|
checksAdded.value.insert(#function)
|
||||||
|
|
||||||
addBidirectionalCollectionTests(
|
addBidirectionalCollectionTests(
|
||||||
testNamePrefix,
|
testNamePrefix,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public struct PartitionExhaustiveTest {
|
|||||||
|
|
||||||
public init(
|
public init(
|
||||||
_ sequence: [Int],
|
_ sequence: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
self.loc = SourceLoc(file, line, comment: "test data")
|
self.loc = SourceLoc(file, line, comment: "test data")
|
||||||
@@ -102,10 +102,10 @@ extension TestSuite {
|
|||||||
) {
|
) {
|
||||||
var testNamePrefix = testNamePrefix
|
var testNamePrefix = testNamePrefix
|
||||||
|
|
||||||
if checksAdded.value.contains(__FUNCTION__) {
|
if checksAdded.value.contains(#function) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
checksAdded.value.insert(__FUNCTION__)
|
checksAdded.value.insert(#function)
|
||||||
|
|
||||||
addForwardCollectionTests(
|
addForwardCollectionTests(
|
||||||
testNamePrefix,
|
testNamePrefix,
|
||||||
@@ -407,10 +407,10 @@ self.test("\(testNamePrefix).sort/${'Predicate' if predicate else 'WhereElementI
|
|||||||
) {
|
) {
|
||||||
var testNamePrefix = testNamePrefix
|
var testNamePrefix = testNamePrefix
|
||||||
|
|
||||||
if checksAdded.value.contains(__FUNCTION__) {
|
if checksAdded.value.contains(#function) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
checksAdded.value.insert(__FUNCTION__)
|
checksAdded.value.insert(#function)
|
||||||
|
|
||||||
addForwardMutableCollectionTests(
|
addForwardMutableCollectionTests(
|
||||||
testNamePrefix,
|
testNamePrefix,
|
||||||
@@ -525,10 +525,10 @@ if resiliencyChecks.subscriptOnOutOfBoundsIndicesBehavior != .None {
|
|||||||
) {
|
) {
|
||||||
var testNamePrefix = testNamePrefix
|
var testNamePrefix = testNamePrefix
|
||||||
|
|
||||||
if checksAdded.value.contains(__FUNCTION__) {
|
if checksAdded.value.contains(#function) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
checksAdded.value.insert(__FUNCTION__)
|
checksAdded.value.insert(#function)
|
||||||
|
|
||||||
addBidirectionalMutableCollectionTests(
|
addBidirectionalMutableCollectionTests(
|
||||||
testNamePrefix,
|
testNamePrefix,
|
||||||
|
|||||||
@@ -69,7 +69,7 @@ internal struct ReplaceRangeTest {
|
|||||||
internal init(
|
internal init(
|
||||||
collection: [Int], newElements: [Int],
|
collection: [Int], newElements: [Int],
|
||||||
rangeSelection: RangeSelection, expected: [Int],
|
rangeSelection: RangeSelection, expected: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.collection = collection.map(OpaqueValue.init)
|
self.collection = collection.map(OpaqueValue.init)
|
||||||
self.newElements = newElements.map(OpaqueValue.init)
|
self.newElements = newElements.map(OpaqueValue.init)
|
||||||
@@ -87,7 +87,7 @@ internal struct AppendTest {
|
|||||||
|
|
||||||
internal init(
|
internal init(
|
||||||
collection: [Int], newElement: Int, expected: [Int],
|
collection: [Int], newElement: Int, expected: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.collection = collection.map(OpaqueValue.init)
|
self.collection = collection.map(OpaqueValue.init)
|
||||||
self.newElement = OpaqueValue(newElement)
|
self.newElement = OpaqueValue(newElement)
|
||||||
@@ -104,7 +104,7 @@ internal struct AppendContentsOfTest {
|
|||||||
|
|
||||||
internal init(
|
internal init(
|
||||||
collection: [Int], newElements: [Int], expected: [Int],
|
collection: [Int], newElements: [Int], expected: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.collection = collection.map(OpaqueValue.init)
|
self.collection = collection.map(OpaqueValue.init)
|
||||||
self.newElements = newElements.map(OpaqueValue.init)
|
self.newElements = newElements.map(OpaqueValue.init)
|
||||||
@@ -122,7 +122,7 @@ internal struct InsertTest {
|
|||||||
|
|
||||||
internal init(
|
internal init(
|
||||||
collection: [Int], newElement: Int, indexSelection: IndexSelection,
|
collection: [Int], newElement: Int, indexSelection: IndexSelection,
|
||||||
expected: [Int], file: String = __FILE__, line: UInt = __LINE__
|
expected: [Int], file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.collection = collection.map(OpaqueValue.init)
|
self.collection = collection.map(OpaqueValue.init)
|
||||||
self.newElement = OpaqueValue(newElement)
|
self.newElement = OpaqueValue(newElement)
|
||||||
@@ -141,7 +141,7 @@ internal struct InsertContentsOfTest {
|
|||||||
|
|
||||||
internal init(
|
internal init(
|
||||||
collection: [Int], newElements: [Int], indexSelection: IndexSelection,
|
collection: [Int], newElements: [Int], indexSelection: IndexSelection,
|
||||||
expected: [Int], file: String = __FILE__, line: UInt = __LINE__
|
expected: [Int], file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.collection = collection.map(OpaqueValue.init)
|
self.collection = collection.map(OpaqueValue.init)
|
||||||
self.newElements = newElements.map(OpaqueValue.init)
|
self.newElements = newElements.map(OpaqueValue.init)
|
||||||
@@ -161,7 +161,7 @@ internal struct RemoveAtIndexTest {
|
|||||||
internal init(
|
internal init(
|
||||||
collection: [Int], indexSelection: IndexSelection,
|
collection: [Int], indexSelection: IndexSelection,
|
||||||
expectedRemovedElement: Int, expectedCollection: [Int],
|
expectedRemovedElement: Int, expectedCollection: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.collection = collection.map(OpaqueValue.init)
|
self.collection = collection.map(OpaqueValue.init)
|
||||||
self.indexSelection = indexSelection
|
self.indexSelection = indexSelection
|
||||||
@@ -179,7 +179,7 @@ internal struct RemoveLastNTest {
|
|||||||
|
|
||||||
internal init(
|
internal init(
|
||||||
collection: [Int], numberToRemove: Int, expectedCollection: [Int],
|
collection: [Int], numberToRemove: Int, expectedCollection: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.collection = collection.map(OpaqueValue.init)
|
self.collection = collection.map(OpaqueValue.init)
|
||||||
self.numberToRemove = numberToRemove
|
self.numberToRemove = numberToRemove
|
||||||
@@ -196,7 +196,7 @@ internal struct RemoveRangeTest {
|
|||||||
|
|
||||||
internal init(
|
internal init(
|
||||||
collection: [Int], rangeSelection: RangeSelection, expected: [Int],
|
collection: [Int], rangeSelection: RangeSelection, expected: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.collection = collection.map(OpaqueValue.init)
|
self.collection = collection.map(OpaqueValue.init)
|
||||||
self.rangeSelection = rangeSelection
|
self.rangeSelection = rangeSelection
|
||||||
@@ -212,7 +212,7 @@ internal struct RemoveAllTest {
|
|||||||
|
|
||||||
internal init(
|
internal init(
|
||||||
collection: [Int], expected: [Int],
|
collection: [Int], expected: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.collection = collection.map(OpaqueValue.init)
|
self.collection = collection.map(OpaqueValue.init)
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
@@ -227,7 +227,7 @@ internal struct ReserveCapacityTest {
|
|||||||
|
|
||||||
internal init(
|
internal init(
|
||||||
collection: [Int], requestedCapacity: Int,
|
collection: [Int], requestedCapacity: Int,
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.collection = collection.map(OpaqueValue.init)
|
self.collection = collection.map(OpaqueValue.init)
|
||||||
self.requestedCapacity = requestedCapacity
|
self.requestedCapacity = requestedCapacity
|
||||||
@@ -243,7 +243,7 @@ internal struct OperatorPlusTest {
|
|||||||
|
|
||||||
internal init(
|
internal init(
|
||||||
lhs: [Int], rhs: [Int], expected: [Int],
|
lhs: [Int], rhs: [Int], expected: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.lhs = lhs.map(OpaqueValue.init)
|
self.lhs = lhs.map(OpaqueValue.init)
|
||||||
self.rhs = rhs.map(OpaqueValue.init)
|
self.rhs = rhs.map(OpaqueValue.init)
|
||||||
@@ -365,10 +365,10 @@ extension TestSuite {
|
|||||||
) {
|
) {
|
||||||
var testNamePrefix = testNamePrefix
|
var testNamePrefix = testNamePrefix
|
||||||
|
|
||||||
if checksAdded.value.contains(__FUNCTION__) {
|
if checksAdded.value.contains(#function) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
checksAdded.value.insert(__FUNCTION__)
|
checksAdded.value.insert(#function)
|
||||||
|
|
||||||
addForwardCollectionTests(
|
addForwardCollectionTests(
|
||||||
testNamePrefix,
|
testNamePrefix,
|
||||||
@@ -1126,10 +1126,10 @@ self.test("\(testNamePrefix).OperatorPlus") {
|
|||||||
) {
|
) {
|
||||||
var testNamePrefix = testNamePrefix
|
var testNamePrefix = testNamePrefix
|
||||||
|
|
||||||
if checksAdded.value.contains(__FUNCTION__) {
|
if checksAdded.value.contains(#function) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
checksAdded.value.insert(__FUNCTION__)
|
checksAdded.value.insert(#function)
|
||||||
|
|
||||||
addForwardRangeReplaceableCollectionTests(
|
addForwardRangeReplaceableCollectionTests(
|
||||||
testNamePrefix,
|
testNamePrefix,
|
||||||
@@ -1252,10 +1252,10 @@ self.test("\(testNamePrefix).removeLast(n: Int)/whereIndexIsBidirectional/remove
|
|||||||
) {
|
) {
|
||||||
var testNamePrefix = testNamePrefix
|
var testNamePrefix = testNamePrefix
|
||||||
|
|
||||||
if checksAdded.value.contains(__FUNCTION__) {
|
if checksAdded.value.contains(#function) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
checksAdded.value.insert(__FUNCTION__)
|
checksAdded.value.insert(#function)
|
||||||
|
|
||||||
addBidirectionalRangeReplaceableCollectionTests(
|
addBidirectionalRangeReplaceableCollectionTests(
|
||||||
testNamePrefix,
|
testNamePrefix,
|
||||||
|
|||||||
@@ -38,10 +38,10 @@ extension TestSuite {
|
|||||||
var testNamePrefix = testNamePrefix
|
var testNamePrefix = testNamePrefix
|
||||||
|
|
||||||
// Don't run the same tests twice.
|
// Don't run the same tests twice.
|
||||||
if checksAdded.value.contains(__FUNCTION__) {
|
if checksAdded.value.contains(#function) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
checksAdded.value.insert(__FUNCTION__)
|
checksAdded.value.insert(#function)
|
||||||
|
|
||||||
addForwardRangeReplaceableCollectionTests(
|
addForwardRangeReplaceableCollectionTests(
|
||||||
testNamePrefix,
|
testNamePrefix,
|
||||||
@@ -169,10 +169,10 @@ extension TestSuite {
|
|||||||
var testNamePrefix = testNamePrefix
|
var testNamePrefix = testNamePrefix
|
||||||
|
|
||||||
// Don't run the same tests twice.
|
// Don't run the same tests twice.
|
||||||
if checksAdded.value.contains(__FUNCTION__) {
|
if checksAdded.value.contains(#function) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
checksAdded.value.insert(__FUNCTION__)
|
checksAdded.value.insert(#function)
|
||||||
|
|
||||||
addForwardRangeReplaceableSliceTests(
|
addForwardRangeReplaceableSliceTests(
|
||||||
testNamePrefix,
|
testNamePrefix,
|
||||||
@@ -314,10 +314,10 @@ extension TestSuite {
|
|||||||
var testNamePrefix = testNamePrefix
|
var testNamePrefix = testNamePrefix
|
||||||
|
|
||||||
// Don't run the same tests twice.
|
// Don't run the same tests twice.
|
||||||
if checksAdded.value.contains(__FUNCTION__) {
|
if checksAdded.value.contains(#function) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
checksAdded.value.insert(__FUNCTION__)
|
checksAdded.value.insert(#function)
|
||||||
|
|
||||||
addBidirectionalRangeReplaceableSliceTests(
|
addBidirectionalRangeReplaceableSliceTests(
|
||||||
testNamePrefix,
|
testNamePrefix,
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public struct DropFirstTest {
|
|||||||
public let loc: SourceLoc
|
public let loc: SourceLoc
|
||||||
|
|
||||||
public init(sequence: [Int], dropElements: Int, expected: [Int],
|
public init(sequence: [Int], dropElements: Int, expected: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__) {
|
file: String = #file, line: UInt = #line) {
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
self.dropElements = dropElements
|
self.dropElements = dropElements
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
@@ -34,7 +34,7 @@ public struct DropLastTest {
|
|||||||
public let loc: SourceLoc
|
public let loc: SourceLoc
|
||||||
|
|
||||||
public init(sequence: [Int], dropElements: Int, expected: [Int],
|
public init(sequence: [Int], dropElements: Int, expected: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__) {
|
file: String = #file, line: UInt = #line) {
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
self.dropElements = dropElements
|
self.dropElements = dropElements
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
@@ -54,7 +54,7 @@ public struct ElementsEqualTest {
|
|||||||
_ expected: Bool, _ sequence: [Int], _ other: [Int],
|
_ expected: Bool, _ sequence: [Int], _ other: [Int],
|
||||||
_ expectedLeftoverSequence: [Int],
|
_ expectedLeftoverSequence: [Int],
|
||||||
_ expectedLeftoverOther: [Int],
|
_ expectedLeftoverOther: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__,
|
file: String = #file, line: UInt = #line,
|
||||||
comment: String = ""
|
comment: String = ""
|
||||||
) {
|
) {
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
@@ -80,7 +80,7 @@ public struct EnumerateTest {
|
|||||||
|
|
||||||
public init(
|
public init(
|
||||||
_ expected: [(Int, Int)], _ sequence: [Int],
|
_ expected: [(Int, Int)], _ sequence: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__,
|
file: String = #file, line: UInt = #line,
|
||||||
comment: String = ""
|
comment: String = ""
|
||||||
) {
|
) {
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
@@ -99,7 +99,7 @@ public struct FilterTest {
|
|||||||
_ expected: [Int],
|
_ expected: [Int],
|
||||||
_ sequence: [Int],
|
_ sequence: [Int],
|
||||||
_ includeElement: (Int) -> Bool,
|
_ includeElement: (Int) -> Bool,
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
@@ -118,7 +118,7 @@ public struct FindTest {
|
|||||||
public init(
|
public init(
|
||||||
expected: Int?, element: Int, sequence: [Int],
|
expected: Int?, element: Int, sequence: [Int],
|
||||||
expectedLeftoverSequence: [Int],
|
expectedLeftoverSequence: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
self.element = MinimalEquatableValue(element)
|
self.element = MinimalEquatableValue(element)
|
||||||
@@ -139,7 +139,7 @@ public struct FlatMapTest {
|
|||||||
expected: [Int32],
|
expected: [Int32],
|
||||||
sequence: [Int],
|
sequence: [Int],
|
||||||
transform: (Int) -> [Int32],
|
transform: (Int) -> [Int32],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
@@ -158,7 +158,7 @@ public struct FlatMapToOptionalTest {
|
|||||||
_ expected: [Int32],
|
_ expected: [Int32],
|
||||||
_ sequence: [Int],
|
_ sequence: [Int],
|
||||||
_ transform: (Int) -> Int32?,
|
_ transform: (Int) -> Int32?,
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
@@ -176,7 +176,7 @@ internal struct ForEachTest {
|
|||||||
|
|
||||||
init(
|
init(
|
||||||
_ sequence: [Int],
|
_ sequence: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
self.loc = SourceLoc(file, line, comment: "test data")
|
self.loc = SourceLoc(file, line, comment: "test data")
|
||||||
@@ -195,7 +195,7 @@ public struct LexicographicalCompareTest {
|
|||||||
_ expected: ExpectedComparisonResult, _ sequence: [Int], _ other: [Int],
|
_ expected: ExpectedComparisonResult, _ sequence: [Int], _ other: [Int],
|
||||||
_ expectedLeftoverSequence: [Int],
|
_ expectedLeftoverSequence: [Int],
|
||||||
_ expectedLeftoverOther: [Int],
|
_ expectedLeftoverOther: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__,
|
file: String = #file, line: UInt = #line,
|
||||||
comment: String = ""
|
comment: String = ""
|
||||||
) {
|
) {
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
@@ -224,7 +224,7 @@ public struct MapTest {
|
|||||||
_ expected: [Int32],
|
_ expected: [Int32],
|
||||||
_ sequence: [Int],
|
_ sequence: [Int],
|
||||||
_ transform: (Int) -> Int32,
|
_ transform: (Int) -> Int32,
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
@@ -247,7 +247,7 @@ public struct MinMaxElementTest {
|
|||||||
maxValue expectedMaxValue: Int?,
|
maxValue expectedMaxValue: Int?,
|
||||||
index expectedMaxIndex: Int?,
|
index expectedMaxIndex: Int?,
|
||||||
_ sequence: [Int],
|
_ sequence: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__,
|
file: String = #file, line: UInt = #line,
|
||||||
comment: String = ""
|
comment: String = ""
|
||||||
) {
|
) {
|
||||||
self.expectedMinValue = expectedMinValue
|
self.expectedMinValue = expectedMinValue
|
||||||
@@ -266,7 +266,7 @@ public struct PrefixTest {
|
|||||||
public let loc: SourceLoc
|
public let loc: SourceLoc
|
||||||
|
|
||||||
public init(sequence: [Int], maxLength: Int, expected: [Int],
|
public init(sequence: [Int], maxLength: Int, expected: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__) {
|
file: String = #file, line: UInt = #line) {
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
self.maxLength = maxLength
|
self.maxLength = maxLength
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
@@ -280,7 +280,7 @@ public struct ReduceTest {
|
|||||||
|
|
||||||
public init(
|
public init(
|
||||||
_ sequence: [Int],
|
_ sequence: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
self.loc = SourceLoc(file, line, comment: "test data")
|
self.loc = SourceLoc(file, line, comment: "test data")
|
||||||
@@ -294,7 +294,7 @@ public struct ReverseTest {
|
|||||||
|
|
||||||
public init(
|
public init(
|
||||||
_ expected: [Int], _ sequence: [Int],
|
_ expected: [Int], _ sequence: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
@@ -309,7 +309,7 @@ public struct SuffixTest {
|
|||||||
public let loc: SourceLoc
|
public let loc: SourceLoc
|
||||||
|
|
||||||
public init(sequence: [Int], maxLength: Int, expected: [Int],
|
public init(sequence: [Int], maxLength: Int, expected: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__) {
|
file: String = #file, line: UInt = #line) {
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
self.maxLength = maxLength
|
self.maxLength = maxLength
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
@@ -326,7 +326,7 @@ public struct SplitTest {
|
|||||||
public let loc: SourceLoc
|
public let loc: SourceLoc
|
||||||
|
|
||||||
public init(sequence: [Int], maxSplit: Int, separator: Int, expected: [[Int]],
|
public init(sequence: [Int], maxSplit: Int, separator: Int, expected: [[Int]],
|
||||||
allowEmptySlices: Bool, file: String = __FILE__, line: UInt = __LINE__) {
|
allowEmptySlices: Bool, file: String = #file, line: UInt = #line) {
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
self.maxSplit = maxSplit
|
self.maxSplit = maxSplit
|
||||||
self.separator = separator
|
self.separator = separator
|
||||||
@@ -348,7 +348,7 @@ public struct StartsWithTest {
|
|||||||
_ expected: Bool, _ sequence: [Int], _ prefix: [Int],
|
_ expected: Bool, _ sequence: [Int], _ prefix: [Int],
|
||||||
_ expectedLeftoverSequence: [Int],
|
_ expectedLeftoverSequence: [Int],
|
||||||
_ expectedLeftoverPrefix: [Int],
|
_ expectedLeftoverPrefix: [Int],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
@@ -372,7 +372,7 @@ public struct ZipTest {
|
|||||||
_ other: [Int32],
|
_ other: [Int32],
|
||||||
leftovers expectedLeftoverSequence: [Int],
|
leftovers expectedLeftoverSequence: [Int],
|
||||||
_ expectedLeftoverOther: [Int32],
|
_ expectedLeftoverOther: [Int32],
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
self.expected = expected
|
self.expected = expected
|
||||||
self.sequence = sequence
|
self.sequence = sequence
|
||||||
@@ -1455,10 +1455,10 @@ extension TestSuite {
|
|||||||
) {
|
) {
|
||||||
var testNamePrefix = testNamePrefix
|
var testNamePrefix = testNamePrefix
|
||||||
|
|
||||||
if checksAdded.value.contains(__FUNCTION__) {
|
if checksAdded.value.contains(#function) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
checksAdded.value.insert(__FUNCTION__)
|
checksAdded.value.insert(#function)
|
||||||
|
|
||||||
func makeWrappedSequence(elements: [OpaqueValue<Int>]) -> Sequence {
|
func makeWrappedSequence(elements: [OpaqueValue<Int>]) -> Sequence {
|
||||||
return makeSequence(elements.map(wrapValue))
|
return makeSequence(elements.map(wrapValue))
|
||||||
|
|||||||
@@ -577,7 +577,7 @@ public func expectCustomizable<
|
|||||||
@autoclosure _ message: () -> String = "",
|
@autoclosure _ message: () -> String = "",
|
||||||
showFrame: Bool = true,
|
showFrame: Bool = true,
|
||||||
stackTrace: SourceLocStack = SourceLocStack(),
|
stackTrace: SourceLocStack = SourceLocStack(),
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
let newTrace = stackTrace.pushIf(showFrame, file: file, line: line)
|
let newTrace = stackTrace.pushIf(showFrame, file: file, line: line)
|
||||||
expectNotEqual(0, counters[T.self], message(), stackTrace: newTrace)
|
expectNotEqual(0, counters[T.self], message(), stackTrace: newTrace)
|
||||||
@@ -595,7 +595,7 @@ public func expectNotCustomizable<
|
|||||||
@autoclosure _ message: () -> String = "",
|
@autoclosure _ message: () -> String = "",
|
||||||
showFrame: Bool = true,
|
showFrame: Bool = true,
|
||||||
stackTrace: SourceLocStack = SourceLocStack(),
|
stackTrace: SourceLocStack = SourceLocStack(),
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
let newTrace = stackTrace.pushIf(showFrame, file: file, line: line)
|
let newTrace = stackTrace.pushIf(showFrame, file: file, line: line)
|
||||||
expectNotEqual(0, counters[T.self], message(), stackTrace: newTrace)
|
expectNotEqual(0, counters[T.self], message(), stackTrace: newTrace)
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
TRACE = '''@autoclosure _ message: () -> String = "",
|
TRACE = '''@autoclosure _ message: () -> String = "",
|
||||||
showFrame: Bool = true,
|
showFrame: Bool = true,
|
||||||
stackTrace: SourceLocStack = SourceLocStack(),
|
stackTrace: SourceLocStack = SourceLocStack(),
|
||||||
file: String = __FILE__, line: UInt = __LINE__'''
|
file: String = #file, line: UInt = #line'''
|
||||||
|
|
||||||
stackTrace = 'stackTrace.pushIf(showFrame, file: file, line: line)'
|
stackTrace = 'stackTrace.pushIf(showFrame, file: file, line: line)'
|
||||||
}%
|
}%
|
||||||
|
|||||||
@@ -36,7 +36,7 @@ public struct SourceLoc {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func withCurrentLoc(
|
public func withCurrentLoc(
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) -> SourceLocStack {
|
) -> SourceLocStack {
|
||||||
return SourceLocStack(self).with(SourceLoc(file, line))
|
return SourceLocStack(self).with(SourceLoc(file, line))
|
||||||
}
|
}
|
||||||
@@ -74,7 +74,7 @@ public struct SourceLocStack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func withCurrentLoc(
|
public func withCurrentLoc(
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) -> SourceLocStack {
|
) -> SourceLocStack {
|
||||||
return with(SourceLoc(file, line))
|
return with(SourceLoc(file, line))
|
||||||
}
|
}
|
||||||
@@ -90,7 +90,7 @@ public struct SourceLocStack {
|
|||||||
TRACE = '''@autoclosure _ message: () -> String = "",
|
TRACE = '''@autoclosure _ message: () -> String = "",
|
||||||
showFrame: Bool = true,
|
showFrame: Bool = true,
|
||||||
stackTrace: SourceLocStack = SourceLocStack(),
|
stackTrace: SourceLocStack = SourceLocStack(),
|
||||||
file: String = __FILE__, line: UInt = __LINE__'''
|
file: String = #file, line: UInt = #line'''
|
||||||
|
|
||||||
# When the parameter list would start with a ${TRACE}, we use
|
# When the parameter list would start with a ${TRACE}, we use
|
||||||
# ${TRACE1} instead, to avoid the warning about an extraneous
|
# ${TRACE1} instead, to avoid the warning about an extraneous
|
||||||
@@ -876,7 +876,7 @@ public class TestSuite {
|
|||||||
|
|
||||||
public func test(
|
public func test(
|
||||||
name: String,
|
name: String,
|
||||||
file: String = __FILE__, line: UInt = __LINE__,
|
file: String = #file, line: UInt = #line,
|
||||||
_ testFunction: () -> Void
|
_ testFunction: () -> Void
|
||||||
) {
|
) {
|
||||||
_TestBuilder(testSuite: self, name: name, loc: SourceLoc(file, line))
|
_TestBuilder(testSuite: self, name: name, loc: SourceLoc(file, line))
|
||||||
@@ -884,7 +884,7 @@ public class TestSuite {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public func test(
|
public func test(
|
||||||
name: String, file: String = __FILE__, line: UInt = __LINE__
|
name: String, file: String = #file, line: UInt = #line
|
||||||
) -> _TestBuilder {
|
) -> _TestBuilder {
|
||||||
return _TestBuilder(testSuite: self, name: name, loc: SourceLoc(file, line))
|
return _TestBuilder(testSuite: self, name: name, loc: SourceLoc(file, line))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ extension TypeIndexed where Value : ForwardIndexType {
|
|||||||
@autoclosure _ message: () -> String = "",
|
@autoclosure _ message: () -> String = "",
|
||||||
showFrame: Bool = true,
|
showFrame: Bool = true,
|
||||||
stackTrace: SourceLocStack = SourceLocStack(),
|
stackTrace: SourceLocStack = SourceLocStack(),
|
||||||
file: String = __FILE__, line: UInt = __LINE__,
|
file: String = #file, line: UInt = #line,
|
||||||
body: () -> R
|
body: () -> R
|
||||||
) -> R {
|
) -> R {
|
||||||
let expected = self[t].successor()
|
let expected = self[t].successor()
|
||||||
@@ -76,7 +76,7 @@ extension TypeIndexed where Value : Equatable {
|
|||||||
@autoclosure _ message: () -> String = "",
|
@autoclosure _ message: () -> String = "",
|
||||||
showFrame: Bool = true,
|
showFrame: Bool = true,
|
||||||
stackTrace: SourceLocStack = SourceLocStack(),
|
stackTrace: SourceLocStack = SourceLocStack(),
|
||||||
file: String = __FILE__, line: UInt = __LINE__,
|
file: String = #file, line: UInt = #line,
|
||||||
body: () -> R
|
body: () -> R
|
||||||
) -> R {
|
) -> R {
|
||||||
let expected = self[t]
|
let expected = self[t]
|
||||||
@@ -102,7 +102,7 @@ public func expectEqual<V: Comparable>(
|
|||||||
@autoclosure _ message: () -> String = "",
|
@autoclosure _ message: () -> String = "",
|
||||||
showFrame: Bool = true,
|
showFrame: Bool = true,
|
||||||
stackTrace: SourceLocStack = SourceLocStack(),
|
stackTrace: SourceLocStack = SourceLocStack(),
|
||||||
file: String = __FILE__, line: UInt = __LINE__
|
file: String = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
expectEqualsUnordered(
|
expectEqualsUnordered(
|
||||||
expected.map { (TypeIdentifier($0.0), $0.1) },
|
expected.map { (TypeIdentifier($0.0), $0.1) },
|
||||||
|
|||||||
@@ -84,13 +84,13 @@ func _XCTRunThrowableBlock(@noescape block: () throws -> Void) -> _XCTThrowableB
|
|||||||
|
|
||||||
// --- Supported Assertions ---
|
// --- Supported Assertions ---
|
||||||
|
|
||||||
public func XCTFail(message: String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTFail(message: String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.Fail
|
let assertionType = _XCTAssertionType.Fail
|
||||||
|
|
||||||
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, "" as NSString), message, file, line)
|
_XCTRegisterFailure(true, _XCTFailureDescription(assertionType, 0, "" as NSString), message, file, line)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertNil(@autoclosure expression: () throws -> Any?, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertNil(@autoclosure expression: () throws -> Any?, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.Nil
|
let assertionType = _XCTAssertionType.Nil
|
||||||
|
|
||||||
// evaluate the expression exactly once
|
// evaluate the expression exactly once
|
||||||
@@ -129,7 +129,7 @@ public func XCTAssertNil(@autoclosure expression: () throws -> Any?, @autoclosur
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertNotNil(@autoclosure expression: () throws -> Any?, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertNotNil(@autoclosure expression: () throws -> Any?, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.NotNil
|
let assertionType = _XCTAssertionType.NotNil
|
||||||
|
|
||||||
// evaluate the expression exactly once
|
// evaluate the expression exactly once
|
||||||
@@ -168,12 +168,12 @@ public func XCTAssertNotNil(@autoclosure expression: () throws -> Any?, @autoclo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssert( @autoclosure expression: () throws -> BooleanType, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssert( @autoclosure expression: () throws -> BooleanType, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
// XCTAssert is just a cover for XCTAssertTrue.
|
// XCTAssert is just a cover for XCTAssertTrue.
|
||||||
XCTAssertTrue(expression, message, file: file, line: line)
|
XCTAssertTrue(expression, message, file: file, line: line)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertTrue(@autoclosure expression: () throws -> BooleanType, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertTrue(@autoclosure expression: () throws -> BooleanType, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.True
|
let assertionType = _XCTAssertionType.True
|
||||||
|
|
||||||
// evaluate the expression exactly once
|
// evaluate the expression exactly once
|
||||||
@@ -204,7 +204,7 @@ public func XCTAssertTrue(@autoclosure expression: () throws -> BooleanType, @au
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertFalse(@autoclosure expression: () throws -> BooleanType, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertFalse(@autoclosure expression: () throws -> BooleanType, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.False
|
let assertionType = _XCTAssertionType.False
|
||||||
|
|
||||||
// evaluate the expression exactly once
|
// evaluate the expression exactly once
|
||||||
@@ -235,7 +235,7 @@ public func XCTAssertFalse(@autoclosure expression: () throws -> BooleanType, @a
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () throws -> T?, @autoclosure _ expression2: () throws -> T?, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () throws -> T?, @autoclosure _ expression2: () throws -> T?, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.Equal
|
let assertionType = _XCTAssertionType.Equal
|
||||||
|
|
||||||
// evaluate each expression exactly once
|
// evaluate each expression exactly once
|
||||||
@@ -276,7 +276,7 @@ public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () throws ->
|
|||||||
// Array<T>
|
// Array<T>
|
||||||
// Dictionary<T, U>
|
// Dictionary<T, U>
|
||||||
|
|
||||||
public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () throws -> ArraySlice<T>, @autoclosure _ expression2: () throws -> ArraySlice<T>, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () throws -> ArraySlice<T>, @autoclosure _ expression2: () throws -> ArraySlice<T>, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.Equal
|
let assertionType = _XCTAssertionType.Equal
|
||||||
|
|
||||||
// evaluate each expression exactly once
|
// evaluate each expression exactly once
|
||||||
@@ -314,7 +314,7 @@ public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () throws ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () throws -> ContiguousArray<T>, @autoclosure _ expression2: () throws -> ContiguousArray<T>, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () throws -> ContiguousArray<T>, @autoclosure _ expression2: () throws -> ContiguousArray<T>, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.Equal
|
let assertionType = _XCTAssertionType.Equal
|
||||||
|
|
||||||
// evaluate each expression exactly once
|
// evaluate each expression exactly once
|
||||||
@@ -352,7 +352,7 @@ public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () throws ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () throws -> [T], @autoclosure _ expression2: () throws -> [T], @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () throws -> [T], @autoclosure _ expression2: () throws -> [T], @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.Equal
|
let assertionType = _XCTAssertionType.Equal
|
||||||
|
|
||||||
// evaluate each expression exactly once
|
// evaluate each expression exactly once
|
||||||
@@ -390,7 +390,7 @@ public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () throws ->
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertEqual<T, U : Equatable>(@autoclosure expression1: () throws -> [T: U], @autoclosure _ expression2: () throws -> [T: U], @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertEqual<T, U : Equatable>(@autoclosure expression1: () throws -> [T: U], @autoclosure _ expression2: () throws -> [T: U], @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.Equal
|
let assertionType = _XCTAssertionType.Equal
|
||||||
|
|
||||||
// evaluate each expression exactly once
|
// evaluate each expression exactly once
|
||||||
@@ -428,7 +428,7 @@ public func XCTAssertEqual<T, U : Equatable>(@autoclosure expression1: () throws
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () throws -> T?, @autoclosure _ expression2: () throws -> T?, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () throws -> T?, @autoclosure _ expression2: () throws -> T?, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.NotEqual
|
let assertionType = _XCTAssertionType.NotEqual
|
||||||
|
|
||||||
// evaluate each expression exactly once
|
// evaluate each expression exactly once
|
||||||
@@ -469,7 +469,7 @@ public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () throws
|
|||||||
// Array<T>
|
// Array<T>
|
||||||
// Dictionary<T, U>
|
// Dictionary<T, U>
|
||||||
|
|
||||||
public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () throws -> ContiguousArray<T>, @autoclosure _ expression2: () throws -> ContiguousArray<T>, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () throws -> ContiguousArray<T>, @autoclosure _ expression2: () throws -> ContiguousArray<T>, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.NotEqual
|
let assertionType = _XCTAssertionType.NotEqual
|
||||||
|
|
||||||
// evaluate each expression exactly once
|
// evaluate each expression exactly once
|
||||||
@@ -507,7 +507,7 @@ public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () throws
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () throws -> ArraySlice<T>, @autoclosure _ expression2: () throws -> ArraySlice<T>, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () throws -> ArraySlice<T>, @autoclosure _ expression2: () throws -> ArraySlice<T>, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.NotEqual
|
let assertionType = _XCTAssertionType.NotEqual
|
||||||
|
|
||||||
// evaluate each expression exactly once
|
// evaluate each expression exactly once
|
||||||
@@ -545,7 +545,7 @@ public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () throws
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () throws -> [T], @autoclosure _ expression2: () throws -> [T], @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () throws -> [T], @autoclosure _ expression2: () throws -> [T], @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.NotEqual
|
let assertionType = _XCTAssertionType.NotEqual
|
||||||
|
|
||||||
// evaluate each expression exactly once
|
// evaluate each expression exactly once
|
||||||
@@ -583,7 +583,7 @@ public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () throws
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertNotEqual<T, U : Equatable>(@autoclosure expression1: () throws -> [T: U], @autoclosure _ expression2: () throws -> [T: U], @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertNotEqual<T, U : Equatable>(@autoclosure expression1: () throws -> [T: U], @autoclosure _ expression2: () throws -> [T: U], @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.NotEqual
|
let assertionType = _XCTAssertionType.NotEqual
|
||||||
|
|
||||||
// evaluate each expression exactly once
|
// evaluate each expression exactly once
|
||||||
@@ -636,7 +636,7 @@ func _XCTCheckEqualWithAccuracy_CGFloat(value1: CGFloat, _ value2: CGFloat, _ ac
|
|||||||
&& (abs(value1 - value2) <= accuracy)
|
&& (abs(value1 - value2) <= accuracy)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertEqualWithAccuracy<T : FloatingPointType>(@autoclosure expression1: () throws -> T, @autoclosure _ expression2: () throws -> T, accuracy: T, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertEqualWithAccuracy<T : FloatingPointType>(@autoclosure expression1: () throws -> T, @autoclosure _ expression2: () throws -> T, accuracy: T, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.EqualWithAccuracy
|
let assertionType = _XCTAssertionType.EqualWithAccuracy
|
||||||
|
|
||||||
// evaluate each expression exactly once
|
// evaluate each expression exactly once
|
||||||
@@ -707,7 +707,7 @@ func _XCTCheckNotEqualWithAccuracy_CGFloat(value1: CGFloat, _ value2: CGFloat, _
|
|||||||
|| (abs(value1 - value2) > accuracy)
|
|| (abs(value1 - value2) > accuracy)
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertNotEqualWithAccuracy<T : FloatingPointType>(@autoclosure expression1: () throws -> T, @autoclosure _ expression2: () throws -> T, _ accuracy: T, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertNotEqualWithAccuracy<T : FloatingPointType>(@autoclosure expression1: () throws -> T, @autoclosure _ expression2: () throws -> T, _ accuracy: T, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.NotEqualWithAccuracy
|
let assertionType = _XCTAssertionType.NotEqualWithAccuracy
|
||||||
|
|
||||||
// evaluate each expression exactly once
|
// evaluate each expression exactly once
|
||||||
@@ -763,7 +763,7 @@ public func XCTAssertNotEqualWithAccuracy<T : FloatingPointType>(@autoclosure ex
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertGreaterThan<T : Comparable>(@autoclosure expression1: () throws -> T, @autoclosure _ expression2: () throws -> T, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertGreaterThan<T : Comparable>(@autoclosure expression1: () throws -> T, @autoclosure _ expression2: () throws -> T, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.GreaterThan
|
let assertionType = _XCTAssertionType.GreaterThan
|
||||||
|
|
||||||
// evaluate each expression exactly once
|
// evaluate each expression exactly once
|
||||||
@@ -801,7 +801,7 @@ public func XCTAssertGreaterThan<T : Comparable>(@autoclosure expression1: () th
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertGreaterThanOrEqual<T : Comparable>(@autoclosure expression1: () throws -> T, @autoclosure _ expression2: () throws -> T, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__)
|
public func XCTAssertGreaterThanOrEqual<T : Comparable>(@autoclosure expression1: () throws -> T, @autoclosure _ expression2: () throws -> T, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line)
|
||||||
{
|
{
|
||||||
let assertionType = _XCTAssertionType.GreaterThanOrEqual
|
let assertionType = _XCTAssertionType.GreaterThanOrEqual
|
||||||
|
|
||||||
@@ -840,7 +840,7 @@ public func XCTAssertGreaterThanOrEqual<T : Comparable>(@autoclosure expression1
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertLessThan<T : Comparable>(@autoclosure expression1: () throws -> T, @autoclosure _ expression2: () throws -> T, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertLessThan<T : Comparable>(@autoclosure expression1: () throws -> T, @autoclosure _ expression2: () throws -> T, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.LessThan
|
let assertionType = _XCTAssertionType.LessThan
|
||||||
|
|
||||||
// evaluate each expression exactly once
|
// evaluate each expression exactly once
|
||||||
@@ -878,7 +878,7 @@ public func XCTAssertLessThan<T : Comparable>(@autoclosure expression1: () throw
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertLessThanOrEqual<T : Comparable>(@autoclosure expression1: () throws -> T, @autoclosure _ expression2: () throws -> T, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__)
|
public func XCTAssertLessThanOrEqual<T : Comparable>(@autoclosure expression1: () throws -> T, @autoclosure _ expression2: () throws -> T, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line)
|
||||||
{
|
{
|
||||||
let assertionType = _XCTAssertionType.LessThanOrEqual
|
let assertionType = _XCTAssertionType.LessThanOrEqual
|
||||||
|
|
||||||
@@ -917,7 +917,7 @@ public func XCTAssertLessThanOrEqual<T : Comparable>(@autoclosure expression1: (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertThrowsError<T>(@autoclosure expression: () throws -> T, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__, _ errorHandler: (error: ErrorType) -> Void = { _ in }) -> Void {
|
public func XCTAssertThrowsError<T>(@autoclosure expression: () throws -> T, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line, _ errorHandler: (error: ErrorType) -> Void = { _ in }) -> Void {
|
||||||
// evaluate expression exactly once
|
// evaluate expression exactly once
|
||||||
var caughtErrorOptional: ErrorType?
|
var caughtErrorOptional: ErrorType?
|
||||||
|
|
||||||
@@ -951,37 +951,37 @@ public func XCTAssertThrowsError<T>(@autoclosure expression: () throws -> T, @au
|
|||||||
#if XCTEST_ENABLE_EXCEPTION_ASSERTIONS
|
#if XCTEST_ENABLE_EXCEPTION_ASSERTIONS
|
||||||
// --- Currently-Unsupported Assertions ---
|
// --- Currently-Unsupported Assertions ---
|
||||||
|
|
||||||
public func XCTAssertThrows(@autoclosure expression: () -> Any?, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertThrows(@autoclosure expression: () -> Any?, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.Assertion_Throws
|
let assertionType = _XCTAssertionType.Assertion_Throws
|
||||||
|
|
||||||
// FIXME: Unsupported
|
// FIXME: Unsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertThrowsSpecific(@autoclosure expression: () -> Any?, _ exception: Any, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertThrowsSpecific(@autoclosure expression: () -> Any?, _ exception: Any, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.Assertion_ThrowsSpecific
|
let assertionType = _XCTAssertionType.Assertion_ThrowsSpecific
|
||||||
|
|
||||||
// FIXME: Unsupported
|
// FIXME: Unsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertThrowsSpecificNamed(@autoclosure expression: () -> Any?, _ exception: Any, _ name: String, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertThrowsSpecificNamed(@autoclosure expression: () -> Any?, _ exception: Any, _ name: String, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.Assertion_ThrowsSpecificNamed
|
let assertionType = _XCTAssertionType.Assertion_ThrowsSpecificNamed
|
||||||
|
|
||||||
// FIXME: Unsupported
|
// FIXME: Unsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertNoThrow(@autoclosure expression: () -> Any?, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertNoThrow(@autoclosure expression: () -> Any?, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.Assertion_NoThrow
|
let assertionType = _XCTAssertionType.Assertion_NoThrow
|
||||||
|
|
||||||
// FIXME: Unsupported
|
// FIXME: Unsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertNoThrowSpecific(@autoclosure expression: () -> Any?, _ exception: Any, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertNoThrowSpecific(@autoclosure expression: () -> Any?, _ exception: Any, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.Assertion_NoThrowSpecific
|
let assertionType = _XCTAssertionType.Assertion_NoThrowSpecific
|
||||||
|
|
||||||
// FIXME: Unsupported
|
// FIXME: Unsupported
|
||||||
}
|
}
|
||||||
|
|
||||||
public func XCTAssertNoThrowSpecificNamed(@autoclosure expression: () -> Any?, _ exception: Any, _ name: String, @autoclosure _ message: () -> String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertNoThrowSpecificNamed(@autoclosure expression: () -> Any?, _ exception: Any, _ name: String, @autoclosure _ message: () -> String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
let assertionType = _XCTAssertionType.Assertion_NoThrowSpecificNamed
|
let assertionType = _XCTAssertionType.Assertion_NoThrowSpecificNamed
|
||||||
|
|
||||||
// FIXME: Unsupported
|
// FIXME: Unsupported
|
||||||
|
|||||||
@@ -31,7 +31,7 @@
|
|||||||
public func assert(
|
public func assert(
|
||||||
@autoclosure condition: () -> Bool,
|
@autoclosure condition: () -> Bool,
|
||||||
@autoclosure _ message: () -> String = String(),
|
@autoclosure _ message: () -> String = String(),
|
||||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
file: StaticString = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
// Only assert in debug mode.
|
// Only assert in debug mode.
|
||||||
if _isDebugAssertConfiguration() {
|
if _isDebugAssertConfiguration() {
|
||||||
@@ -62,7 +62,7 @@ public func assert(
|
|||||||
public func precondition(
|
public func precondition(
|
||||||
@autoclosure condition: () -> Bool,
|
@autoclosure condition: () -> Bool,
|
||||||
@autoclosure _ message: () -> String = String(),
|
@autoclosure _ message: () -> String = String(),
|
||||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
file: StaticString = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
// Only check in debug and release mode. In release mode just trap.
|
// Only check in debug and release mode. In release mode just trap.
|
||||||
if _isDebugAssertConfiguration() {
|
if _isDebugAssertConfiguration() {
|
||||||
@@ -97,7 +97,7 @@ public func precondition(
|
|||||||
@inline(__always)
|
@inline(__always)
|
||||||
public func assertionFailure(
|
public func assertionFailure(
|
||||||
@autoclosure message: () -> String = String(),
|
@autoclosure message: () -> String = String(),
|
||||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
file: StaticString = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
if _isDebugAssertConfiguration() {
|
if _isDebugAssertConfiguration() {
|
||||||
_assertionFailed("fatal error", message(), file, line,
|
_assertionFailed("fatal error", message(), file, line,
|
||||||
@@ -126,7 +126,7 @@ public func assertionFailure(
|
|||||||
@_transparent @noreturn
|
@_transparent @noreturn
|
||||||
public func preconditionFailure(
|
public func preconditionFailure(
|
||||||
@autoclosure message: () -> String = String(),
|
@autoclosure message: () -> String = String(),
|
||||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
file: StaticString = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
// Only check in debug and release mode. In release mode just trap.
|
// Only check in debug and release mode. In release mode just trap.
|
||||||
if _isDebugAssertConfiguration() {
|
if _isDebugAssertConfiguration() {
|
||||||
@@ -142,7 +142,7 @@ public func preconditionFailure(
|
|||||||
@_transparent @noreturn
|
@_transparent @noreturn
|
||||||
public func fatalError(
|
public func fatalError(
|
||||||
@autoclosure message: () -> String = String(),
|
@autoclosure message: () -> String = String(),
|
||||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
file: StaticString = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
_assertionFailed("fatal error", message(), file, line,
|
_assertionFailed("fatal error", message(), file, line,
|
||||||
flags: _fatalErrorFlags())
|
flags: _fatalErrorFlags())
|
||||||
@@ -157,7 +157,7 @@ public func fatalError(
|
|||||||
@_transparent
|
@_transparent
|
||||||
public func _precondition(
|
public func _precondition(
|
||||||
@autoclosure condition: () -> Bool, _ message: StaticString = StaticString(),
|
@autoclosure condition: () -> Bool, _ message: StaticString = StaticString(),
|
||||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
file: StaticString = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
// Only check in debug and release mode. In release mode just trap.
|
// Only check in debug and release mode. In release mode just trap.
|
||||||
if _isDebugAssertConfiguration() {
|
if _isDebugAssertConfiguration() {
|
||||||
@@ -174,7 +174,7 @@ public func _precondition(
|
|||||||
@_transparent @noreturn
|
@_transparent @noreturn
|
||||||
public func _preconditionFailure(
|
public func _preconditionFailure(
|
||||||
message: StaticString = StaticString(),
|
message: StaticString = StaticString(),
|
||||||
file: StaticString = __FILE__, line: UInt = __LINE__) {
|
file: StaticString = #file, line: UInt = #line) {
|
||||||
|
|
||||||
_precondition(false, message, file:file, line: line)
|
_precondition(false, message, file:file, line: line)
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ public func _preconditionFailure(
|
|||||||
@_transparent
|
@_transparent
|
||||||
public func _overflowChecked<T>(
|
public func _overflowChecked<T>(
|
||||||
args: (T, Bool),
|
args: (T, Bool),
|
||||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
file: StaticString = #file, line: UInt = #line
|
||||||
) -> T {
|
) -> T {
|
||||||
let (result, error) = args
|
let (result, error) = args
|
||||||
if _isDebugAssertConfiguration() {
|
if _isDebugAssertConfiguration() {
|
||||||
@@ -212,7 +212,7 @@ public func _overflowChecked<T>(
|
|||||||
@_transparent
|
@_transparent
|
||||||
public func _debugPrecondition(
|
public func _debugPrecondition(
|
||||||
@autoclosure condition: () -> Bool, _ message: StaticString = StaticString(),
|
@autoclosure condition: () -> Bool, _ message: StaticString = StaticString(),
|
||||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
file: StaticString = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
// Only check in debug mode.
|
// Only check in debug mode.
|
||||||
if _isDebugAssertConfiguration() {
|
if _isDebugAssertConfiguration() {
|
||||||
@@ -226,7 +226,7 @@ public func _debugPrecondition(
|
|||||||
@_transparent @noreturn
|
@_transparent @noreturn
|
||||||
public func _debugPreconditionFailure(
|
public func _debugPreconditionFailure(
|
||||||
message: StaticString = StaticString(),
|
message: StaticString = StaticString(),
|
||||||
file: StaticString = __FILE__, line: UInt = __LINE__) {
|
file: StaticString = #file, line: UInt = #line) {
|
||||||
if _isDebugAssertConfiguration() {
|
if _isDebugAssertConfiguration() {
|
||||||
_precondition(false, message, file: file, line: line)
|
_precondition(false, message, file: file, line: line)
|
||||||
}
|
}
|
||||||
@@ -242,7 +242,7 @@ public func _debugPreconditionFailure(
|
|||||||
@_transparent
|
@_transparent
|
||||||
public func _sanityCheck(
|
public func _sanityCheck(
|
||||||
@autoclosure condition: () -> Bool, _ message: StaticString = StaticString(),
|
@autoclosure condition: () -> Bool, _ message: StaticString = StaticString(),
|
||||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
file: StaticString = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
#if INTERNAL_CHECKS_ENABLED
|
#if INTERNAL_CHECKS_ENABLED
|
||||||
if !_branchHint(condition(), true) {
|
if !_branchHint(condition(), true) {
|
||||||
@@ -255,7 +255,7 @@ public func _sanityCheck(
|
|||||||
@_transparent @noreturn
|
@_transparent @noreturn
|
||||||
public func _sanityCheckFailure(
|
public func _sanityCheckFailure(
|
||||||
message: StaticString = StaticString(),
|
message: StaticString = StaticString(),
|
||||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
file: StaticString = #file, line: UInt = #line
|
||||||
) {
|
) {
|
||||||
_sanityCheck(false, message, file: file, line: line)
|
_sanityCheck(false, message, file: file, line: line)
|
||||||
_conditionallyUnreachable()
|
_conditionallyUnreachable()
|
||||||
|
|||||||
@@ -210,13 +210,13 @@ func _fatalErrorMessage(
|
|||||||
@_transparent @noreturn
|
@_transparent @noreturn
|
||||||
public // COMPILER_INTRINSIC
|
public // COMPILER_INTRINSIC
|
||||||
func _unimplemented_initializer(className: StaticString,
|
func _unimplemented_initializer(className: StaticString,
|
||||||
initName: StaticString = __FUNCTION__,
|
initName: StaticString = #function,
|
||||||
file: StaticString = __FILE__,
|
file: StaticString = #file,
|
||||||
line: UInt = __LINE__,
|
line: UInt = #line,
|
||||||
column: UInt = __COLUMN__) {
|
column: UInt = #column) {
|
||||||
// This function is marked @_transparent so that it is inlined into the caller
|
// This function is marked @_transparent so that it is inlined into the caller
|
||||||
// (the initializer stub), and, depending on the build configuration,
|
// (the initializer stub), and, depending on the build configuration,
|
||||||
// redundant parameter values (__FILE__ etc.) are eliminated, and don't leak
|
// redundant parameter values (#file etc.) are eliminated, and don't leak
|
||||||
// information about the user's source.
|
// information about the user's source.
|
||||||
|
|
||||||
if _isDebugAssertConfiguration() {
|
if _isDebugAssertConfiguration() {
|
||||||
@@ -254,7 +254,7 @@ func _unimplemented_initializer(className: StaticString,
|
|||||||
public // COMPILER_INTRINSIC
|
public // COMPILER_INTRINSIC
|
||||||
func _undefined<T>(
|
func _undefined<T>(
|
||||||
@autoclosure message: () -> String = String(),
|
@autoclosure message: () -> String = String(),
|
||||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
file: StaticString = #file, line: UInt = #line
|
||||||
) -> T {
|
) -> T {
|
||||||
_assertionFailed("fatal error", message(), file, line,
|
_assertionFailed("fatal error", message(), file, line,
|
||||||
flags: 0)
|
flags: 0)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ import SwiftShims
|
|||||||
% traversals = ['Forward', 'Bidirectional', 'RandomAccess']
|
% traversals = ['Forward', 'Bidirectional', 'RandomAccess']
|
||||||
|
|
||||||
@noreturn @inline(never)
|
@noreturn @inline(never)
|
||||||
internal func _abstract(file: StaticString = __FILE__, line: UInt = __LINE__) {
|
internal func _abstract(file: StaticString = #file, line: UInt = #line) {
|
||||||
fatalError("Method must be overridden", file: file, line: line)
|
fatalError("Method must be overridden", file: file, line: line)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ func rejectsAssertStringLiteral() {
|
|||||||
|
|
||||||
|
|
||||||
// <rdar://problem/22243469> QoI: Poor error message with throws, default arguments, & overloads
|
// <rdar://problem/22243469> QoI: Poor error message with throws, default arguments, & overloads
|
||||||
func process(line: UInt = __LINE__, _ fn: () -> Void) {}
|
func process(line: UInt = #line, _ fn: () -> Void) {}
|
||||||
func process(line: UInt = __LINE__) -> Int { return 0 }
|
func process(line: UInt = #line) -> Int { return 0 }
|
||||||
func dangerous() throws {}
|
func dangerous() throws {}
|
||||||
|
|
||||||
func test() {
|
func test() {
|
||||||
|
|||||||
@@ -321,7 +321,7 @@ trailingclosure3(x: 5) { return 5 }
|
|||||||
func trailingclosure4(f f: () -> Int) {}
|
func trailingclosure4(f f: () -> Int) {}
|
||||||
trailingclosure4 { 5 }
|
trailingclosure4 { 5 }
|
||||||
|
|
||||||
func trailingClosure5<T>(file: String = __FILE__, line: UInt = __LINE__, expression: () -> T?) { }
|
func trailingClosure5<T>(file: String = #file, line: UInt = #line, expression: () -> T?) { }
|
||||||
func trailingClosure6<T>(value value: Int, expression: () -> T?) { }
|
func trailingClosure6<T>(value value: Int, expression: () -> T?) { }
|
||||||
|
|
||||||
trailingClosure5(file: "hello", line: 17) { return Optional.Some(5) } // expected-error{{extraneous argument label 'file:' in call}}{{18-24=}}
|
trailingClosure5(file: "hello", line: 17) { return Optional.Some(5) } // expected-error{{extraneous argument label 'file:' in call}}{{18-24=}}
|
||||||
|
|||||||
@@ -16,10 +16,10 @@
|
|||||||
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=DEFAULT_ARG_INIT_4 | FileCheck %s -check-prefix=DEFAULT_ARG_INIT
|
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=DEFAULT_ARG_INIT_4 | FileCheck %s -check-prefix=DEFAULT_ARG_INIT
|
||||||
|
|
||||||
func freeFuncWithDefaultArgs1(
|
func freeFuncWithDefaultArgs1(
|
||||||
a: Int, b: Int = 42, file: String = __FILE__, line: Int = __LINE__,
|
a: Int, b: Int = 42, file: String = #file, line: Int = #line,
|
||||||
column: Int = __COLUMN__, function: String = __FUNCTION__) {
|
column: Int = #column, function: String = #function) {
|
||||||
}
|
}
|
||||||
func freeFuncWithDefaultArgs2(file file: String = __FILE__) {}
|
func freeFuncWithDefaultArgs2(file file: String = #file) {}
|
||||||
func freeFuncWithDefaultArgs3(a a: Int = 0) {}
|
func freeFuncWithDefaultArgs3(a a: Int = 0) {}
|
||||||
func freeFuncWithDefaultArgs4(a: Int, b: Int = 0, c: Int = 0) {}
|
func freeFuncWithDefaultArgs4(a: Int, b: Int = 0, c: Int = 0) {}
|
||||||
|
|
||||||
|
|||||||
@@ -129,8 +129,8 @@ func testUnreachableAfterNoReturnMethod() -> Int {
|
|||||||
|
|
||||||
func testCleanupCodeEmptyTuple(@autoclosure fn: () -> Bool = false,
|
func testCleanupCodeEmptyTuple(@autoclosure fn: () -> Bool = false,
|
||||||
message: String = "",
|
message: String = "",
|
||||||
file: String = __FILE__,
|
file: String = #file,
|
||||||
line: Int = __LINE__) {
|
line: Int = #line) {
|
||||||
if true {
|
if true {
|
||||||
exit()
|
exit()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -223,9 +223,9 @@ class NoEscapeImmediatelyApplied {
|
|||||||
|
|
||||||
|
|
||||||
// Reduced example from XCTest overlay, involves a TupleShuffleExpr
|
// Reduced example from XCTest overlay, involves a TupleShuffleExpr
|
||||||
public func XCTAssertTrue(@autoclosure expression: () -> BooleanType, _ message: String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssertTrue(@autoclosure expression: () -> BooleanType, _ message: String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
}
|
}
|
||||||
public func XCTAssert( @autoclosure expression: () -> BooleanType, _ message: String = "", file: StaticString = __FILE__, line: UInt = __LINE__) -> Void {
|
public func XCTAssert( @autoclosure expression: () -> BooleanType, _ message: String = "", file: StaticString = #file, line: UInt = #line) -> Void {
|
||||||
XCTAssertTrue(expression, message, file: file, line: line);
|
XCTAssertTrue(expression, message, file: file, line: line);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -583,9 +583,14 @@ func iterators() {
|
|||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
||||||
func magic_literals() {
|
func magic_literals() {
|
||||||
_ = __FILE__
|
_ = __FILE__ // expected-warning {{__FILE__ is deprecated and will be removed in Swift 3, please use #file}}
|
||||||
_ = __LINE__ + __COLUMN__
|
_ = __LINE__ // expected-warning {{__LINE__ is deprecated and will be removed in Swift 3, please use #line}}
|
||||||
var _: UInt8 = __LINE__ + __COLUMN__
|
_ = __COLUMN__ // expected-warning {{__COLUMN__ is deprecated and will be removed in Swift 3, please use #column}}
|
||||||
|
_ = __DSO_HANDLE__ // expected-warning {{__DSO_HANDLE__ is deprecated and will be removed in Swift 3, please use #dsohandle}}
|
||||||
|
|
||||||
|
_ = #file
|
||||||
|
_ = #line + #column
|
||||||
|
var _: UInt8 = #line + #column
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|||||||
Reference in New Issue
Block a user