Fix formatting in some of test data files.

Adapted from https://github.com/develar/kotlin/commit/a9e0a42fb1347fa8e21c86b5a073ef8a7c873da0.
This commit is contained in:
Pavel V. Talanov
2012-08-10 14:06:23 +04:00
parent 12d9b25189
commit 7a22ad099a
31 changed files with 227 additions and 234 deletions
@@ -2,12 +2,12 @@ import java.util.*
class Lifetime() {
val attached = ArrayList< Function0<Unit> >()
public fun attach(action : ()->Unit)
{
attached.add(action)
}
fun close()
{
for(x in attached) x()
@@ -18,51 +18,52 @@ class Lifetime() {
public class Viewable<T>()
{
val items = ArrayList<T>()
fun add(item:T)
{
items.add(item)
}
fun remove(item:T)
{
items.remove(item)
}
fun view(lifetime: Lifetime, viewer: (itemLifetime:Lifetime, item:T) -> Unit)
{
for(item in items)
viewer(lifetime, item)
}
fun view(lifetime: Lifetime, viewer: (itemLifetime: Lifetime, item: T) -> Unit) {
for (item in items) {
viewer(lifetime, item)
}
}
}
fun lifetime(body: (Lifetime)->Unit)
{
val l = Lifetime()
body(l)
l.close()
fun lifetime(body: (Lifetime)->Unit) {
val l = Lifetime()
body(l)
l.close()
}
fun<T> Dump(items:ArrayList<T>)
{
for(item in items)
print(item.toString() + ", ")
println("end")
fun<T> Dump(items: ArrayList<T>) {
for(item in items) {
print(item.toString() + ", ")
}
println("end")
}
fun main(args:Array<String>)
{
val v = Viewable<Int>()
val x = ArrayList<Int>()
v.add(1)
v.add(2)
v.add(3)
lifetime(
{
v.view(it, {(itemLifetime, item)->
x.add(item)
Dump(x)
itemLifetime.attach { x.remove(item as Any); Dump(x); println("!") }
})
})
fun main(args: Array<String>) {
val v = Viewable<Int>()
val x = ArrayList<Int>()
v.add(1)
v.add(2)
v.add(3)
lifetime() {
v.view(it) {itemLifetime, item ->
x.add(item)
Dump(x)
itemLifetime.attach() {
x.remove(item as Any);
Dump(x);
println("!")
}
}
}
}
@@ -1,9 +1,9 @@
package foo
fun box() : Boolean {
var sum = 0
val adder = {(a: Int) -> sum += a }
adder(3)
adder(2)
return sum == 5
fun box(): Boolean {
var sum = 0
val adder = {(a: Int) -> sum += a}
adder(3)
adder(2)
return sum == 5
}
@@ -1,6 +1,5 @@
package foo
fun f(a : Int = 2, b : Int = 3) = a + b
fun box() : Boolean
@@ -1,14 +1,14 @@
package foo
fun f(a: (Int) -> Int) = a(1)
fun f(a: (Int) -> Int) = a(1)
fun box() : Boolean {
fun box(): Boolean {
if (f() {
it + 2
} != 3) return false
if (f() {(a : Int) -> a * 300} != 300) return false;
if (f() {(a: Int) -> a * 300} != 300) return false;
return true
}
@@ -2,16 +2,16 @@ package foo
var b = 0
fun loop(var times : Int) {
while(times > 0) {
val u = {(value : Int) ->
fun loop(var times: Int) {
while (times > 0) {
val u = {(value: Int) ->
b = b + 1
}
u(times--)
}
}
}
fun box() : Boolean {
fun box(): Boolean {
loop(5)
return b == 5
}