mirror of
https://github.com/corda/corda.git
synced 2024-12-19 21:17:58 +00:00
Universal: fixed syntax issue that should have resulted in compile error
This commit is contained in:
parent
9c5ef6cdfe
commit
2299b3beae
@ -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))
|
||||
}*/
|
||||
|
@ -64,10 +64,12 @@ class ContractDefinition {
|
||||
actions {
|
||||
acmeCorp.may {
|
||||
"exercise".anytime {
|
||||
(acmeCorp or highStreetBank).may {
|
||||
"execute".givenThat(after("2017-09-01")) {
|
||||
highStreetBank.gives(acmeCorp, 1.M, EUR)
|
||||
acmeCorp.gives(highStreetBank, 1200.K, USD)
|
||||
actions {
|
||||
(acmeCorp or highStreetBank).may {
|
||||
"execute".givenThat(after("2017-09-01")) {
|
||||
highStreetBank.gives(acmeCorp, 1.M, EUR)
|
||||
acmeCorp.gives(highStreetBank, 1200.K, USD)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -81,8 +83,52 @@ class ContractDefinition {
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun test() {
|
||||
/* @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 `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)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -22,15 +22,17 @@ 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)
|
||||
(highStreetBank or acmeCorp).may {
|
||||
"proceed".givenThat(after("01/10/2015")) {
|
||||
highStreetBank.gives(acmeCorp, libor(notional, "01/07/2015", "01/10/2015"), currency)
|
||||
acmeCorp.gives(highStreetBank, interest(notional, "act/365", coupon, "01/07/2015", "01/10/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)
|
||||
acmeCorp.gives(highStreetBank, interest(notional, "act/365", coupon, "01/07/2015", "01/10/2015"), currency)
|
||||
|
||||
actions {
|
||||
(highStreetBank or acmeCorp).may {
|
||||
"dummy".anytime { zero }
|
||||
// etc ...
|
||||
actions {
|
||||
(highStreetBank or acmeCorp).may {
|
||||
"dummy".anytime { zero }
|
||||
// etc ...
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user