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
@@ -1,7 +1,6 @@
package foo
class A() {
var i = 0
fun f() {
@@ -21,4 +20,4 @@ fun box() : Boolean {
val a = A()
a.f()
return a.i == 3
}
}
@@ -24,4 +24,4 @@ fun box() : Boolean {
sum += f()
}
return (sum == 27)
}
}
@@ -1,7 +1,7 @@
fun box() : String {
return if (apply( 5, {(arg: Int) -> arg + 13 } ) == 18) "OK" else "fail"
fun box(): String {
return if (apply(5) {(arg: Int) -> arg + 13 } == 18) "OK" else "fail"
}
fun apply(arg : Int, f : (p:Int) -> Int) : Int {
fun apply(arg: Int, f: (p: Int) -> Int): Int {
return f(arg)
}
@@ -1,8 +1,8 @@
fun box() : String {
fun box(): String {
val cl = 39
return if (sum(200, { val ff = {cl}; ff() }) == 239) "OK" else "FAIL"
return if (sum(200, {val ff = {cl}; ff()}) == 239) "OK" else "FAIL"
}
fun sum(arg:Int, f : () -> Int) : Int {
fun sum(arg: Int, f: ()->Int): Int {
return arg + f()
}
}
@@ -1,13 +1,13 @@
class Point(val x : Int, val y : Int)
class Point(val x: Int, val y: Int)
fun box() : String {
val answer = apply(Point(3, 5), { Point.(scalar : Int) : Point ->
fun box(): String {
val answer = apply(Point(3, 5), { Point.(scalar: Int) : Point ->
Point(x * scalar, y * scalar)
})
return if (answer.x == 6 && answer.y == 10) "OK" else "FAIL"
}
fun apply(arg:Point, f : Point.(scalar : Int) -> Point) : Point {
fun apply(arg: Point, f: Point.(scalar: Int) -> Point): Point {
return arg.f(2)
}
@@ -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
}
@@ -1,7 +1,7 @@
package foo
class Data(val rawData : Array<Int>, val width : Int, val height : Int) {
fun get(x : Int, y : Int) : ColorLike {
class Data(val rawData: Array<Int>, val width: Int, val height: Int) {
fun get(x: Int, y: Int): ColorLike {
return object : ColorLike {
override val red: Int = rawData[(y * width + x) * 4 + 0];
override val green: Int = rawData[(y * width + x) * 4 + 1];
@@ -9,13 +9,13 @@ class Data(val rawData : Array<Int>, val width : Int, val height : Int) {
}
}
fun set(x : Int, y : Int, color : ColorLike) {
fun set(x: Int, y: Int, color: ColorLike) {
rawData[(y * width + x) * 4 + 0] = color.red;
rawData[(y * width + x) * 4 + 1] = color.green;
rawData[(y * width + x) * 4 + 2] = color.blue;
}
fun each(block : (x : Int, y : Int)->Unit) {
fun each(block: (x: Int, y: Int)->Unit) {
for (x in 0..width - 1) {
for (y in 0..height - 1) {
block(x, y)
@@ -24,29 +24,28 @@ class Data(val rawData : Array<Int>, val width : Int, val height : Int) {
}
}
class Color(r : Int, g : Int, b : Int) : ColorLike {
class Color(r: Int, g: Int, b: Int): ColorLike {
override val red: Int = r
override val green: Int = g
override val blue: Int = b
}
trait ColorLike {
val red : Int;
val green : Int;
val blue : Int;
val red: Int;
val green: Int;
val blue: Int;
}
fun box() : Boolean {
fun box(): Boolean {
val d = Data(Array(4) {0}, 1, 1)
if (d[0, 0].red != 0) {
return false
}
if (d[0, 0].green != 0) {
return false
}
if (d[0, 0].blue != 0) {
return false
}
return true
return false
}
if (d[0, 0].blue != 0) {
return false
}
return true
}
@@ -5,31 +5,29 @@ var c1 = 0
var c2 = 0
class A() {
var p = 0
fun get(i : Int) : Int {
c1++
return 0
}
fun set(i : Int, value : Int) {
c2++
}
var p = 0
fun get(i: Int): Int {
c1++
return 0
}
fun set(i: Int, value: Int) {
c2++
}
}
val a : A = A()
get() {
c0++
return $a
}
fun box() : String {
val a: A = A()
get() {
c0++
return $a
}
fun box(): String {
var d = a[1]
if (c0 != 1) {
return "1"
}
if (c1 != 1) {
if (c1 != 1) {
return "2"
}
++a[1]
@@ -37,20 +35,20 @@ fun box() : String {
return "3"
}
if (c1 != 3) {
return "4"
return "4"
}
if (c2 != 1) {
return "5"
}
--a[1]
--a[1]
if (c0 != 3) {
return "6"
}
if (c1 != 5) {
return "7"
}
if (c2 != 2) {
return "8"
}
return "OK"
if (c1 != 5) {
return "7"
}
if (c2 != 2) {
return "8"
}
return "OK"
}
@@ -1,7 +1,7 @@
class A(var a : Int) {
class A(var a: Int) {
{
$a=3
$a = 3
}
}
fun box() = (A(1).a == 3)
fun box() = (A(1).a == 3)
@@ -1,17 +1,18 @@
package foo
class A() {
fun lold() = true
fun lold() = true
val p = {{lold()}()}
val p = {{
lold()
}()
}
}
fun box() : Boolean {
return A().p()
fun box(): Boolean {
return A().p()
}
fun main(arg : Array<String>) {
fun main(arg: Array<String>) {
println(box())
}
@@ -1,19 +1,18 @@
package foo
class A() {
fun lold() = true
val p : ()->Boolean
{
$p = {{lold()}()}
}
fun lold() = true
val p: ()->Boolean
{
$p = {{lold()}()}
}
}
fun box() : Boolean {
return A().p()
fun box(): Boolean {
return A().p()
}
fun main(arg : Array<String>) {
fun main(arg: Array<String>) {
println(box())
}
@@ -1,18 +1,18 @@
package foo
fun box() : Boolean {
if (t(1) != 0) {
return false
}
if (t(0) != 1) {
return false
}
return (t(100) == 2)
fun box(): Boolean {
if (t(1) != 0) {
return false
}
if (t(0) != 1) {
return false
}
return (t(100) == 2)
}
fun t(i : Int) = when(i) {
0 -> 1
1 -> 0
else -> 2
fun t(i: Int) = when(i) {
0 -> 1
1 -> 0
else -> 2
}
@@ -1,7 +1,7 @@
package foo
fun apply(i : Int, f : Int.(Int) -> Int) = i.f(1);
fun apply(i: Int, f: Int.(Int) -> Int) = i.f(1);
fun box() : Boolean {
return (apply(1, {i -> i + this})) == 2
fun box(): Boolean {
return apply(1, {i -> i + this}) == 2
}
@@ -1,26 +1,24 @@
package foo
class Foo {
fun blah(value: Int): Int {
return value + 1
}
fun blah(value: Int): Int {
return value + 1
}
}
val Foo.fooImp : Int
get() {
return blah(5)
}
val Foo.fooImp: Int
get() {
return blah(5)
}
val Foo.fooExp : Int
get() {
return this.blah(10)
}
val Foo.fooExp: Int
get() {
return this.blah(10)
}
fun box() : Boolean {
fun box(): Boolean {
var a = Foo()
if (a.fooImp != 6) return false
if (a.fooExp != 11) return false
return true;
}
}
@@ -1,16 +1,16 @@
package foo
open class A(var a : Int) {
open class A(var a: Int) {
open fun Int.modify() : Int {
open fun Int.modify(): Int {
return this * 3;
}
fun eval() = a.modify();
}
class B(a : Int) : A(a) {
override fun Int.modify() : Int {
class B(a: Int): A(a) {
override fun Int.modify(): Int {
return this - 2;
}
}
@@ -1,12 +1,12 @@
package foo
open class C(a : Int) {
open class C(a: Int) {
val b = a
}
class D(c : Int) : C(c + 2) {
class D(c: Int): C(c + 2) {
}
fun box(): Boolean {
return (D(0).b == 2)
return (D(0).b == 2)
}
@@ -15,41 +15,41 @@
*/
{
var classes = function(){
var A = Kotlin.createClass({initialize:function(){
this.$order = '';
{
this.set_order(this.get_order() + 'A');
}
var items = function () {
var A = Kotlin.createClass({initialize: function () {
this.$order = '';
{
this.set_order(this.get_order() + 'A');
}
}, set_order: function (tmp$0) {
this.$order = tmp$0;
}, get_order: function () {
return this.$order;
}
});
var B = Kotlin.createClass(A, {initialize: function () {
this.super_init();
{
this.set_order(this.get_order() + 'B');
}
}
});
var C = Kotlin.createClass(B, {initialize: function () {
this.super_init();
{
this.set_order(this.get_order() + 'C');
}
}
});
return {A: A, B: B, C: C};
}
, set_order:function(tmp$0){
this.$order = tmp$0;
}
, get_order:function(){
return this.$order;
}
});
var B = Kotlin.createClass(A, {initialize:function(){
this.super_init();
{
this.set_order(this.get_order() + 'B');
}
}
});
var C = Kotlin.createClass(B, {initialize:function(){
this.super_init();
{
this.set_order(this.get_order() + 'C');
}
}
});
return {A:A, B:B, C:C};
}
();
var foo = Kotlin.definePackage(classes, {box:function(){
return (new foo.C).get_order() === 'ABC' && (new foo.B).get_order() === 'AB' && (new foo.A).get_order() === 'A';
}
});
();
items.box = function () {
return (new foo.C).get_order() === 'ABC' && (new foo.B).get_order() === 'AB' && (new foo.A).get_order() === 'A';
};
var foo = Kotlin.definePackage(items);
}
function test() {
@@ -4,17 +4,17 @@ import js.*
native
class A(val c: Int) {
native
class object {
val g: Int = js.noImpl
val c: String = js.noImpl
}
native
class object {
val g: Int = js.noImpl
val c: String = js.noImpl
}
}
fun box(): Boolean {
if (A.g != 3) return false
if (A.c != "hoooray") return false
if (A(2).c != 2) return false
if (A.g != 3) return false
if (A.c != "hoooray") return false
if (A(2).c != 2) return false
return true
return true
}
@@ -1,9 +1,7 @@
package foo
class A() {
fun f() : Boolean {
fun f(): Boolean {
object t {
val c = true;
}
@@ -12,7 +10,6 @@ class A() {
}
return t.c && z.c
}
}
fun box() = A().f();
@@ -5,9 +5,7 @@ val a = object {
fun b() = 2
}
fun box() : Boolean {
fun box(): Boolean {
if (a.c() != 3) {
return false;
}
@@ -15,6 +13,5 @@ fun box() : Boolean {
return false;
}
return true;
}
@@ -25,4 +25,4 @@ fun box():Boolean {
val test = _enumerate(Test())
val p = _enumerate(P())
return (100 == test.a && "s" == test.b) && p.a == 100 && _findFirst<Int>(object {val test = 100}) == 100;
}
}
@@ -1,14 +1,19 @@
package foo
trait I {
fun test():String
fun test(): String
}
class P : I {
override fun test():String {return "a" + test("b")}
private fun test(p:String):String {return p}
class P: I {
override fun test(): String {
return "a" + test("b")
}
private fun test(p: String): String {
return p
}
}
fun box():Boolean {
fun box(): Boolean {
return P().test() == "ab"
}
@@ -10,4 +10,4 @@ function _findFirst(o) {
for (var p in o) {
return o[p];
}
}
}
@@ -3,7 +3,7 @@ package foo
class Test() {
}
fun box() : Boolean {
fun box(): Boolean {
var test = Test()
return true
}
@@ -1,7 +1,7 @@
package foo
val f = {(i : Int) -> i + 1}
val f = {(i: Int) -> i + 1}
val a = Array(3, f)
fun box() = (a[0] == 1 && a[2] == 3 && a[1] == 2)
fun box() = (a[0] == 1 && a[2] == 3 && a[1] == 2)
@@ -1,25 +1,25 @@
package foo
trait A {
fun addFoo(s:String) : String {
return s + "FOO"
fun addFoo(s: String): String {
return s + "FOO"
}
}
trait B {
fun hooray() : String {
fun hooray(): String {
return "hooray"
}
}
trait AD : A, B {
trait AD: A, B {
}
class Test() : AD {
fun eval() : String {
class Test(): AD {
fun eval(): String {
return addFoo(hooray());
}
}
fun box() = (Test().eval() == "hoorayFOO")
fun box() = (Test().eval() == "hoorayFOO")
@@ -134,8 +134,8 @@ class A() : BodyTag("a") {
}
}
fun html(init : HTML.() -> Unit) : HTML {
val html = HTML()
html.init()
return html
fun html(init: HTML.() -> Unit): HTML {
val html = HTML()
html.init()
return html
}