KT-2633 Support multiple assignment in JVM Back-end

#KT-2633 Fixed
This commit is contained in:
Svetlana Isakova
2012-08-21 16:12:30 +04:00
parent 239c5fd94b
commit 47362bf2ac
16 changed files with 355 additions and 2 deletions
@@ -0,0 +1,56 @@
/*
* Copyright 2010-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 org.jetbrains.jet.codegen;
import org.jetbrains.jet.test.generator.SimpleTestClassModel;
import org.jetbrains.jet.test.generator.TestGenerator;
import java.io.File;
import java.io.IOException;
import java.util.Arrays;
/**
* @author svtk
*/
public abstract class AbstractMultiDeclTestCase extends CodegenTestCase {
@Override
protected String getPrefix() {
return "multiDecl";
}
@Override
protected void setUp() throws Exception {
super.setUp();
createEnvironmentWithMockJdkAndIdeaAnnotations();
}
public static void main(String[] args) throws IOException {
Class<AbstractMultiDeclTestCase> thisClass = AbstractMultiDeclTestCase.class;
String aPackage = thisClass.getPackage().getName();
new TestGenerator(
"compiler/tests/",
aPackage,
"MultiDeclTestGenerated",
thisClass,
Arrays.asList(
new SimpleTestClassModel(new File("compiler/testData/codegen/multiDecl"), true, "kt", "blackBoxFileByFullPath")
),
thisClass
).generateAndSave();
}
}
@@ -20,6 +20,7 @@ import com.google.common.base.Predicates;
import com.google.common.collect.Lists;
import com.intellij.openapi.util.Pair;
import com.intellij.openapi.util.SystemInfo;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.psi.PsiFile;
import com.intellij.testFramework.UsefulTestCase;
import org.jetbrains.annotations.NotNull;
@@ -121,6 +122,17 @@ public abstract class CodegenTestCase extends UsefulTestCase {
}
}
protected String loadFileByFullPath(final String fullPath) {
try {
File file = new File(fullPath);
final String content = FileUtil.loadFile(file, true);
myFiles = CodegenTestFiles.create(file.getName(), content, myEnvironment.getProject());
return content;
} catch (IOException e) {
throw new RuntimeException(e);
}
}
protected void loadFiles(final String... names) {
myFiles = CodegenTestFiles.create(myEnvironment.getProject(), names);
}
@@ -138,6 +150,11 @@ public abstract class CodegenTestCase extends UsefulTestCase {
blackBox();
}
protected void blackBoxFileByFullPath(String filename) {
loadFileByFullPath(filename);
blackBox();
}
protected void blackBoxMultiFile(String... filenames) {
loadFiles(filenames);
blackBox();
@@ -0,0 +1,85 @@
/*
* Copyright 2010-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 org.jetbrains.jet.codegen;
import junit.framework.Assert;
import junit.framework.Test;
import junit.framework.TestSuite;
import java.io.File;
import org.jetbrains.jet.JetTestUtils;
import org.jetbrains.jet.test.TestMetadata;
import org.jetbrains.jet.codegen.AbstractMultiDeclTestCase;
/** This class is generated by {@link org.jetbrains.jet.codegen.AbstractMultiDeclTestCase}. DO NOT MODIFY MANUALLY */
@TestMetadata("compiler/testData/codegen/multiDecl")
public class MultiDeclTestGenerated extends AbstractMultiDeclTestCase {
public void testAllFilesPresentInMultiDecl() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.codegen.AbstractMultiDeclTestCase", new File("compiler/testData/codegen/multiDecl"), "kt", false);
}
@TestMetadata("ComplexInitializer.kt")
public void testComplexInitializer() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/ComplexInitializer.kt");
}
@TestMetadata("SimpleVals.kt")
public void testSimpleVals() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/SimpleVals.kt");
}
@TestMetadata("SimpleValsExtensions.kt")
public void testSimpleValsExtensions() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/SimpleValsExtensions.kt");
}
@TestMetadata("SimpleVarsExtensions.kt")
public void testSimpleVarsExtensions() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/SimpleVarsExtensions.kt");
}
@TestMetadata("ValCapturedInFunctionLiteral.kt")
public void testValCapturedInFunctionLiteral() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/ValCapturedInFunctionLiteral.kt");
}
@TestMetadata("ValCapturedInLocalFunction.kt")
public void testValCapturedInLocalFunction() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/ValCapturedInLocalFunction.kt");
}
@TestMetadata("ValCapturedInObjectLiteral.kt")
public void testValCapturedInObjectLiteral() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/ValCapturedInObjectLiteral.kt");
}
@TestMetadata("VarCapturedInFunctionLiteral.kt")
public void testVarCapturedInFunctionLiteral() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/VarCapturedInFunctionLiteral.kt");
}
@TestMetadata("VarCapturedInLocalFunction.kt")
public void testVarCapturedInLocalFunction() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/VarCapturedInLocalFunction.kt");
}
@TestMetadata("VarCapturedInObjectLiteral.kt")
public void testVarCapturedInObjectLiteral() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/VarCapturedInObjectLiteral.kt");
}
}