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,
|
||||
"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
|
||||
ERROR(expected_expr_assignment,none,
|
||||
"expected expression in assignment", ())
|
||||
|
||||
@@ -881,16 +881,31 @@ ParserResult<Expr> Parser::parseExprPostfix(Diag<> ID, bool isExprBasic) {
|
||||
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___LINE__:
|
||||
case tok::kw___COLUMN__:
|
||||
case tok::kw___FUNCTION__:
|
||||
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());
|
||||
SourceLoc Loc = consumeToken();
|
||||
Result = makeParserResult(
|
||||
|
||||
@@ -31,7 +31,7 @@ public struct SubscriptRangeTest {
|
||||
public init(
|
||||
expected: [Int], collection: [Int], bounds: Range<Int>,
|
||||
count: Int,
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.expected = expected.map(OpaqueValue.init)
|
||||
self.collection = collection.map(OpaqueValue.init)
|
||||
@@ -49,7 +49,7 @@ public struct PrefixThroughTest {
|
||||
|
||||
init(
|
||||
collection: [Int], position: Int, expected: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.collection = collection
|
||||
self.position = position
|
||||
@@ -66,7 +66,7 @@ public struct PrefixUpToTest {
|
||||
|
||||
public init(
|
||||
collection: [Int], end: Int, expected: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.collection = collection
|
||||
self.end = end
|
||||
@@ -83,7 +83,7 @@ internal struct RemoveFirstNTest {
|
||||
|
||||
init(
|
||||
collection: [Int], numberToRemove: Int, expectedCollection: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.collection = collection
|
||||
self.numberToRemove = numberToRemove
|
||||
@@ -100,7 +100,7 @@ public struct SuffixFromTest {
|
||||
|
||||
init(
|
||||
collection: [Int], start: Int, expected: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.collection = collection
|
||||
self.start = start
|
||||
@@ -305,10 +305,10 @@ extension TestSuite {
|
||||
) {
|
||||
var testNamePrefix = testNamePrefix
|
||||
|
||||
if checksAdded.value.contains(__FUNCTION__) {
|
||||
if checksAdded.value.contains(#function) {
|
||||
return
|
||||
}
|
||||
checksAdded.value.insert(__FUNCTION__)
|
||||
checksAdded.value.insert(#function)
|
||||
|
||||
addSequenceTests(
|
||||
testNamePrefix,
|
||||
@@ -842,10 +842,10 @@ self.test("\(testNamePrefix).popFirst()/slice/empty/semantics") {
|
||||
outOfBoundsSubscriptOffset: Int = 1
|
||||
) {
|
||||
var testNamePrefix = testNamePrefix
|
||||
if checksAdded.value.contains(__FUNCTION__) {
|
||||
if checksAdded.value.contains(#function) {
|
||||
return
|
||||
}
|
||||
checksAdded.value.insert(__FUNCTION__)
|
||||
checksAdded.value.insert(#function)
|
||||
|
||||
addForwardCollectionTests(
|
||||
testNamePrefix,
|
||||
@@ -1191,10 +1191,10 @@ self.test("\(testNamePrefix).suffix/semantics") {
|
||||
) {
|
||||
var testNamePrefix = testNamePrefix
|
||||
|
||||
if checksAdded.value.contains(__FUNCTION__) {
|
||||
if checksAdded.value.contains(#function) {
|
||||
return
|
||||
}
|
||||
checksAdded.value.insert(__FUNCTION__)
|
||||
checksAdded.value.insert(#function)
|
||||
|
||||
addBidirectionalCollectionTests(
|
||||
testNamePrefix,
|
||||
|
||||
@@ -19,7 +19,7 @@ public struct PartitionExhaustiveTest {
|
||||
|
||||
public init(
|
||||
_ sequence: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.sequence = sequence
|
||||
self.loc = SourceLoc(file, line, comment: "test data")
|
||||
@@ -102,10 +102,10 @@ extension TestSuite {
|
||||
) {
|
||||
var testNamePrefix = testNamePrefix
|
||||
|
||||
if checksAdded.value.contains(__FUNCTION__) {
|
||||
if checksAdded.value.contains(#function) {
|
||||
return
|
||||
}
|
||||
checksAdded.value.insert(__FUNCTION__)
|
||||
checksAdded.value.insert(#function)
|
||||
|
||||
addForwardCollectionTests(
|
||||
testNamePrefix,
|
||||
@@ -407,10 +407,10 @@ self.test("\(testNamePrefix).sort/${'Predicate' if predicate else 'WhereElementI
|
||||
) {
|
||||
var testNamePrefix = testNamePrefix
|
||||
|
||||
if checksAdded.value.contains(__FUNCTION__) {
|
||||
if checksAdded.value.contains(#function) {
|
||||
return
|
||||
}
|
||||
checksAdded.value.insert(__FUNCTION__)
|
||||
checksAdded.value.insert(#function)
|
||||
|
||||
addForwardMutableCollectionTests(
|
||||
testNamePrefix,
|
||||
@@ -525,10 +525,10 @@ if resiliencyChecks.subscriptOnOutOfBoundsIndicesBehavior != .None {
|
||||
) {
|
||||
var testNamePrefix = testNamePrefix
|
||||
|
||||
if checksAdded.value.contains(__FUNCTION__) {
|
||||
if checksAdded.value.contains(#function) {
|
||||
return
|
||||
}
|
||||
checksAdded.value.insert(__FUNCTION__)
|
||||
checksAdded.value.insert(#function)
|
||||
|
||||
addBidirectionalMutableCollectionTests(
|
||||
testNamePrefix,
|
||||
|
||||
@@ -69,7 +69,7 @@ internal struct ReplaceRangeTest {
|
||||
internal init(
|
||||
collection: [Int], newElements: [Int],
|
||||
rangeSelection: RangeSelection, expected: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.collection = collection.map(OpaqueValue.init)
|
||||
self.newElements = newElements.map(OpaqueValue.init)
|
||||
@@ -87,7 +87,7 @@ internal struct AppendTest {
|
||||
|
||||
internal init(
|
||||
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.newElement = OpaqueValue(newElement)
|
||||
@@ -104,7 +104,7 @@ internal struct AppendContentsOfTest {
|
||||
|
||||
internal init(
|
||||
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.newElements = newElements.map(OpaqueValue.init)
|
||||
@@ -122,7 +122,7 @@ internal struct InsertTest {
|
||||
|
||||
internal init(
|
||||
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.newElement = OpaqueValue(newElement)
|
||||
@@ -141,7 +141,7 @@ internal struct InsertContentsOfTest {
|
||||
|
||||
internal init(
|
||||
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.newElements = newElements.map(OpaqueValue.init)
|
||||
@@ -161,7 +161,7 @@ internal struct RemoveAtIndexTest {
|
||||
internal init(
|
||||
collection: [Int], indexSelection: IndexSelection,
|
||||
expectedRemovedElement: Int, expectedCollection: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.collection = collection.map(OpaqueValue.init)
|
||||
self.indexSelection = indexSelection
|
||||
@@ -179,7 +179,7 @@ internal struct RemoveLastNTest {
|
||||
|
||||
internal init(
|
||||
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.numberToRemove = numberToRemove
|
||||
@@ -196,7 +196,7 @@ internal struct RemoveRangeTest {
|
||||
|
||||
internal init(
|
||||
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.rangeSelection = rangeSelection
|
||||
@@ -212,7 +212,7 @@ internal struct RemoveAllTest {
|
||||
|
||||
internal init(
|
||||
collection: [Int], expected: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.collection = collection.map(OpaqueValue.init)
|
||||
self.expected = expected
|
||||
@@ -227,7 +227,7 @@ internal struct ReserveCapacityTest {
|
||||
|
||||
internal init(
|
||||
collection: [Int], requestedCapacity: Int,
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.collection = collection.map(OpaqueValue.init)
|
||||
self.requestedCapacity = requestedCapacity
|
||||
@@ -243,7 +243,7 @@ internal struct OperatorPlusTest {
|
||||
|
||||
internal init(
|
||||
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.rhs = rhs.map(OpaqueValue.init)
|
||||
@@ -365,10 +365,10 @@ extension TestSuite {
|
||||
) {
|
||||
var testNamePrefix = testNamePrefix
|
||||
|
||||
if checksAdded.value.contains(__FUNCTION__) {
|
||||
if checksAdded.value.contains(#function) {
|
||||
return
|
||||
}
|
||||
checksAdded.value.insert(__FUNCTION__)
|
||||
checksAdded.value.insert(#function)
|
||||
|
||||
addForwardCollectionTests(
|
||||
testNamePrefix,
|
||||
@@ -1126,10 +1126,10 @@ self.test("\(testNamePrefix).OperatorPlus") {
|
||||
) {
|
||||
var testNamePrefix = testNamePrefix
|
||||
|
||||
if checksAdded.value.contains(__FUNCTION__) {
|
||||
if checksAdded.value.contains(#function) {
|
||||
return
|
||||
}
|
||||
checksAdded.value.insert(__FUNCTION__)
|
||||
checksAdded.value.insert(#function)
|
||||
|
||||
addForwardRangeReplaceableCollectionTests(
|
||||
testNamePrefix,
|
||||
@@ -1252,10 +1252,10 @@ self.test("\(testNamePrefix).removeLast(n: Int)/whereIndexIsBidirectional/remove
|
||||
) {
|
||||
var testNamePrefix = testNamePrefix
|
||||
|
||||
if checksAdded.value.contains(__FUNCTION__) {
|
||||
if checksAdded.value.contains(#function) {
|
||||
return
|
||||
}
|
||||
checksAdded.value.insert(__FUNCTION__)
|
||||
checksAdded.value.insert(#function)
|
||||
|
||||
addBidirectionalRangeReplaceableCollectionTests(
|
||||
testNamePrefix,
|
||||
|
||||
@@ -38,10 +38,10 @@ extension TestSuite {
|
||||
var testNamePrefix = testNamePrefix
|
||||
|
||||
// Don't run the same tests twice.
|
||||
if checksAdded.value.contains(__FUNCTION__) {
|
||||
if checksAdded.value.contains(#function) {
|
||||
return
|
||||
}
|
||||
checksAdded.value.insert(__FUNCTION__)
|
||||
checksAdded.value.insert(#function)
|
||||
|
||||
addForwardRangeReplaceableCollectionTests(
|
||||
testNamePrefix,
|
||||
@@ -169,10 +169,10 @@ extension TestSuite {
|
||||
var testNamePrefix = testNamePrefix
|
||||
|
||||
// Don't run the same tests twice.
|
||||
if checksAdded.value.contains(__FUNCTION__) {
|
||||
if checksAdded.value.contains(#function) {
|
||||
return
|
||||
}
|
||||
checksAdded.value.insert(__FUNCTION__)
|
||||
checksAdded.value.insert(#function)
|
||||
|
||||
addForwardRangeReplaceableSliceTests(
|
||||
testNamePrefix,
|
||||
@@ -314,10 +314,10 @@ extension TestSuite {
|
||||
var testNamePrefix = testNamePrefix
|
||||
|
||||
// Don't run the same tests twice.
|
||||
if checksAdded.value.contains(__FUNCTION__) {
|
||||
if checksAdded.value.contains(#function) {
|
||||
return
|
||||
}
|
||||
checksAdded.value.insert(__FUNCTION__)
|
||||
checksAdded.value.insert(#function)
|
||||
|
||||
addBidirectionalRangeReplaceableSliceTests(
|
||||
testNamePrefix,
|
||||
|
||||
@@ -19,7 +19,7 @@ public struct DropFirstTest {
|
||||
public let loc: SourceLoc
|
||||
|
||||
public init(sequence: [Int], dropElements: Int, expected: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__) {
|
||||
file: String = #file, line: UInt = #line) {
|
||||
self.sequence = sequence
|
||||
self.dropElements = dropElements
|
||||
self.expected = expected
|
||||
@@ -34,7 +34,7 @@ public struct DropLastTest {
|
||||
public let loc: SourceLoc
|
||||
|
||||
public init(sequence: [Int], dropElements: Int, expected: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__) {
|
||||
file: String = #file, line: UInt = #line) {
|
||||
self.sequence = sequence
|
||||
self.dropElements = dropElements
|
||||
self.expected = expected
|
||||
@@ -54,7 +54,7 @@ public struct ElementsEqualTest {
|
||||
_ expected: Bool, _ sequence: [Int], _ other: [Int],
|
||||
_ expectedLeftoverSequence: [Int],
|
||||
_ expectedLeftoverOther: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__,
|
||||
file: String = #file, line: UInt = #line,
|
||||
comment: String = ""
|
||||
) {
|
||||
self.expected = expected
|
||||
@@ -80,7 +80,7 @@ public struct EnumerateTest {
|
||||
|
||||
public init(
|
||||
_ expected: [(Int, Int)], _ sequence: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__,
|
||||
file: String = #file, line: UInt = #line,
|
||||
comment: String = ""
|
||||
) {
|
||||
self.expected = expected
|
||||
@@ -99,7 +99,7 @@ public struct FilterTest {
|
||||
_ expected: [Int],
|
||||
_ sequence: [Int],
|
||||
_ includeElement: (Int) -> Bool,
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.expected = expected
|
||||
self.sequence = sequence
|
||||
@@ -118,7 +118,7 @@ public struct FindTest {
|
||||
public init(
|
||||
expected: Int?, element: Int, sequence: [Int],
|
||||
expectedLeftoverSequence: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.expected = expected
|
||||
self.element = MinimalEquatableValue(element)
|
||||
@@ -139,7 +139,7 @@ public struct FlatMapTest {
|
||||
expected: [Int32],
|
||||
sequence: [Int],
|
||||
transform: (Int) -> [Int32],
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.expected = expected
|
||||
self.sequence = sequence
|
||||
@@ -158,7 +158,7 @@ public struct FlatMapToOptionalTest {
|
||||
_ expected: [Int32],
|
||||
_ sequence: [Int],
|
||||
_ transform: (Int) -> Int32?,
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.expected = expected
|
||||
self.sequence = sequence
|
||||
@@ -176,7 +176,7 @@ internal struct ForEachTest {
|
||||
|
||||
init(
|
||||
_ sequence: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.sequence = sequence
|
||||
self.loc = SourceLoc(file, line, comment: "test data")
|
||||
@@ -195,7 +195,7 @@ public struct LexicographicalCompareTest {
|
||||
_ expected: ExpectedComparisonResult, _ sequence: [Int], _ other: [Int],
|
||||
_ expectedLeftoverSequence: [Int],
|
||||
_ expectedLeftoverOther: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__,
|
||||
file: String = #file, line: UInt = #line,
|
||||
comment: String = ""
|
||||
) {
|
||||
self.expected = expected
|
||||
@@ -224,7 +224,7 @@ public struct MapTest {
|
||||
_ expected: [Int32],
|
||||
_ sequence: [Int],
|
||||
_ transform: (Int) -> Int32,
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.expected = expected
|
||||
self.sequence = sequence
|
||||
@@ -247,7 +247,7 @@ public struct MinMaxElementTest {
|
||||
maxValue expectedMaxValue: Int?,
|
||||
index expectedMaxIndex: Int?,
|
||||
_ sequence: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__,
|
||||
file: String = #file, line: UInt = #line,
|
||||
comment: String = ""
|
||||
) {
|
||||
self.expectedMinValue = expectedMinValue
|
||||
@@ -266,7 +266,7 @@ public struct PrefixTest {
|
||||
public let loc: SourceLoc
|
||||
|
||||
public init(sequence: [Int], maxLength: Int, expected: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__) {
|
||||
file: String = #file, line: UInt = #line) {
|
||||
self.sequence = sequence
|
||||
self.maxLength = maxLength
|
||||
self.expected = expected
|
||||
@@ -280,7 +280,7 @@ public struct ReduceTest {
|
||||
|
||||
public init(
|
||||
_ sequence: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.sequence = sequence
|
||||
self.loc = SourceLoc(file, line, comment: "test data")
|
||||
@@ -294,7 +294,7 @@ public struct ReverseTest {
|
||||
|
||||
public init(
|
||||
_ expected: [Int], _ sequence: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.expected = expected
|
||||
self.sequence = sequence
|
||||
@@ -309,7 +309,7 @@ public struct SuffixTest {
|
||||
public let loc: SourceLoc
|
||||
|
||||
public init(sequence: [Int], maxLength: Int, expected: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__) {
|
||||
file: String = #file, line: UInt = #line) {
|
||||
self.sequence = sequence
|
||||
self.maxLength = maxLength
|
||||
self.expected = expected
|
||||
@@ -326,7 +326,7 @@ public struct SplitTest {
|
||||
public let loc: SourceLoc
|
||||
|
||||
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.maxSplit = maxSplit
|
||||
self.separator = separator
|
||||
@@ -348,7 +348,7 @@ public struct StartsWithTest {
|
||||
_ expected: Bool, _ sequence: [Int], _ prefix: [Int],
|
||||
_ expectedLeftoverSequence: [Int],
|
||||
_ expectedLeftoverPrefix: [Int],
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.expected = expected
|
||||
self.sequence = sequence
|
||||
@@ -372,7 +372,7 @@ public struct ZipTest {
|
||||
_ other: [Int32],
|
||||
leftovers expectedLeftoverSequence: [Int],
|
||||
_ expectedLeftoverOther: [Int32],
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
self.expected = expected
|
||||
self.sequence = sequence
|
||||
@@ -1455,10 +1455,10 @@ extension TestSuite {
|
||||
) {
|
||||
var testNamePrefix = testNamePrefix
|
||||
|
||||
if checksAdded.value.contains(__FUNCTION__) {
|
||||
if checksAdded.value.contains(#function) {
|
||||
return
|
||||
}
|
||||
checksAdded.value.insert(__FUNCTION__)
|
||||
checksAdded.value.insert(#function)
|
||||
|
||||
func makeWrappedSequence(elements: [OpaqueValue<Int>]) -> Sequence {
|
||||
return makeSequence(elements.map(wrapValue))
|
||||
|
||||
@@ -577,7 +577,7 @@ public func expectCustomizable<
|
||||
@autoclosure _ message: () -> String = "",
|
||||
showFrame: Bool = true,
|
||||
stackTrace: SourceLocStack = SourceLocStack(),
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
let newTrace = stackTrace.pushIf(showFrame, file: file, line: line)
|
||||
expectNotEqual(0, counters[T.self], message(), stackTrace: newTrace)
|
||||
@@ -595,7 +595,7 @@ public func expectNotCustomizable<
|
||||
@autoclosure _ message: () -> String = "",
|
||||
showFrame: Bool = true,
|
||||
stackTrace: SourceLocStack = SourceLocStack(),
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
let newTrace = stackTrace.pushIf(showFrame, file: file, line: line)
|
||||
expectNotEqual(0, counters[T.self], message(), stackTrace: newTrace)
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
TRACE = '''@autoclosure _ message: () -> String = "",
|
||||
showFrame: Bool = true,
|
||||
stackTrace: SourceLocStack = SourceLocStack(),
|
||||
file: String = __FILE__, line: UInt = __LINE__'''
|
||||
file: String = #file, line: UInt = #line'''
|
||||
|
||||
stackTrace = 'stackTrace.pushIf(showFrame, file: file, line: line)'
|
||||
}%
|
||||
|
||||
@@ -36,7 +36,7 @@ public struct SourceLoc {
|
||||
}
|
||||
|
||||
public func withCurrentLoc(
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) -> SourceLocStack {
|
||||
return SourceLocStack(self).with(SourceLoc(file, line))
|
||||
}
|
||||
@@ -74,7 +74,7 @@ public struct SourceLocStack {
|
||||
}
|
||||
|
||||
public func withCurrentLoc(
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) -> SourceLocStack {
|
||||
return with(SourceLoc(file, line))
|
||||
}
|
||||
@@ -90,7 +90,7 @@ public struct SourceLocStack {
|
||||
TRACE = '''@autoclosure _ message: () -> String = "",
|
||||
showFrame: Bool = true,
|
||||
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
|
||||
# ${TRACE1} instead, to avoid the warning about an extraneous
|
||||
@@ -876,7 +876,7 @@ public class TestSuite {
|
||||
|
||||
public func test(
|
||||
name: String,
|
||||
file: String = __FILE__, line: UInt = __LINE__,
|
||||
file: String = #file, line: UInt = #line,
|
||||
_ testFunction: () -> Void
|
||||
) {
|
||||
_TestBuilder(testSuite: self, name: name, loc: SourceLoc(file, line))
|
||||
@@ -884,7 +884,7 @@ public class TestSuite {
|
||||
}
|
||||
|
||||
public func test(
|
||||
name: String, file: String = __FILE__, line: UInt = __LINE__
|
||||
name: String, file: String = #file, line: UInt = #line
|
||||
) -> _TestBuilder {
|
||||
return _TestBuilder(testSuite: self, name: name, loc: SourceLoc(file, line))
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ extension TypeIndexed where Value : ForwardIndexType {
|
||||
@autoclosure _ message: () -> String = "",
|
||||
showFrame: Bool = true,
|
||||
stackTrace: SourceLocStack = SourceLocStack(),
|
||||
file: String = __FILE__, line: UInt = __LINE__,
|
||||
file: String = #file, line: UInt = #line,
|
||||
body: () -> R
|
||||
) -> R {
|
||||
let expected = self[t].successor()
|
||||
@@ -76,7 +76,7 @@ extension TypeIndexed where Value : Equatable {
|
||||
@autoclosure _ message: () -> String = "",
|
||||
showFrame: Bool = true,
|
||||
stackTrace: SourceLocStack = SourceLocStack(),
|
||||
file: String = __FILE__, line: UInt = __LINE__,
|
||||
file: String = #file, line: UInt = #line,
|
||||
body: () -> R
|
||||
) -> R {
|
||||
let expected = self[t]
|
||||
@@ -102,7 +102,7 @@ public func expectEqual<V: Comparable>(
|
||||
@autoclosure _ message: () -> String = "",
|
||||
showFrame: Bool = true,
|
||||
stackTrace: SourceLocStack = SourceLocStack(),
|
||||
file: String = __FILE__, line: UInt = __LINE__
|
||||
file: String = #file, line: UInt = #line
|
||||
) {
|
||||
expectEqualsUnordered(
|
||||
expected.map { (TypeIdentifier($0.0), $0.1) },
|
||||
|
||||
@@ -84,13 +84,13 @@ func _XCTRunThrowableBlock(@noescape block: () throws -> Void) -> _XCTThrowableB
|
||||
|
||||
// --- 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
|
||||
|
||||
_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
|
||||
|
||||
// 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
|
||||
|
||||
// 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.
|
||||
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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// evaluate each expression exactly once
|
||||
@@ -276,7 +276,7 @@ public func XCTAssertEqual<T : Equatable>(@autoclosure expression1: () throws ->
|
||||
// Array<T>
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// evaluate each expression exactly once
|
||||
@@ -469,7 +469,7 @@ public func XCTAssertNotEqual<T : Equatable>(@autoclosure expression1: () throws
|
||||
// Array<T>
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// evaluate each expression exactly once
|
||||
@@ -636,7 +636,7 @@ func _XCTCheckEqualWithAccuracy_CGFloat(value1: CGFloat, _ value2: CGFloat, _ ac
|
||||
&& (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
|
||||
|
||||
// evaluate each expression exactly once
|
||||
@@ -707,7 +707,7 @@ func _XCTCheckNotEqualWithAccuracy_CGFloat(value1: CGFloat, _ value2: CGFloat, _
|
||||
|| (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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
@@ -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
|
||||
|
||||
// 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
|
||||
|
||||
@@ -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
|
||||
var caughtErrorOptional: ErrorType?
|
||||
|
||||
@@ -951,37 +951,37 @@ public func XCTAssertThrowsError<T>(@autoclosure expression: () throws -> T, @au
|
||||
#if XCTEST_ENABLE_EXCEPTION_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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// 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
|
||||
|
||||
// FIXME: Unsupported
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
public func assert(
|
||||
@autoclosure condition: () -> Bool,
|
||||
@autoclosure _ message: () -> String = String(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
||||
file: StaticString = #file, line: UInt = #line
|
||||
) {
|
||||
// Only assert in debug mode.
|
||||
if _isDebugAssertConfiguration() {
|
||||
@@ -62,7 +62,7 @@ public func assert(
|
||||
public func precondition(
|
||||
@autoclosure condition: () -> Bool,
|
||||
@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.
|
||||
if _isDebugAssertConfiguration() {
|
||||
@@ -97,7 +97,7 @@ public func precondition(
|
||||
@inline(__always)
|
||||
public func assertionFailure(
|
||||
@autoclosure message: () -> String = String(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
||||
file: StaticString = #file, line: UInt = #line
|
||||
) {
|
||||
if _isDebugAssertConfiguration() {
|
||||
_assertionFailed("fatal error", message(), file, line,
|
||||
@@ -126,7 +126,7 @@ public func assertionFailure(
|
||||
@_transparent @noreturn
|
||||
public func preconditionFailure(
|
||||
@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.
|
||||
if _isDebugAssertConfiguration() {
|
||||
@@ -142,7 +142,7 @@ public func preconditionFailure(
|
||||
@_transparent @noreturn
|
||||
public func fatalError(
|
||||
@autoclosure message: () -> String = String(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
||||
file: StaticString = #file, line: UInt = #line
|
||||
) {
|
||||
_assertionFailed("fatal error", message(), file, line,
|
||||
flags: _fatalErrorFlags())
|
||||
@@ -157,7 +157,7 @@ public func fatalError(
|
||||
@_transparent
|
||||
public func _precondition(
|
||||
@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.
|
||||
if _isDebugAssertConfiguration() {
|
||||
@@ -174,7 +174,7 @@ public func _precondition(
|
||||
@_transparent @noreturn
|
||||
public func _preconditionFailure(
|
||||
message: StaticString = StaticString(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__) {
|
||||
file: StaticString = #file, line: UInt = #line) {
|
||||
|
||||
_precondition(false, message, file:file, line: line)
|
||||
|
||||
@@ -187,7 +187,7 @@ public func _preconditionFailure(
|
||||
@_transparent
|
||||
public func _overflowChecked<T>(
|
||||
args: (T, Bool),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
||||
file: StaticString = #file, line: UInt = #line
|
||||
) -> T {
|
||||
let (result, error) = args
|
||||
if _isDebugAssertConfiguration() {
|
||||
@@ -212,7 +212,7 @@ public func _overflowChecked<T>(
|
||||
@_transparent
|
||||
public func _debugPrecondition(
|
||||
@autoclosure condition: () -> Bool, _ message: StaticString = StaticString(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
||||
file: StaticString = #file, line: UInt = #line
|
||||
) {
|
||||
// Only check in debug mode.
|
||||
if _isDebugAssertConfiguration() {
|
||||
@@ -226,7 +226,7 @@ public func _debugPrecondition(
|
||||
@_transparent @noreturn
|
||||
public func _debugPreconditionFailure(
|
||||
message: StaticString = StaticString(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__) {
|
||||
file: StaticString = #file, line: UInt = #line) {
|
||||
if _isDebugAssertConfiguration() {
|
||||
_precondition(false, message, file: file, line: line)
|
||||
}
|
||||
@@ -242,7 +242,7 @@ public func _debugPreconditionFailure(
|
||||
@_transparent
|
||||
public func _sanityCheck(
|
||||
@autoclosure condition: () -> Bool, _ message: StaticString = StaticString(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
||||
file: StaticString = #file, line: UInt = #line
|
||||
) {
|
||||
#if INTERNAL_CHECKS_ENABLED
|
||||
if !_branchHint(condition(), true) {
|
||||
@@ -255,7 +255,7 @@ public func _sanityCheck(
|
||||
@_transparent @noreturn
|
||||
public func _sanityCheckFailure(
|
||||
message: StaticString = StaticString(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
||||
file: StaticString = #file, line: UInt = #line
|
||||
) {
|
||||
_sanityCheck(false, message, file: file, line: line)
|
||||
_conditionallyUnreachable()
|
||||
|
||||
@@ -210,13 +210,13 @@ func _fatalErrorMessage(
|
||||
@_transparent @noreturn
|
||||
public // COMPILER_INTRINSIC
|
||||
func _unimplemented_initializer(className: StaticString,
|
||||
initName: StaticString = __FUNCTION__,
|
||||
file: StaticString = __FILE__,
|
||||
line: UInt = __LINE__,
|
||||
column: UInt = __COLUMN__) {
|
||||
initName: StaticString = #function,
|
||||
file: StaticString = #file,
|
||||
line: UInt = #line,
|
||||
column: UInt = #column) {
|
||||
// This function is marked @_transparent so that it is inlined into the caller
|
||||
// (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.
|
||||
|
||||
if _isDebugAssertConfiguration() {
|
||||
@@ -254,7 +254,7 @@ func _unimplemented_initializer(className: StaticString,
|
||||
public // COMPILER_INTRINSIC
|
||||
func _undefined<T>(
|
||||
@autoclosure message: () -> String = String(),
|
||||
file: StaticString = __FILE__, line: UInt = __LINE__
|
||||
file: StaticString = #file, line: UInt = #line
|
||||
) -> T {
|
||||
_assertionFailed("fatal error", message(), file, line,
|
||||
flags: 0)
|
||||
|
||||
@@ -15,7 +15,7 @@ import SwiftShims
|
||||
% traversals = ['Forward', 'Bidirectional', 'RandomAccess']
|
||||
|
||||
@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)
|
||||
}
|
||||
|
||||
|
||||
@@ -48,8 +48,8 @@ func rejectsAssertStringLiteral() {
|
||||
|
||||
|
||||
// <rdar://problem/22243469> QoI: Poor error message with throws, default arguments, & overloads
|
||||
func process(line: UInt = __LINE__, _ fn: () -> Void) {}
|
||||
func process(line: UInt = __LINE__) -> Int { return 0 }
|
||||
func process(line: UInt = #line, _ fn: () -> Void) {}
|
||||
func process(line: UInt = #line) -> Int { return 0 }
|
||||
func dangerous() throws {}
|
||||
|
||||
func test() {
|
||||
|
||||
@@ -321,7 +321,7 @@ trailingclosure3(x: 5) { return 5 }
|
||||
func trailingclosure4(f f: () -> Int) {}
|
||||
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?) { }
|
||||
|
||||
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
|
||||
|
||||
func freeFuncWithDefaultArgs1(
|
||||
a: Int, b: Int = 42, file: String = __FILE__, line: Int = __LINE__,
|
||||
column: Int = __COLUMN__, function: String = __FUNCTION__) {
|
||||
a: Int, b: Int = 42, file: String = #file, line: Int = #line,
|
||||
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 freeFuncWithDefaultArgs4(a: Int, b: Int = 0, c: Int = 0) {}
|
||||
|
||||
|
||||
@@ -129,8 +129,8 @@ func testUnreachableAfterNoReturnMethod() -> Int {
|
||||
|
||||
func testCleanupCodeEmptyTuple(@autoclosure fn: () -> Bool = false,
|
||||
message: String = "",
|
||||
file: String = __FILE__,
|
||||
line: Int = __LINE__) {
|
||||
file: String = #file,
|
||||
line: Int = #line) {
|
||||
if true {
|
||||
exit()
|
||||
}
|
||||
|
||||
@@ -223,9 +223,9 @@ class NoEscapeImmediatelyApplied {
|
||||
|
||||
|
||||
// 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);
|
||||
}
|
||||
|
||||
|
||||
@@ -583,9 +583,14 @@ func iterators() {
|
||||
//===----------------------------------------------------------------------===//
|
||||
|
||||
func magic_literals() {
|
||||
_ = __FILE__
|
||||
_ = __LINE__ + __COLUMN__
|
||||
var _: UInt8 = __LINE__ + __COLUMN__
|
||||
_ = __FILE__ // expected-warning {{__FILE__ is deprecated and will be removed in Swift 3, please use #file}}
|
||||
_ = __LINE__ // expected-warning {{__LINE__ is deprecated and will be removed in Swift 3, please use #line}}
|
||||
_ = __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