GreatSyntacticShift: Codegen testdata fixed

This commit is contained in:
Andrey Breslav
2011-12-20 22:56:13 +04:00
parent 41fd43b5e5
commit 6aad3b2662
67 changed files with 151 additions and 151 deletions
@@ -1,11 +1,11 @@
fun main(args: Array<String>?) {
val y: Unit = () //do not compile
val y: Unit = #() //do not compile
A<Unit>() //do not compile
C<Unit>(()) //do not compile
C<Unit>(#()) //do not compile
//do not compile
System.out?.println(fff<Unit>(())) //do not compile
System.out?.println(fff<Unit>(#())) //do not compile
System.out?.println(id<Unit>(y)) //do not compile
System.out?.println(fff<Unit>(id<Unit>(y)) == id<Unit>(foreach(Array<Int>(0,{0}),{(e : Int) : Unit => }))) //do not compile
System.out?.println(fff<Unit>(id<Unit>(y)) == id<Unit>(foreach(Array<Int>(0,{0}),{(e : Int) : Unit -> }))) //do not compile
}
class A<T>()
@@ -17,13 +17,13 @@ fun <T> fff(x: T) : T { return x }
fun <T> id(value: T): T = value
fun foreach(array: Array<Int>?, action: fun(Int): Unit) {
fun foreach(array: Array<Int>?, action: (Int)-> Unit) {
for (el in array) {
action(el) //exception through compilation (see below)
}
}
fun almostFilter(array: Array<Int>, action: fun(Int): Int) {
fun almostFilter(array: Array<Int>, action: (Int)-> Int) {
for (el in array) {
action(el)
}
@@ -34,8 +34,8 @@ fun box() : String {
a[0] = 0
a[1] = 1
a[2] = 2
foreach(a, { (el : Int) : Unit => System.out?.println(el) })
almostFilter(a, { (el : Int) : Int => el })
foreach(a, { (el : Int) : Unit -> System.out?.println(el) })
almostFilter(a, { (el : Int) : Int -> el })
main(null)
return "OK"
}
@@ -1,4 +1,4 @@
namespace x
package x
class Outer() {
class object {
@@ -1,4 +1,4 @@
namespace test
package test
class List<T>(len: Int) {
val a : Array<T?> = Array<T?>(len)
@@ -1,12 +1,12 @@
import java.util.ArrayList
fun launch(f : fun() : Unit) {
fun launch(f : () -> Unit) {
f()
}
fun box(): String {
val list = ArrayList<Int>()
val foo : fun() : Unit = {
val foo : () -> Unit = {
list.add(2) //first exception
}
foo()
@@ -27,7 +27,7 @@ fun t1() : Boolean {
x = x + "45" + y
x = x.substring(3)
x += "aaa"
()
#()
}
foo()
@@ -43,7 +43,7 @@ fun t2() : Boolean {
x = x + 5 + y
x += 5
x++
()
#()
}
foo()
x -= 55
@@ -55,7 +55,7 @@ fun t3() : Boolean {
var x = true
val foo = {
x = false
()
#()
}
foo()
return !x
@@ -67,7 +67,7 @@ fun t4() : Boolean {
val foo = {
x = x + 200.flt + y
x += 18
()
#()
}
foo()
System.out?.println(x)
@@ -80,7 +80,7 @@ fun t5() : Boolean {
val foo = {
x = x + 200.dbl + y
x -= 22
()
#()
}
foo()
System.out?.println(x)
@@ -94,7 +94,7 @@ fun t6() : Boolean {
x = (x + 20.byt + y).byt
x += 2
x--
()
#()
}
foo()
System.out?.println(x)
@@ -105,7 +105,7 @@ fun t7() : Boolean {
var x : Char = 'a'
val foo = {
x = 'b'
()
#()
}
foo()
System.out?.println(x)
@@ -117,10 +117,10 @@ fun t8() : Boolean {
val foo = {
val bar = {
x = 30.sht
()
#()
}
bar()
()
#()
}
foo()
return x == 30.sht
@@ -1,6 +1,6 @@
fun Any.with(operation : fun Any.() : Any) = operation().toString()
fun Any.with(operation : Any.() -> Any) = operation().toString()
val f = { (a : Int) :Unit => }
val f = { (a : Int) :Unit -> }
fun box () : String {
return if(20.with {
@@ -1,4 +1,4 @@
namespace mult_constructors_3_bug
package mult_constructors_3_bug
public open class Identifier() {
private var myNullable : Boolean = true
@@ -1,4 +1,4 @@
namespace one_extends_base
package one_extends_base
open class Base<T>(name : T?) {
var myName : T?
@@ -1,4 +1,4 @@
namespace mask
package mask
import std.io.*
import java.io.*
@@ -52,7 +52,7 @@ class Luhny() {
fun check() {
if (digits.size() < 14) return
print("check")
val sum = digits.sum { i, d =>
val sum = digits.sum { i, d ->
// println("$i -> $d")
if (i % 2 == digits.size()) {
val f = d * 2 / 10
@@ -94,12 +94,12 @@ class Luhny() {
}
}
fun <T> T.pr(f : fun(T) : Unit) : T {
fun <T> T.pr(f : (T) -> Unit) : T {
f(this)
return this
}
fun LinkedList<Int>.sum(f : fun(Int, Int ): Int): Int {
fun LinkedList<Int>.sum(f : (Int, Int )-> Int): Int {
var sum = 0
for (i in 1..size()) {
val j = size() - i
@@ -120,7 +120,7 @@ fun LinkedList<Int>.sum(f : fun(Int, Int ): Int): Int {
fun Char.isDigit() = Character.isDigit(this)
fun Reader.forEachChar(body : fun(Char) : Unit) {
fun Reader.forEachChar(body : (Char) -> Unit) {
do {
var i = read();
if (i == -1) break
@@ -1,4 +1,4 @@
namespace mask
package mask
import std.io.*
import java.io.*
@@ -46,7 +46,7 @@ class Luhny() {
private fun check() {
val size = digits.size()
if (size < 14) return
val sum = digits.sum {i, d =>
val sum = digits.sum {i, d ->
if (i % 2 == size % 2) double(d) else d
}
// var sum = 0
@@ -89,7 +89,7 @@ class Luhny() {
fun Char.isDigit() = Character.isDigit(this)
fun java.lang.Iterable<Int>.sum(f : fun(index : Int, value : Int) : Int) : Int {
fun java.lang.Iterable<Int>.sum(f : (index : Int, value : Int) -> Int) : Int {
var sum = 0
var i = 0
for (d in this) {
@@ -99,7 +99,7 @@ fun java.lang.Iterable<Int>.sum(f : fun(index : Int, value : Int) : Int) : Int {
return sum
}
fun Reader.forEachChar(body : fun(Char) : Unit) {
fun Reader.forEachChar(body : (Char) -> Unit) {
do {
var i = read();
if (i == -1) break
@@ -1,4 +1,4 @@
namespace mask
package mask
import std.io.*
import java.io.*
@@ -50,7 +50,7 @@ class Luhny() {
fun check() {
if (digits.size() < 14) return
val sum = digits.sum { i, d =>
val sum = digits.sum { i, d ->
if (i % 2 != 0)
d * 2 / 10 + d * 2 % 10
else d
@@ -85,7 +85,7 @@ class Luhny() {
}
}
fun LinkedList<Int>.sum(f : fun(Int, Int) : Int) : Int {
fun LinkedList<Int>.sum(f : (Int, Int) -> Int) : Int {
var sum = 0
var i = 0
for (d in backwards()) {
@@ -136,7 +136,7 @@ fun Char.isDigit() = Character.isDigit(this)
// fun clear() {}
//}
fun Reader.forEachChar(body : fun(Char) : Unit) {
fun Reader.forEachChar(body : (Char) -> Unit) {
do {
var i = read();
if (i == -1) break
@@ -1,4 +1,4 @@
namespace while_bug_1
package while_bug_1
import java.io.*
@@ -1,4 +1,4 @@
namespace whats.the.difference
package whats.the.difference
import java.util.HashSet
@@ -1,4 +1,4 @@
namespace array_test
package array_test
fun box() : String {
var array : IntArray? = IntArray(10)
@@ -1,4 +1,4 @@
namespace name
package name
class Test() {
var i = 5
@@ -1,4 +1,4 @@
namespace demo
package demo
public open class Identifier<T>(myName : T?, myHasDollar : Boolean) {
{
@@ -1,8 +1,8 @@
fun escapeChar(c : Char) : String? = when (c) {
'\\' => "\\\\"
'\n' => "\\n"
'"' => "\\\""
else => String.valueOf(c)
'\\' -> "\\\\"
'\n' -> "\\n"
'"' -> "\\\""
else -> String.valueOf(c)
}
fun String.escape(i : Int = 0, result : String = "") : String =
@@ -1,4 +1,4 @@
namespace org2
package org2
enum class Test {
A
@@ -1,6 +1,6 @@
class List<T>(val head: T, val tail: List<T>? = null)
fun <T> List<T>.mapHead(f: fun(T): T): List<T> = List<T>(f(head), null)
fun <T> List<T>.mapHead(f: (T)-> T): List<T> = List<T>(f(head), null)
fun box() : String {
val a: Int = List<Int>(1).mapHead{it * 2}.head
@@ -1,4 +1,4 @@
namespace demo_range
package demo_range
fun Int?.rangeTo(other : Int?) : IntRange = this.sure().rangeTo(other.sure())
@@ -1,4 +1,4 @@
namespace bitwise_demo
package bitwise_demo
fun Long?.shl(bits : Int?) : Long = this.sure().shl(bits.sure())
@@ -1,4 +1,4 @@
namespace demo_range
package demo_range
fun Int?.plus() : Int = this.sure().plus()
fun Int?.dec() : Int = this.sure().dec()
@@ -1,4 +1,4 @@
namespace demo_long
package demo_long
fun Long?.inv() : Long = this.sure().inv()
@@ -1,10 +1,10 @@
namespace w_range
package w_range
fun box() : String {
var i = 0
when (i) {
1 => i--
else => { i = 2 }
1 -> i--
else -> { i = 2 }
}
System.out?.println(i)
return "OK"
@@ -1,18 +1,18 @@
namespace demo2
package demo2
fun print(o : Any?) {}
fun test(i : Int) {
var monthString : String? = "<empty>"
when (i) {
1 => {
1 -> {
print(1)
print(2)
print(3)
print(4)
print(5)
}
else => {
else -> {
monthString = "Invalid month"
}
}
@@ -1,18 +1,18 @@
namespace demo2
package demo2
fun print(o : Any?) {}
fun test(i : Int) {
var monthString : String? = "<empty>"
when (i) {
1 => {
1 -> {
print(1)
print(2)
print(3)
print(4)
print(5)
}
else => {
else -> {
monthString = "Invalid month"
}
}
@@ -1,7 +1,7 @@
class A() {
var x : Int = 0
var z = { () =>
var z = { () ->
x++
}
}
@@ -1,4 +1,4 @@
namespace foo
package foo
import java.util.*;
@@ -1,4 +1,4 @@
namespace demo
package demo
fun box() : String {
var res : Boolean = true