IDEA-54000 Move java formatting tests to community edition

Moved from 'idea-tests' to 'java-tests' because java formatter belongs to community edition
This commit is contained in:
Denis Zhdanov
2010-04-19 19:26:51 +04:00
parent ceac16de83
commit e42c2fdcab
32 changed files with 387 additions and 0 deletions
@@ -0,0 +1,5 @@
class Test {
class Inner{
int myField;
}
}
@@ -0,0 +1,5 @@
class Test {
class Inner{
int myField;
}
}
@@ -0,0 +1,6 @@
class Foo {
void foo() {
foo(
);
}
}
@@ -0,0 +1,7 @@
class Foo {
void foo() {
foo(
);
}
}
@@ -0,0 +1,15 @@
public class A {
private void foo() {
Runnable a = new Runnable() {
private int a;
public void run() {
newMethod();
}
private void newMethod() {
a = 2;
}
};
}
}
@@ -0,0 +1,16 @@
public class A {
private void foo() {
Runnable a = new Runnable() {
private int a;
public void run() {
newMethod();
}
private void newMethod() {
a = 2;
}
};
}
}
@@ -0,0 +1,11 @@
class Foo {
void foo(){
try {
// comment before
g();
// comment after
} catch (Exception e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
}
@@ -0,0 +1,11 @@
class Foo {
void foo(){
try {
// comment before
g();
// comment after
} catch (Exception e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
}
}
@@ -0,0 +1,8 @@
class Foo{
void foo() {
someVariable = x =
x +
y;
}
}
@@ -0,0 +1,9 @@
class Foo {
void foo() {
someVariable = x =
x +
y;
}
}
@@ -0,0 +1,10 @@
class Foo {
void foo(){
for (int i = 0;
i < 5;
i++) {
doSomething(i);
}
}
}
@@ -0,0 +1,11 @@
class Foo {
void foo() {
for (int i = 0;
i < 5;
i++) {
doSomething(i);
}
}
}
@@ -0,0 +1,7 @@
class Foo{
public void foo(){
int someVariable = (y +
z
);
}
}
@@ -0,0 +1,8 @@
class Foo {
public void foo() {
int someVariable = (y +
z
);
}
}
@@ -0,0 +1,7 @@
class A {
A IMPL = new A() {
void f(boolean b) {
bar();
}
};
}
@@ -0,0 +1,8 @@
class A {
A IMPL = new A() {
void f(boolean b) {
bar();
}
};
}
@@ -0,0 +1,17 @@
public class A {
void f() {
new My() {
public void f() {
int i = 9;
int j = 9;
}
};
new My() {
public void f() {
l();
l();
}
};
}
}
@@ -0,0 +1,18 @@
public class A {
void f() {
new My() {
public void f() {
int i = 9;
int j = 9;
}
};
new My() {
public void f() {
l();
l();
}
};
}
}
@@ -0,0 +1,5 @@
class Foo {
void foo () {
assert false;
}
}
@@ -0,0 +1,6 @@
class Foo {
void foo() {
assert false;
}
}
@@ -0,0 +1,34 @@
class Foo {
void foo(){
if (a)
{
}
while(a)
{
}
do
{
} while(a);
try
{
}
catch(Exception e)
{
}
finally
{
}
switch(a)
{
}
for(a)
{
}
}
}
@@ -0,0 +1,25 @@
class Foo {
void foo() {
if (a) {
}
while (a) {
}
do {
} while (a);
try {
} catch (Exception e) {
} finally {
}
switch (a) {
}
for (a) {
}
}
}
@@ -0,0 +1,7 @@
class Foo{
public void a(){
if (b) {
break;
}
}
}
@@ -0,0 +1,8 @@
class Foo {
public void a() {
if (b) {
break;
}
}
}
@@ -0,0 +1,9 @@
class Foo {
public void foo(){
if (a) {
} else {
((String)value)
}
}
}
@@ -0,0 +1,10 @@
class Foo {
public void foo() {
if (a) {
} else {
((String) value)
}
}
}
@@ -0,0 +1,36 @@
class FormattingTest {
private static FormattingTest staticFoo;
private FormattingTest instanceFoo;
@SuppressWarnings({"AccessStaticViaInstance"})
public void test() {
// Long chained method calls with initial instance target - method calls are aligned to the first method
// call place.
instanceFoo.instanceMethodWithQuiteLongNameIndeed().staticMethodWithQuiteLongNameIndeed().instanceMethodWithQuiteLongNameIndeed().instanceMethodWithQuiteLongNameIndeed().staticMethodWithQuiteLongNameIndeed();
// Long chained method calls with initial static target - method calls are aligned to the first method
// call place.
staticFoo.instanceMethodWithQuiteLongNameIndeed().staticMethodWithQuiteLongNameIndeed().instanceMethodWithQuiteLongNameIndeed().instanceMethodWithQuiteLongNameIndeed().staticMethodWithQuiteLongNameIndeed();
// Interleaved method call chains - every sub-chain is aligned to its own target
instanceFoo.instanceMethodWithQuiteLongNameIndeed().staticMethodWithQuiteLongNameIndeed().instanceMethodWithQuiteLongNameIndeed().instanceFoo.instanceMethodWithQuiteLongNameIndeed().staticMethodWithQuiteLongNameIndeed().instanceMethodWithQuiteLongNameIndeed();
// Interleaved method call chains with manual line break - every sub-chain is aligned to its own
// target and manual line break is preserved.
instanceFoo.instanceMethodWithQuiteLongNameIndeed().staticMethodWithQuiteLongNameIndeed()
.instanceFoo.instanceMethodWithQuiteLongNameIndeed().staticMethodWithQuiteLongNameIndeed().instanceMethodWithQuiteLongNameIndeed();
// Chained calls with implicit target - method calls are not aligned and use continuation indent instead.
instanceMethodWithQuiteLongNameIndeed().instanceMethodWithQuiteLongNameIndeed().instanceMethodWithQuiteLongNameIndeed().instanceMethodWithQuiteLongNameIndeed();
}
public FormattingTest instanceMethodWithQuiteLongNameIndeed() {
return instanceFoo;
}
public static FormattingTest staticMethodWithQuiteLongNameIndeed() {
return staticFoo;
}
}
@@ -0,0 +1,45 @@
class FormattingTest {
private static FormattingTest staticFoo;
private FormattingTest instanceFoo;
@SuppressWarnings({"AccessStaticViaInstance"})
public void test() {
// Long chained method calls with initial instance target - method calls are aligned to the first method
// call place.
instanceFoo.instanceMethodWithQuiteLongNameIndeed().staticMethodWithQuiteLongNameIndeed()
.instanceMethodWithQuiteLongNameIndeed().instanceMethodWithQuiteLongNameIndeed()
.staticMethodWithQuiteLongNameIndeed();
// Long chained method calls with initial static target - method calls are aligned to the first method
// call place.
staticFoo.instanceMethodWithQuiteLongNameIndeed().staticMethodWithQuiteLongNameIndeed()
.instanceMethodWithQuiteLongNameIndeed().instanceMethodWithQuiteLongNameIndeed()
.staticMethodWithQuiteLongNameIndeed();
// Interleaved method call chains - every sub-chain is aligned to its own target
instanceFoo.instanceMethodWithQuiteLongNameIndeed().staticMethodWithQuiteLongNameIndeed()
.instanceMethodWithQuiteLongNameIndeed().instanceFoo.instanceMethodWithQuiteLongNameIndeed()
.staticMethodWithQuiteLongNameIndeed()
.instanceMethodWithQuiteLongNameIndeed();
// Interleaved method call chains with manual line break - every sub-chain is aligned to its own
// target and manual line break is preserved.
instanceFoo.instanceMethodWithQuiteLongNameIndeed().staticMethodWithQuiteLongNameIndeed()
.instanceFoo.instanceMethodWithQuiteLongNameIndeed().staticMethodWithQuiteLongNameIndeed()
.instanceMethodWithQuiteLongNameIndeed();
// Chained calls with implicit target - method calls are not aligned and use continuation indent instead.
instanceMethodWithQuiteLongNameIndeed().instanceMethodWithQuiteLongNameIndeed()
.instanceMethodWithQuiteLongNameIndeed().instanceMethodWithQuiteLongNameIndeed();
}
public FormattingTest instanceMethodWithQuiteLongNameIndeed() {
return instanceFoo;
}
public static FormattingTest staticMethodWithQuiteLongNameIndeed() {
return staticFoo;
}
}
@@ -0,0 +1,5 @@
class A {
void foo() {
continue;
}
}
@@ -0,0 +1,6 @@
class A {
void foo() {
continue;
}
}
@@ -0,0 +1,6 @@
class C {
{
String q = (String) ( (String)"abc" );
}
}
@@ -0,0 +1,6 @@
class C {
{
String q = (String) ((String) "abc");
}
}