Change test name. Change order of parameters in test instructions
This commit is contained in:
+2
-2
@@ -7,5 +7,5 @@ fun foo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// METHOD : invoke(I)V
|
// METHOD : invoke(I)V
|
||||||
// VARIABLE : INDEX=0 NAME=this TYPE=Lnamespace$foo$1$1;
|
// VARIABLE : NAME=this TYPE=Lnamespace$foo$1$1; INDEX=0
|
||||||
// VARIABLE : INDEX=1 NAME=it TYPE=I
|
// VARIABLE : NAME=it TYPE=I INDEX=1
|
||||||
+1
-1
@@ -5,4 +5,4 @@ fun foo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// METHOD : invoke()V
|
// METHOD : invoke()V
|
||||||
// VARIABLE : INDEX=0 NAME=this TYPE=Lnamespace$foo$a$1;
|
// VARIABLE : NAME=this TYPE=Lnamespace$foo$a$1; INDEX=0
|
||||||
+24
-22
@@ -51,12 +51,12 @@ import java.util.regex.Pattern;
|
|||||||
* @author Natalia.Ukhorskaya
|
* @author Natalia.Ukhorskaya
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class WriteThisForClosureTest extends TestCaseWithTmpdir {
|
public class CheckLocalVariablesTableTest extends TestCaseWithTmpdir {
|
||||||
|
|
||||||
private final File ktFile;
|
private final File ktFile;
|
||||||
private JetCoreEnvironment jetCoreEnvironment;
|
private JetCoreEnvironment jetCoreEnvironment;
|
||||||
|
|
||||||
public WriteThisForClosureTest(File ktFile) {
|
public CheckLocalVariablesTableTest(File ktFile) {
|
||||||
this.ktFile = ktFile;
|
this.ktFile = ktFile;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,9 +93,9 @@ public class WriteThisForClosureTest extends TestCaseWithTmpdir {
|
|||||||
int index = 0;
|
int index = 0;
|
||||||
for (LocalVariable expectedVariable : expectedLocalVariables) {
|
for (LocalVariable expectedVariable : expectedLocalVariables) {
|
||||||
LocalVariable actualVariable = actualLocalVariables.get(index);
|
LocalVariable actualVariable = actualLocalVariables.get(index);
|
||||||
assertEquals("Indexes are different", expectedVariable.index, actualVariable.index);
|
|
||||||
assertEquals("Names are different", expectedVariable.name, actualVariable.name);
|
assertEquals("Names are different", expectedVariable.name, actualVariable.name);
|
||||||
assertEquals("Types are different", expectedVariable.type, actualVariable.type);
|
assertEquals("Types are different", expectedVariable.type, actualVariable.type);
|
||||||
|
assertEquals("Indexes are different", expectedVariable.index, actualVariable.index);
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -106,20 +106,19 @@ public class WriteThisForClosureTest extends TestCaseWithTmpdir {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Disposer.dispose(myTestRootDisposable);
|
Disposer.dispose(myTestRootDisposable);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static Test suite() {
|
public static Test suite() {
|
||||||
return JetTestCaseBuilder.suiteForDirectory(JetTestCaseBuilder.getTestDataPathBase(), "/writeThisInLocalVariableTable", true,
|
return JetTestCaseBuilder.suiteForDirectory(JetTestCaseBuilder.getTestDataPathBase(), "/checkLocalVariablesTable", true,
|
||||||
new JetTestCaseBuilder.NamedTestFactory() {
|
new JetTestCaseBuilder.NamedTestFactory() {
|
||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public Test createTest(@NotNull String dataPath,
|
public Test createTest(@NotNull String dataPath,
|
||||||
@NotNull String name,
|
@NotNull String name,
|
||||||
@NotNull File file) {
|
@NotNull File file) {
|
||||||
return new WriteThisForClosureTest(file);
|
return new CheckLocalVariablesTableTest(file);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -129,9 +128,11 @@ public class WriteThisForClosureTest extends TestCaseWithTmpdir {
|
|||||||
private final String type;
|
private final String type;
|
||||||
private final int index;
|
private final int index;
|
||||||
|
|
||||||
private LocalVariable(int index,
|
private LocalVariable(
|
||||||
@NotNull String name,
|
@NotNull String name,
|
||||||
@NotNull String type) {
|
@NotNull String type,
|
||||||
|
int index
|
||||||
|
) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.type = type;
|
this.type = type;
|
||||||
this.index = index;
|
this.index = index;
|
||||||
@@ -141,29 +142,29 @@ public class WriteThisForClosureTest extends TestCaseWithTmpdir {
|
|||||||
@NotNull
|
@NotNull
|
||||||
private static final Pattern methodPattern = Pattern.compile("^// METHOD : *(.*)");
|
private static final Pattern methodPattern = Pattern.compile("^// METHOD : *(.*)");
|
||||||
|
|
||||||
private static final Pattern namePattern = Pattern.compile("^// VARIABLE : INDEX=*(.*) NAME=.* TYPE=.*");
|
private static final Pattern namePattern = Pattern.compile("^// VARIABLE : NAME=*(.*) TYPE=.* INDEX=.*");
|
||||||
private static final Pattern typePattern = Pattern.compile("^// VARIABLE : INDEX=.* NAME=*(.*) TYPE=.*");
|
private static final Pattern typePattern = Pattern.compile("^// VARIABLE : NAME=.* TYPE=*(.*) INDEX=.*");
|
||||||
private static final Pattern indexPattern = Pattern.compile("^// VARIABLE : INDEX=.* NAME=.* TYPE=*(.*)");
|
private static final Pattern indexPattern = Pattern.compile("^// VARIABLE : NAME=.* TYPE=.* INDEX=*(.*)");
|
||||||
|
|
||||||
|
|
||||||
private List<LocalVariable> parseExpectations() throws IOException {
|
private List<LocalVariable> parseExpectations() throws IOException {
|
||||||
List<String> lines = Files.readLines(ktFile, Charset.forName("utf-8"));
|
List<String> lines = Files.readLines(ktFile, Charset.forName("utf-8"));
|
||||||
List<LocalVariable> expectedLocalVariables = new ArrayList<LocalVariable>();
|
List<LocalVariable> expectedLocalVariables = new ArrayList<LocalVariable>();
|
||||||
for (int i = lines.size() - 3; i < lines.size(); ++i) {
|
for (int i = lines.size() - 3; i < lines.size(); ++i) {
|
||||||
Matcher indexMatcher = namePattern.matcher(lines.get(i));
|
Matcher nameMatcher = namePattern.matcher(lines.get(i));
|
||||||
if (indexMatcher.matches()) {
|
if (nameMatcher.matches()) {
|
||||||
Matcher nameMatcher = typePattern.matcher(lines.get(i));
|
Matcher typeMatcher = typePattern.matcher(lines.get(i));
|
||||||
Matcher typeMatcher = indexPattern.matcher(lines.get(i));
|
Matcher indexMatcher = indexPattern.matcher(lines.get(i));
|
||||||
|
|
||||||
if (!nameMatcher.matches()
|
if (!typeMatcher.matches()
|
||||||
|| !typeMatcher.matches()) {
|
|| !indexMatcher.matches()) {
|
||||||
throw new AssertionError("Incorrect test instructions format");
|
throw new AssertionError("Incorrect test instructions format");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
expectedLocalVariables.add(new LocalVariable(Integer.parseInt(indexMatcher.group(1)),
|
expectedLocalVariables.add(new LocalVariable(nameMatcher.group(1),
|
||||||
nameMatcher.group(1),
|
typeMatcher.group(1),
|
||||||
typeMatcher.group(1)));
|
Integer.parseInt(indexMatcher.group(1))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (expectedLocalVariables.size() == 0) {
|
if (expectedLocalVariables.size() == 0) {
|
||||||
@@ -176,7 +177,7 @@ public class WriteThisForClosureTest extends TestCaseWithTmpdir {
|
|||||||
|
|
||||||
private String parseMethodName() throws IOException {
|
private String parseMethodName() throws IOException {
|
||||||
List<String> lines = Files.readLines(ktFile, Charset.forName("utf-8"));
|
List<String> lines = Files.readLines(ktFile, Charset.forName("utf-8"));
|
||||||
for (int i = lines.size() - 3; i < lines.size(); ++i) {
|
for (int i = 0; i < lines.size(); ++i) {
|
||||||
Matcher methodMatcher = methodPattern.matcher(lines.get(i));
|
Matcher methodMatcher = methodPattern.matcher(lines.get(i));
|
||||||
if (methodMatcher.matches()) {
|
if (methodMatcher.matches()) {
|
||||||
return methodMatcher.group(1);
|
return methodMatcher.group(1);
|
||||||
@@ -198,8 +199,9 @@ public class WriteThisForClosureTest extends TestCaseWithTmpdir {
|
|||||||
return new EmptyVisitor() {
|
return new EmptyVisitor() {
|
||||||
@Override
|
@Override
|
||||||
public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
|
public void visitLocalVariable(String name, String desc, String signature, Label start, Label end, int index) {
|
||||||
readVariables.add(new LocalVariable(index, name, desc));
|
readVariables.add(new LocalVariable(name, desc, index));
|
||||||
}
|
}
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
Reference in New Issue
Block a user