Replaced all uses of assert with require (#3309)

JVM assertions have to be enabled with the -ea flag so it's possible for these checks to be ignored.
This commit is contained in:
Shams Asari
2018-06-06 00:31:41 +01:00
committed by GitHub
parent 75f2c4a0a4
commit d620e71bb6
16 changed files with 65 additions and 64 deletions

View File

@ -204,7 +204,7 @@ class UniversalContract : Contract {
val rest = extractRemainder(arr, action)
// for now - let's assume not
assert(rest is Zero)
require(rest is Zero)
requireThat {
"action must have a time-window" using (tx.timeWindow != null)

View File

@ -125,7 +125,7 @@ fun actions(arrangement: Arrangement): Map<String, Action> = when (arrangement)
}
fun debugCompare(left: String, right: String) {
assert(left == right)
require(left == right)
}
fun <T> debugCompare(perLeft: Perceivable<T>, perRight: Perceivable<T>) {
@ -142,7 +142,7 @@ fun <T> debugCompare(perLeft: Perceivable<T>, perRight: Perceivable<T>) {
if (perRight is PerceivableOperation) {
debugCompare(perLeft.left, perRight.left)
debugCompare(perLeft.right, perRight.right)
assert(perLeft.op == perRight.op)
require(perLeft.op == perRight.op)
return
}
}
@ -152,7 +152,7 @@ fun <T> debugCompare(perLeft: Perceivable<T>, perRight: Perceivable<T>) {
debugCompare(perLeft.interest, perRight.interest)
debugCompare(perLeft.start, perRight.start)
debugCompare(perLeft.end, perRight.end)
assert(perLeft.dayCountConvention == perRight.dayCountConvention)
require(perLeft.dayCountConvention == perRight.dayCountConvention)
return
}
}
@ -166,25 +166,25 @@ fun <T> debugCompare(perLeft: Perceivable<T>, perRight: Perceivable<T>) {
}
}
assert(false)
require(false)
}
fun debugCompare(parLeft: Party, parRight: Party) {
assert(parLeft == parRight)
require(parLeft == parRight)
}
fun debugCompare(left: Frequency, right: Frequency) {
assert(left == right)
require(left == right)
}
fun debugCompare(left: LocalDate, right: LocalDate) {
assert(left == right)
require(left == right)
}
fun debugCompare(parLeft: Set<Party>, parRight: Set<Party>) {
if (parLeft == parRight) return
assert(parLeft == parRight)
require(parLeft == parRight)
}
fun debugCompare(arrLeft: Arrangement, arrRight: Arrangement) {
@ -229,5 +229,5 @@ fun debugCompare(arrLeft: Arrangement, arrRight: Arrangement) {
}
}
assert(false)
require(false)
}