mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-26 19:06:24 +07:00
test for "Replace 'for each' loop with indexed 'for' loop"
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
package com.siyeh.ipp.forloop.indexed;
|
||||
|
||||
class LabeledForLoop {
|
||||
|
||||
int[] getArr() {
|
||||
Label:
|
||||
<caret>for (int x: getArr()) {}
|
||||
return new int[]{1};
|
||||
}
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.siyeh.ipp.forloop.indexed;
|
||||
|
||||
class LabeledForLoop {
|
||||
|
||||
int[] getArr() {
|
||||
int[] arr = getArr();
|
||||
Label:
|
||||
for (int i = 0, arrLength = arr.length; i < arrLength; i++) {
|
||||
int x = arr[i];
|
||||
}
|
||||
return new int[]{1};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package com.siyeh.ipp.forloop.indexed;
|
||||
|
||||
class NewArray {
|
||||
void foo() {
|
||||
<caret>for (int k : new int[3]) {
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
package com.siyeh.ipp.forloop.indexed;
|
||||
|
||||
class NewArray {
|
||||
void foo() {
|
||||
int[] ints = new int[3];
|
||||
for (int i = 0, intsLength = ints.length; i < intsLength; i++) {
|
||||
int k = ints[i];
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
package com.siyeh.ipp.forloop.indexed;
|
||||
|
||||
class NormalForEachLoop {
|
||||
void foo(int[] is) {
|
||||
<caret>for (int i : is) {
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.siyeh.ipp.forloop.indexed;
|
||||
|
||||
class NormalForEachLoop {
|
||||
void foo(int[] is) {
|
||||
for (int i1 = 0, isLength = is.length; i1 < isLength; i1++) {
|
||||
int i = is[i1];
|
||||
System.out.println(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
+35
@@ -0,0 +1,35 @@
|
||||
/*
|
||||
* Copyright 2000-2012 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package com.siyeh.ipp.forloop;
|
||||
|
||||
import com.siyeh.IntentionPowerPackBundle;
|
||||
import com.siyeh.ipp.IPPTestCase;
|
||||
|
||||
public class ReplaceForEachLoopWithIndexedForLoopIntentionTest extends IPPTestCase {
|
||||
public void testLabeledForLoop() { doTest(); }
|
||||
public void testNormalForeachLoop() { doTest(); }
|
||||
public void testNewArray() { doTest(); }
|
||||
|
||||
@Override
|
||||
protected String getIntentionName() {
|
||||
return IntentionPowerPackBundle.message("replace.for.each.loop.with.indexed.for.loop.intention.name");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getRelativePath() {
|
||||
return "forloop/indexed";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user