Universal: fixed syntax issue that should have resulted in compile error

This commit is contained in:
sofusmortensen 2016-09-18 18:09:00 +02:00
parent 9c5ef6cdfe
commit 2299b3beae
3 changed files with 70 additions and 14 deletions

View File

@ -90,6 +90,14 @@ open class ContractBuilder {
fun <T> String.givenThat(@Suppress("UNUSED_PARAMETER") ignore1: T, @Suppress("UNUSED_PARAMETER") ignore2: T) {
}
@Deprecated(level = DeprecationLevel.ERROR, message = "Not available")
fun Party.may(init: ActionBuilder.() -> Action) {
}
@Deprecated(level = DeprecationLevel.ERROR, message = "Not available")
fun Set<Party>.may(init: ActionBuilder.() -> Action) {
}
/* fun Party.gives(beneficiary: Party, amount: Perceivable<Long>, currency: Currency) {
contracts.add( Transfer(amount, currency, this, beneficiary))
}*/

View File

@ -64,6 +64,7 @@ class ContractDefinition {
actions {
acmeCorp.may {
"exercise".anytime {
actions {
(acmeCorp or highStreetBank).may {
"execute".givenThat(after("2017-09-01")) {
highStreetBank.gives(acmeCorp, 1.M, EUR)
@ -72,6 +73,7 @@ class ContractDefinition {
}
}
}
}
highStreetBank.may {
"expire".givenThat(after("2017-09-01")) {
zero
@ -81,8 +83,52 @@ class ContractDefinition {
}
/* @Test
fun `builder problem - should not compile`() {
val arr = arrange {
actions {
acmeCorp.may {
"execute".anytime {
acmeCorp.may {
"problem".anytime {
highStreetBank.gives(acmeCorp, 1.M, USD)
}
}
}
}
}
}
assert( arr is Actions )
if (arr is Actions) {
assert( arr.actions.size == 1)
}
}
*/
@Test
fun test() {
fun `builder problem - legal`() {
val arr = arrange {
actions {
acmeCorp.may {
"execute".anytime {
actions {
acmeCorp.may {
"problem".anytime {
highStreetBank.gives(acmeCorp, 1.M, USD)
}
}
}
}
}
}
}
assert( arr is Actions )
if (arr is Actions) {
assert( arr.actions.size == 1)
}
}
}
}

View File

@ -22,6 +22,7 @@ class Swaption {
"proceed".givenThat(after("01/07/2015")) {
highStreetBank.gives(acmeCorp, libor(notional, "01/04/2015", "01/07/2015"), currency)
acmeCorp.gives(highStreetBank, interest(notional, "act/365", coupon, "01/04/2015", "01/07/2015"), currency)
actions {
(highStreetBank or acmeCorp).may {
"proceed".givenThat(after("01/10/2015")) {
highStreetBank.gives(acmeCorp, libor(notional, "01/07/2015", "01/10/2015"), currency)
@ -35,6 +36,7 @@ class Swaption {
}
}
}
}
actions {
acmeCorp.may {
"cancel".anytime {