stdlib: don't use assert() in stdlib implementation

Swift SVN r18653
This commit is contained in:
Dmitri Hrybenko
2014-05-28 20:43:56 +00:00
parent 5718e5fe3d
commit 473ad2e1eb
4 changed files with 10 additions and 6 deletions

View File

@@ -210,7 +210,7 @@ extension ArrayBuffer {
// Could be sped up, e.g. by using
// enumerateObjectsAtIndexes:options:usingBlock:
for i in subRange {
assert(ns.objectAtIndex(i) is T,
_precondition(ns.objectAtIndex(i) is T,
"NSArray element failed to match the Swift Array Element type")
}
}

View File

@@ -375,9 +375,11 @@ func ${op} (lhs: ${Self}, rhs: ${Self}) -> Bool {
@transparent
func ${op} (lhs: ${Self}, rhs: ${Self}) -> ${Self} {
% if signed:
assert(U${Self}(rhs) < U${Self}(sizeofValue(rhs) * 8))
_precondition(U${Self}(rhs) < U${Self}(sizeofValue(rhs) * 8),
"shift amount is larger than type size in bits")
% else:
assert(rhs < ${Self}(sizeofValue(rhs) * 8))
_precondition(rhs < ${Self}(sizeofValue(rhs) * 8),
"shift amount is larger than type size in bits")
% end
return ${Self}(Builtin.${name}_${BuiltinName}(lhs.value, rhs.value))
}

View File

@@ -483,8 +483,10 @@ extension ${Self} {
% for srcBits in allFloatBits:
% That = floatName(srcBits)
init(_ v: ${That}) {
assert(v >= ${That}(${Self}.min))
assert(v <= ${That}(${Self}.max))
_precondition(v >= ${That}(${Self}.min),
"floating point value can not be converted to ${Self} because it is greater than ${Self}.min")
_precondition(v <= ${That}(${Self}.max),
"floating point value can not be converted to ${Self} because it is less than ${Self}.min")
value = Builtin.fpto${sign}i_FPIEEE${srcBits}_${BuiltinName}(v.value)
}
% end

View File

@@ -91,7 +91,7 @@ case "32": let x = Int64(pf)
default: break
}
// CHECK: assertion failed: file {{.*}}/FloatingPoint.swift, line {{[0-9]*}}
// CHECK: fatal error: floating point value can not be converted
// CHECK-NEXT: CRASHED: SIG{{ILL|TRAP}}
println("BUSTED: should have crashed already")
exit(1)