separate compiler and plugin tests

This commit is contained in:
Dmitry Jemerov
2011-10-20 16:19:02 +02:00
parent a80398098b
commit ec6dec0d37
586 changed files with 69 additions and 42 deletions
@@ -1,12 +0,0 @@
// One of the two passes is making a scope and turning vals into functions
// See KT-76
namespace x
val b : Foo = Foo()
val a1 = b.compareTo(2)
class Foo() {
fun compareTo(other : Byte) : Int = 0
fun compareTo(other : Char) : Int = 0
}
@@ -1,6 +0,0 @@
fun test() {
val a : Any? = null
if (a is Any) else a = null;
while (a is Any) a = null
while (true) a = null
}
@@ -1,9 +0,0 @@
fun foo(u : Unit) : Int = 1
fun test() : Int {
foo(<error>1</error>)
val a : fun() : Unit = {
foo(<error>1</error>)
}
return 1
}
@@ -1,66 +0,0 @@
import java.*
import util.*
import java.io.*
fun takeFirst(expr: StringBuilder): Char {
val c = expr.charAt(0)
expr.deleteCharAt(0)
return c
}
fun evaluateArg(expr: AbstractStringBuilder, numbers: ArrayList<Int>): Int {
if (expr.length() == 0) throw Exception("Syntax error: Character expected");
val c = takeFirst(<error>expr</error>)
if (c >= '0' && c <= '9') {
val n = c - '0'
if (!numbers.contains(n)) throw Exception("You used incorrect number: " + n)
numbers.remove(n)
return n
}
throw Exception("Syntax error: Unrecognized character " + c)
}
fun evaluateAdd(expr: StringBuilder, numbers: ArrayList<Int>): Int {
val lhs = evaluateArg(expr, numbers)
if (expr.length() > 0) {
}
return lhs
}
fun evaluate(expr: StringBuilder, numbers: ArrayList<Int>): Int {
val lhs = evaluateAdd(expr, numbers)
if (expr.length() > 0) {
val c = expr.charAt(0)
expr.deleteCharAt(0)
}
return lhs
}
fun main(args: Array<String>) {
System.out?.println("24 game")
val numbers = ArrayList<Int>(4)
val rnd = Random();
val prompt = StringBuilder()
for(val i in 0..3) {
val n = rnd.nextInt(9) + 1
numbers.add(n)
if (i > 0) prompt.append(" ");
prompt.append(n)
}
System.out?.println("Your numbers: " + prompt)
System.out?.println("Enter your expression:")
val reader = BufferedReader(InputStreamReader(System.`in`))
val expr = StringBuilder(reader.readLine())
try {
val result = evaluate(expr, numbers)
if (result != 24)
System.out?.println("Sorry, that's " + result)
else
System.out?.println("You won!");
}
catch(e: Throwable) {
System.out?.println(e.getMessage())
}
}
@@ -1,4 +0,0 @@
// JET-11 Redeclaration & Forward reference for classes cause an exception
open class <error>NoC</error>
class NoC1 : NoC
open class <error>NoC</error>
@@ -1,14 +0,0 @@
namespace jet121 {
fun box() : String {
val answer = apply("OK") { String.() : Int =>
get(0)
length
}
return if (answer == 2) "OK" else "FAIL"
}
fun apply(arg:String, f : fun String.() : Int) : Int {
return arg.f()
}
}
@@ -1,8 +0,0 @@
fun foo1() : fun (Int) : Int = { (x: Int) => x }
fun foo() {
val h : fun (Int) : Int = foo1();
h(1)
val m : fun (Int) : Int = {(a : Int) => 1}//foo1()
m(1)
}
@@ -1,8 +0,0 @@
fun set(key : String, value : String) {
val a : String? = ""
when (a) {
"" => a<error>.</error>get(0)
is String, is Any => a.compareTo("")
else => a.toString()
}
}
@@ -1,6 +0,0 @@
// JET-17 Do not infer property types by the initializer before the containing scope is ready
class WithC() {
val a = 1
val b = $a // error here, but must not be
}
@@ -1,21 +0,0 @@
abstract enum class ProtocolState {
WAITING {
override fun signal() = ProtocolState.TALKING
}
TALKING {
override fun signal() = ProtocolState.WAITING
}
abstract fun signal() : ProtocolState
}
fun box(): String {
val x: ProtocolState = ProtocolState.WAITING
x = x.signal()
if (x != ProtocolState.TALKING) return "fail 1"
x = x.signal()
if (x != ProtocolState.WAITING) return "fail 2"
return "OK"
}
@@ -1,22 +0,0 @@
abstract enum class ProtocolState {
WAITING {
override fun signal() = ProtocolState.TALKING
}
TALKING {
override fun signal() = ProtocolState.WAITING
}
abstract fun signal() : ProtocolState
}
enum class Foo<T> {
<error>X</error>
}
fun box() {
val x: ProtocolState = ProtocolState.WAITING
}
@@ -1,4 +0,0 @@
import java.util.Collections
import java.util.List
val ab = Collections.emptyList<Int>() : List<Int>?
@@ -1,4 +0,0 @@
abstract class XXX {
abstract val a : Int get
}
@@ -1,11 +0,0 @@
class Foo()
fun test() {
val f : Foo? = null
if (f == null) {
}
if (f != null) {
}
}
@@ -1,10 +0,0 @@
class Command() {}
fun parse(cmd: String): Command? { return null }
fun Any.equals(other : Any?) : Boolean = this === other
fun main(args: Array<String>) {
val command = parse("")
if (command == null) 1 // error on this line, but must be OK
}
@@ -1,17 +0,0 @@
// JET-72 Type inference doesn't work when iterating over ArrayList
import java.util.ArrayList
abstract class Item(val room: Object) {
abstract val name : String
}
val items: ArrayList<Item> = ArrayList<Item>
fun test(room : Object) {
for(val item: Item in items) {
if (item.room === room) {
System.out?.println("You see " + item.name)
}
}
}
@@ -1,22 +0,0 @@
// JET-81 Assertion fails when processing self-referring anonymous objects
val y = object {
val a = y;
}
val z = y.a;
object A {
val x = A
}
val a = object {
{
b + 1
}
val x = b
val y = 1
}
val b = <error>a</error>.x
val c = a.y
@@ -1,16 +0,0 @@
fun box() {
val a : C
a.foo()
}
open class A {
open fun foo() {}
}
open class B : A {
override fun foo() {}
}
open class C : B {
override fun foo() {}
}
@@ -1,18 +0,0 @@
class Foo(var bar : Int, barr : Int, val barrr : Int) {
{
bar = 1
barr = 1
barrr = 1
1 : Int
this : Foo
}
this(val bar : Int) : this(1, 1, 1) {
bar = 1
this.bar
1 : Int
val a : Int =1
this : Foo
}
}
@@ -1,9 +0,0 @@
fun Any.equals(other : Any?) : Boolean = true
fun main(args: Array<String>) {
val command : Any = 1
command<warning>?.</warning>equals(null)
command.equals(null)
}
@@ -1,3 +0,0 @@
class Z() {
this(x : Int) : this() {}
}
@@ -1,9 +0,0 @@
open class Foo {}
open class Bar {}
fun <T : Bar, T1> foo(x : Int) {}
fun <T1, T : Foo> foo(x : Long) {}
fun f(): Unit {
foo<<error>Int</error>, Int>(1)
}
@@ -1,33 +0,0 @@
class A() {
var x: Int = 0
get() = <error>"s"</error>
set(value: <error>String</error>) {
$x = <error>value</error>
}
val y: Int
get(): <error>String</error> = "s"
val z: Int
get() {
return <error>"s"</error>
}
var a: Any = 1
set(v: <error>String</error>) {
$a = v
}
val b: Int
get(): <error>Any</error> = "s"
val c: Int
get() {
return 1
}
val d = 1
get() {
return $d
}
val e = 1
get(): <error>String</error> {
return <error>$e</error>
}
}
@@ -1,11 +0,0 @@
// KT-303 Stack overflow on a cyclic class hierarchy
open class Foo() : <error>Bar</error>() {
val a : Int = 1
}
open class Bar() : <error>Foo</error>() {
}
val x : Int = <error>Foo()</error>