46 lines
624 B
Plaintext
46 lines
624 B
Plaintext
class IncDec() {
|
|
fun inc() : IncDec = this
|
|
fun dec() : IncDec = this
|
|
}
|
|
|
|
fun testIncDec() {
|
|
var x = IncDec()
|
|
x++
|
|
++x
|
|
x--
|
|
--x
|
|
x = x++
|
|
x = x--
|
|
x = ++x
|
|
x = --x
|
|
}
|
|
|
|
class WrongIncDec() {
|
|
fun inc() : Int = 1
|
|
fun dec() : Int = 1
|
|
}
|
|
|
|
fun testWrongIncDec() {
|
|
var x = WrongIncDec()
|
|
x<error>++</error>
|
|
<error>++</error>x
|
|
x<error>--</error>
|
|
<error>--</error>x
|
|
}
|
|
|
|
class UnitIncDec() {
|
|
fun inc() : Unit {}
|
|
fun dec() : Unit {}
|
|
}
|
|
|
|
fun testUnitIncDec() {
|
|
var x = UnitIncDec()
|
|
x++
|
|
++x
|
|
x--
|
|
--x
|
|
x = <error>x++</error>
|
|
x = <error>x--</error>
|
|
x = <error>++x</error>
|
|
x = <error>--x</error>
|
|
} |