more java tests moved to community

This commit is contained in:
Alexey Kudravtsev
2010-06-25 12:46:40 +04:00
parent 735a9d17a8
commit 2718da9fc7
1139 changed files with 14287 additions and 0 deletions
@@ -0,0 +1,16 @@
// "Access static 'AClass.fff' via class 'AClass' reference" "true"
class AClass
{
AClass getA() {
return null;
}
static int fff;
}
class acc {
int f() {
AClass a = null;
return <caret>AClass.fff;
}
}
@@ -0,0 +1,12 @@
// "Access static 'AClass.fff' via class 'AClass' reference" "true"
class AClass
{
AClass getA() {
int i = <caret>fff;
return null;
}
static int fff;
}
@@ -0,0 +1,17 @@
// "Access static 'AClass.getA()' via class 'AClass' reference" "true"
class AClass
{
static AClass getA() {
return null;
}
static int fff;
}
class acc {
int f() {
AClass a = null;
<caret>AClass.getA();
return 0;
}
}
@@ -0,0 +1,8 @@
// "Access static 'AClass.stat' via class 'AClass' reference" "true"
class AClass {
static boolean stat;
void foo (boolean stat) {
AClass.stat<caret> = stat;
}
}
@@ -0,0 +1,17 @@
// "Access static 'AClass.R.rr' via class 'R' reference" "true"
class AClass
{
public static class R {
static int rr = 0;
}
public R getR() {
return null;
}
}
class ss {
void f(AClass d){
int i = <caret>AClass.R.rr;
}
}
@@ -0,0 +1,16 @@
// "Access static 'AClass.fff' via class 'AClass' reference" "true"
class AClass
{
AClass getA() {
return null;
}
static int fff;
}
class acc {
int f() {
AClass a = null;
return <caret>a.getA().fff;
}
}
@@ -0,0 +1,12 @@
// "Access static 'AClass.fff' via class 'AClass' reference" "true"
class AClass
{
AClass getA() {
int i = <caret>this.fff;
return null;
}
static int fff;
}
@@ -0,0 +1,17 @@
// "Access static 'AClass.getA()' via class 'AClass' reference" "true"
class AClass
{
static AClass getA() {
return null;
}
static int fff;
}
class acc {
int f() {
AClass a = null;
<caret>a.getA();
return 0;
}
}
@@ -0,0 +1,18 @@
// "Access static 'AClass.R.rr' via class 'AClass.R' reference" "false"
class AClass
{
private static class R {
static int rr = 0;
}
public R getR() {
return null;
}
}
// AClass.R is not accessible there
class ss {
void f(AClass d){
int i = <caret>d.getR().rr;
}
}
@@ -0,0 +1,8 @@
// "Access static 'AClass.stat' via class 'AClass' reference" "true"
class AClass {
static boolean stat;
void foo (boolean stat) {
this.stat<caret> = stat;
}
}
@@ -0,0 +1,17 @@
// "Access static 'AClass.R.rr' via class 'R' reference" "true"
class AClass
{
public static class R {
static int rr = 0;
}
public R getR() {
return null;
}
}
class ss {
void f(AClass d){
int i = <caret>d.getR().rr;
}
}
@@ -0,0 +1,13 @@
// "Add Catch Clause(s)" "true"
class a {
void g() throws Exception {
}
void f() {
try {
g();
} catch (Error e) {
} catch (Exception e) {
<caret><selection>e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.</selection>
}
}
}
@@ -0,0 +1,16 @@
// "Add Catch Clause(s)" "true"
class a {
void g() throws Exception {
}
// initializer
{
try {
// comment before
g();
// comment after
} catch (Exception e) {
<caret><selection>e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.</selection>
}
}
}
@@ -0,0 +1,16 @@
// "Add Catch Clause(s)" "true"
class MyException1 extends Exception {}
class MyException2 extends Exception {}
class Test {
void foo () throws MyException1, MyException2 {}
void bar () {
try {
foo();
} catch (MyException1 e) {
} catch (MyException2 myException2) {
<caret><selection>myException2.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.</selection>
}
}
}
@@ -0,0 +1,21 @@
// "Add Catch Clause(s)" "true"
import java.io.FileNotFoundException;
import java.io.IOException;
class CatchExceptions {
void foo() throws java.io.IOException, java.io.FileNotFoundException {
}
void bar() {
try {
foo();
} catch (FileNotFoundException e) {
<selection>e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.</selection>
} catch (IOException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
}
@@ -0,0 +1,11 @@
// "Add Catch Clause(s)" "true"
class a {
void g() throws Exception {
}
void f() {
try {
<caret>g();
} catch (Error e) {
}
}
}
@@ -0,0 +1,20 @@
// "Add Catch Clause(s)" "false"
// should not try to add catch clauses across method boundaries
class s {
int f() throws Exception {
Runnable runnable = new Runnable() {
public void run() {
try {
Runnable runnable = new Runnable() {
public void run() {
<caret>int i = f();//
}
};
} catch (Exception e) {
}
}
};
return 0;
}
}
@@ -0,0 +1,14 @@
// "Add Catch Clause(s)" "true"
class a {
void g() throws Exception {
}
// initializer
{
try {
// comment before
<caret>g();
// comment after
}
}
}
@@ -0,0 +1,14 @@
// "Add Catch Clause(s)" "true"
class MyException1 extends Exception {}
class MyException2 extends Exception {}
class Test {
void foo () throws MyException1, MyException2 {}
void bar () {
try {
<caret>foo();
} catch (MyException1 e) {
}
}
}
@@ -0,0 +1,13 @@
// "Add Catch Clause(s)" "true"
class CatchExceptions {
void foo() throws java.io.IOException, java.io.FileNotFoundException {
}
void bar() {
try {
foo();<caret>
}
}
}
@@ -0,0 +1,7 @@
// "Add Method Body" "true"
class a {
void f() {
<selection>//To change body of created methods use File | Settings | File Templates.</selection><caret>
}
}
@@ -0,0 +1,7 @@
// "Add Method Body" "true"
class a {
String f() {
<selection>return null; //To change body of created methods use File | Settings | File Templates.</selection><caret>
}
}
@@ -0,0 +1,7 @@
// "Add Method Body" "true"
class a {
a() {
<selection>//To change body of created methods use File | Settings | File Templates.</selection><caret>
}
}
@@ -0,0 +1,7 @@
// "Add Method Body" "true"
class a {
String f() {
<selection>return null; //To change body of created methods use File | Settings | File Templates.</selection><caret>
}
}
@@ -0,0 +1,5 @@
// "Add Method Body" "true"
class a {
<caret>void f();
}
@@ -0,0 +1,5 @@
// "Add Method Body" "true"
class a {
<caret>String f();
}
@@ -0,0 +1,5 @@
// "Add Method Body" "true"
class a {
<caret>a();
}
@@ -0,0 +1,5 @@
// "Add Method Body" "true"
class a {
<caret>abstract String f();
}
@@ -0,0 +1,5 @@
// "Add Method Body" "false"
interface a {
<caret>String f();
}
@@ -0,0 +1,7 @@
// "Add 'new int[]'" "true"
class c {
void f() {
int[] a;
a = <caret>new int[]{1, 2};
}
}
@@ -0,0 +1,7 @@
// "Add 'new int[]'" "true"
class c {
void f() {
int[] a;
a = <caret>{1, 2};
}
}
@@ -0,0 +1,15 @@
// "Add on demand static import for 'test.Bar'" "true"
package test;
import static test.Bar.*;
class Bar {
public static final void f() {}
}
public class Foo {
public static final void f(int i) {}
{
<caret>Bar.f(); // invoke 'add on demand static import' for Bar class here. The call is now done to other method.
}
}
@@ -0,0 +1,36 @@
// "Add on demand static import for 'test.Bar'" "true"
package test;
import static test.Bar.*;
class Bar {
public static final void f() {
}
}
public class Foo {
{
f(); // invoke 'add on demand static import' for Bar class here. The call is now done to other method.
}
static class D {
public static final void f(int i) {
}
{
Bar.f(); // invoke 'add on demand static import' for Bar class here. The call is now done to other method.
}
}
{
f(); // invoke 'add on demand static import' for Bar class here. The call is now done to other method.
}
{
f(); // invoke 'add on demand static import' for Bar class here. The call is now done to other method.
}
{
f(); // invoke 'add on demand static import' for Bar class here. The call is now done to other method.
}
}
@@ -0,0 +1,14 @@
// "Add on demand static import for 'test.Bar'" "false"
package test;
import static test.Bar.*;
class Bar {
public static final void f() {}
}
public class Foo {
public static final void f(int i) {}
{
<caret>Bar.f(); // invoke 'add on demand static import' for Bar class here. The call is now done to other method.
}
}
@@ -0,0 +1,13 @@
// "Add on demand static import for 'test.Bar'" "true"
package test;
class Bar {
public static final void f() {}
}
public class Foo {
public static final void f(int i) {}
{
<caret>Bar.f(); // invoke 'add on demand static import' for Bar class here. The call is now done to other method.
}
}
@@ -0,0 +1,34 @@
// "Add on demand static import for 'test.Bar'" "true"
package test;
class Bar {
public static final void f() {
}
}
public class Foo {
{
Bar.f(); // invoke 'add on demand static import' for Bar class here. The call is now done to other method.
}
static class D {
public static final void f(int i) {
}
{
Bar.f(); // invoke 'add on demand static import' for Bar class here. The call is now done to other method.
}
}
{
Bar.f(); // invoke 'add on demand static import' for Bar class here. The call is now done to other method.
}
{
Bar.f(); // invoke 'add on demand static import' for Bar class here. The call is now done to other method.
}
{
<caret>Bar.f(); // invoke 'add on demand static import' for Bar class here. The call is now done to other method.
}
}
@@ -0,0 +1,7 @@
// "Add Return Statement" "true"
class a {
int f() {
return <caret><selection>0</selection>;
}
}
@@ -0,0 +1,7 @@
// "Add Return Statement" "true"
class a {
String f() {
return <caret><selection>null</selection>;
}
}
@@ -0,0 +1,8 @@
// "Add Return Statement" "true"
class a {
int f() {
int i = 0;
return <caret><selection>i</selection>;
}
}
@@ -0,0 +1,7 @@
// "Add Return Statement" "true"
class a {
int f(int p) {
return <caret><selection>p</selection>;
}
}
@@ -0,0 +1,8 @@
// "Add Return Statement" "true"
class a {
int f() {
short i = 0;
return <caret><selection>0</selection>;
}
}
@@ -0,0 +1,6 @@
// "Add Return Statement" "true"
class a {
int f() {
<caret>}
}
@@ -0,0 +1,6 @@
// "Add Return Statement" "true"
class a {
String f() {
<caret>}
}
@@ -0,0 +1,7 @@
// "Add Return Statement" "true"
class a {
int f() {
int i = 0;
<caret>}
}
@@ -0,0 +1,6 @@
// "Add Return Statement" "true"
class a {
int f(int p) {
<caret>}
}
@@ -0,0 +1,7 @@
// "Add Return Statement" "true"
class a {
int f() {
short i = 0;
<caret>}
}
@@ -0,0 +1,7 @@
// "Add Method Body" "false"
class a {
String f() {
return null;
<caret>}
}
@@ -0,0 +1,7 @@
// "Add Runtime Exception(s) to Method Signature" "true"
class a {
int f() throws RuntimeException {
throw new RuntimeException()<caret>;
}
}
@@ -0,0 +1,7 @@
// "Add Runtime Exception(s) to Method Signature" "true"
class a {
int f() {
throw new RuntimeException()<caret>;
}
}
@@ -0,0 +1,7 @@
// "Add Runtime Exception(s) to Method Signature" "false"
class a {
int f() throws RuntimeException{
throw new RuntimeException()<caret>;
}
}
@@ -0,0 +1,13 @@
// "Add explicit type arguments" "true"
import java.util.List;
import java.util.Collections;
class Example {
void f(List<String> list) {}
void g() {
f(<caret>Collections.<String>emptyList());
}
}
@@ -0,0 +1,13 @@
// "Add explicit type arguments" "true"
import java.util.Collection;
import java.util.Collections;
class Example {
void f(Collection<String> list) {}
void g() {
f(<caret>Collections.<String>emptyList());
}
}
@@ -0,0 +1,13 @@
// "Add explicit type arguments" "true"
import java.util.List;
import java.util.Collections;
class Example {
Example(List<String> list) {}
void g() {
new Example(<caret>Collections.<String>emptyList());
}
}
@@ -0,0 +1,13 @@
// "Add explicit type arguments" "true"
import java.util.List;
import java.util.Collections;
class Example {
void f(List<String> list) {}
void g() {
f(<caret>Collections.emptyList());
}
}
@@ -0,0 +1,13 @@
// "Add explicit type arguments" "true"
import java.util.Collection;
import java.util.Collections;
class Example {
void f(Collection<String> list) {}
void g() {
f(<caret>Collections.emptyList());
}
}
@@ -0,0 +1,13 @@
// "Add explicit type arguments" "true"
import java.util.List;
import java.util.Collections;
class Example {
Example(List<String> list) {}
void g() {
new Example(<caret>Collections.emptyList());
}
}
@@ -0,0 +1,7 @@
// "Cast to 'char'" "true"
class a {
void f(int i) {
<caret>char c = (char) i;
}
}
@@ -0,0 +1,16 @@
// "Cast to 'A.Iterator<java.lang.String>'" "true"
class A {
interface Iterator<T> {
}
class List<T> {
Iterator<T> iterator() {
return null;
}
}
void method() {
List l = new List();
<caret>Iterator<String> it = (Iterator<String>) l.iterator();
}
}
@@ -0,0 +1,7 @@
// "Cast to 'b'" "true"
class a {
void f(a a) {
<caret>b b = (b) a;
}
}
class b extends a {}
@@ -0,0 +1,6 @@
// "Cast to 'int'" "true"
class a {
void f() {
int[] ii = {<caret>(int) 1.3};
}
}
@@ -0,0 +1,7 @@
// "Cast to 'int'" "true"
class a {
void f() {
int i;
<caret>i = (int) 3.4f;
}
}
@@ -0,0 +1,7 @@
// "Cast to 'float'" "true"
class a {
float f() {
double d = 4;
return <caret>(float) d;
}
}
@@ -0,0 +1,8 @@
// "Cast to 'int'" "true"
class a {
void f() {
double d = 4;
switch (<caret>(int) d) {
}
}
}
@@ -0,0 +1,9 @@
// "Cast to 'char'" "true"
class a {
void f() {
double d = 4;
switch ('c') {
case <caret>(char) 3.3:
}
}
}
@@ -0,0 +1,7 @@
// "Cast to 'java.lang.String'" "true"
class a {
void f() {
Object y = null;
String s = <caret>(String) y;
}
}
@@ -0,0 +1,7 @@
// "Cast to 'B'" "true"
class A {
void f(B b) {
B s = <caret>b == null ? (B) this : b;
}
}
class B extends A {}
@@ -0,0 +1,7 @@
// "Cast to 'B'" "true"
class A {
void f(B b) {
B s = <caret>b == null ? null : (B) this;
}
}
class B extends A {}
@@ -0,0 +1,7 @@
// "Cast to 'B'" "true"
class A {
void f(B b) {
B s = <caret>(B) (b == null ? this : this);
}
}
class B extends A {}
@@ -0,0 +1,7 @@
// "Cast to 'char'" "true"
class a {
void f(int i) {
<caret>char c = i;
}
}
@@ -0,0 +1,16 @@
// "Cast to 'A.Iterator<java.lang.String>'" "true"
class A {
interface Iterator<T> {
}
class List<T> {
Iterator<T> iterator() {
return null;
}
}
void method() {
List l = new List();
<caret>Iterator<String> it = (Iterator<Object>)l.iterator();
}
}
@@ -0,0 +1,7 @@
// "Cast to 'b'" "true"
class a {
void f(a a) {
<caret>b b = a;
}
}
class b extends a {}
@@ -0,0 +1,6 @@
// "Cast to 'int'" "true"
class a {
void f() {
int[] ii = { <caret>1.3 };
}
}
@@ -0,0 +1,7 @@
// "Cast to 'int'" "true"
class a {
void f() {
int i;
<caret>i = 3.4f;
}
}
@@ -0,0 +1,7 @@
// "Cast to 'float'" "true"
class a {
float f() {
double d = 4;
return <caret>d;
}
}
@@ -0,0 +1,8 @@
// "Cast to 'int'" "true"
class a {
void f() {
double d = 4;
switch (<caret>d) {
}
}
}
@@ -0,0 +1,9 @@
// "Cast to 'char'" "true"
class a {
void f() {
double d = 4;
switch ('c') {
case <caret>3.3:
}
}
}
@@ -0,0 +1,6 @@
// "Cast to 'java.lang.String'" "false"
class a {
void f() {
String s = <caret>1;
}
}
@@ -0,0 +1,7 @@
// "Cast to 'java.lang.String'" "true"
class a {
void f() {
Object y = null;
String s = <caret>(Integer) y;
}
}
@@ -0,0 +1,7 @@
// "Cast to 'B'" "true"
class A {
void f(B b) {
B s = <caret>b == null ? this : b;
}
}
class B extends A {}
@@ -0,0 +1,7 @@
// "Cast to 'B'" "true"
class A {
void f(B b) {
B s = <caret>b == null ? null : this;
}
}
class B extends A {}
@@ -0,0 +1,7 @@
// "Cast to 'B'" "true"
class A {
void f(B b) {
B s = <caret>b == null ? this : this;
}
}
class B extends A {}
@@ -0,0 +1,10 @@
// "Initialize variable 'i'" "true"
class AClass
{
int f() {
int i = <caret><selection>0</selection>;
return i;
}
}
@@ -0,0 +1,7 @@
// "Initialize variable 'f'" "true"
class AClass
{
final AClass f = <caret><selection>null</selection>;
}
@@ -0,0 +1,10 @@
// "Initialize variable 'i'" "true"
class AClass
{
int f() {
int i;
return <caret>i;
}
}
@@ -0,0 +1,7 @@
// "Initialize variable 'f'" "true"
class AClass
{
final AClass f<caret>;
}
@@ -0,0 +1,19 @@
// "Annotate method as @NotNull" "true"
import org.jetbrains.annotations.NotNull;
class X {
@NotNull
String foo() {
return "X";
}
}
class Y extends X{
String foo() {
return "Y";
}
}
class Z extends Y {
String foo<caret>() { // trigger quick fix for inspection here
return "Z";
}
}
@@ -0,0 +1,21 @@
// "Annotate method as @NotNull" "true"
import org.jetbrains.annotations.NotNull;
class X {
@NotNull
String annotateBase() {
return "X";
}
}
class Y extends X{
@NotNull
String annotateBase() {
return "Y";
}
}
class Z extends Y {
@NotNull
String annotateBase<caret>() { // trigger quick fix for inspection here
return "Z";
}
}
@@ -0,0 +1,8 @@
// "Remove annotation" "true"
import org.jetbrains.annotations.*;
class Foo {
<caret>@Nullable
String foo(){return "";}
}
@@ -0,0 +1,20 @@
// "Annotate method as @NotNull" "true"
import org.jetbrains.annotations.NotNull;
class X {
@NotNull
String dontAnnotateBase() {
return "X";
}
}
class Y extends X{
String dontAnnotateBase() {
return "Y";
}
}
class Z extends Y {
@NotNull
String dontAnnotateBase<caret>() { // trigger quick fix for inspection here
return "Z";
}
}
@@ -0,0 +1,23 @@
// "Annotate overridden methods as @NotNull" "true"
import org.jetbrains.annotations.NotNull;
abstract class P2 {
@NotNull<caret>
String foo(@NotNull P p) {
return "";
}
}
class PPP extends P2 {
@NotNull
String foo(P p) {
return super.foo(p);
}
}
class PPP2 extends P2 {
@NotNull
String foo(P p) {
return super.foo(p);
}
}
@@ -0,0 +1,21 @@
// "Annotate overridden methods parameters as @NotNull" "true"
import org.jetbrains.annotations.NotNull;
abstract class P2 {
@NotNull
String foo(@NotNull<caret> P p) {
return "";
}
}
class PPP extends P2 {
String foo(@NotNull P p) {
return super.foo(p);
}
}
class PPP2 extends P2 {
String foo(@NotNull P p) {
return super.foo(p);
}
}
@@ -0,0 +1,7 @@
// "Remove annotation" "true"
import org.jetbrains.annotations.*;
class Foo {
<caret>int foo(){return 0;}
}
@@ -0,0 +1,16 @@
// "Annotate overridden methods as @NotNull" "true"
import org.jetbrains.annotations.*;
public class XEM {
<caret>@NotNull
String f(){
return "";
}
}
class XC extends XEM {
@NotNull
String f() {
return "";
}
}
@@ -0,0 +1,19 @@
// "Annotate method as @NotNull" "true"
import org.jetbrains.annotations.NotNull;
class X {
@NotNull
String foo() {
return "X";
}
}
class Y extends X{
String foo() {
return "Y";
}
}
class Z extends Y {
String foo<caret>() { // trigger quick fix for inspection here
return "Z";
}
}
@@ -0,0 +1,19 @@
// "Annotate method as @NotNull" "true"
import org.jetbrains.annotations.NotNull;
class X {
@NotNull
String annotateBase() {
return "X";
}
}
class Y extends X{
String annotateBase() {
return "Y";
}
}
class Z extends Y {
String annotateBase<caret>() { // trigger quick fix for inspection here
return "Z";
}
}
@@ -0,0 +1,8 @@
// "Remove annotation" "true"
import org.jetbrains.annotations.*;
class Foo {
<caret>@NotNull @Nullable
String foo(){return "";}
}
@@ -0,0 +1,19 @@
// "Annotate method as @NotNull" "true"
import org.jetbrains.annotations.NotNull;
class X {
@NotNull
String dontAnnotateBase() {
return "X";
}
}
class Y extends X{
String dontAnnotateBase() {
return "Y";
}
}
class Z extends Y {
String dontAnnotateBase<caret>() { // trigger quick fix for inspection here
return "Z";
}
}
@@ -0,0 +1,21 @@
// "Annotate overridden methods as @NotNull" "true"
import org.jetbrains.annotations.NotNull;
abstract class P2 {
@NotNull<caret>
String foo(@NotNull P p) {
return "";
}
}
class PPP extends P2 {
String foo(P p) {
return super.foo(p);
}
}
class PPP2 extends P2 {
String foo(P p) {
return super.foo(p);
}
}
@@ -0,0 +1,21 @@
// "Annotate overridden methods parameters as @NotNull" "true"
import org.jetbrains.annotations.NotNull;
abstract class P2 {
@NotNull
String foo(@NotNull<caret> P p) {
return "";
}
}
class PPP extends P2 {
String foo(P p) {
return super.foo(p);
}
}
class PPP2 extends P2 {
String foo(P p) {
return super.foo(p);
}
}
@@ -0,0 +1,8 @@
// "Remove annotation" "true"
import org.jetbrains.annotations.*;
class Foo {
<caret>@NotNull
int foo(){return 0;}
}

Some files were not shown because too many files have changed in this diff Show More