JetPsiCheckerTest and its testdata moved back to plugin tests

This commit is contained in:
Dmitry Jemerov
2011-10-27 18:44:39 +02:00
parent 655d2bd632
commit a3f8a088be
73 changed files with 91 additions and 92 deletions
@@ -0,0 +1,12 @@
// 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
}
@@ -0,0 +1,6 @@
fun test() {
var a : Any? = null
if (a is Any) else a = null;
while (a is Any) a = null
while (true) a = null
}
@@ -0,0 +1,9 @@
fun foo(u : Unit) : Int = 1
fun test() : Int {
foo(<error>1</error>)
val a : fun() : Unit = {
foo(<error>1</error>)
}
return 1
}
@@ -0,0 +1,66 @@
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())
}
}
@@ -0,0 +1,4 @@
// JET-11 Redeclaration & Forward reference for classes cause an exception
open class <error>NoC</error>
class NoC1 : NoC
open class <error>NoC</error>
@@ -0,0 +1,14 @@
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()
}
}
@@ -0,0 +1,8 @@
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)
}
@@ -0,0 +1,8 @@
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()
}
}
@@ -0,0 +1,6 @@
// 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
}
@@ -0,0 +1,21 @@
abstract enum class ProtocolState {
WAITING {
override fun signal() = ProtocolState.TALKING
}
TALKING {
override fun signal() = ProtocolState.WAITING
}
abstract fun signal() : ProtocolState
}
fun box(): String {
var 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"
}
@@ -0,0 +1,22 @@
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
}
@@ -0,0 +1,4 @@
import java.util.Collections
import java.util.List
val ab = Collections.emptyList<Int>() : List<Int>?
@@ -0,0 +1,4 @@
abstract class XXX {
abstract val a : Int get
}
@@ -0,0 +1,11 @@
class Foo()
fun test() {
val f : Foo? = null
if (f == null) {
}
if (f != null) {
}
}
@@ -0,0 +1,10 @@
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
}
@@ -0,0 +1,17 @@
// 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)
}
}
}
@@ -0,0 +1,22 @@
// 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
@@ -0,0 +1,16 @@
fun box() {
val a : C = C()
a.foo()
}
open class A() {
open fun foo() {}
}
open class B() : A() {
override fun foo() {}
}
open class C() : B() {
override fun foo() {}
}
@@ -0,0 +1,18 @@
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
}
}
@@ -0,0 +1,9 @@
fun Any.equals(other : Any?) : Boolean = true
fun main(args: Array<String>) {
val command : Any = 1
command<warning>?.</warning>equals(null)
command.equals(null)
}
@@ -0,0 +1,3 @@
class Z() {
this(x : Int) : this() {}
}
@@ -0,0 +1,9 @@
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)
}
@@ -0,0 +1,33 @@
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>
}
}
@@ -0,0 +1,11 @@
// 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>