fix for multiple evaluation of expression on multi var declaration

This commit is contained in:
Alex Tkachman
2012-08-31 11:45:56 +03:00
parent dd3323cae2
commit bf892870e1
4 changed files with 79 additions and 6 deletions
@@ -0,0 +1,37 @@
/*
* 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.ConfigurationKind;
/**
* This test is separate from MultiDeclTestGenerated because we specifically test generated bytecode
* that expression does not evaluated several time
*/
public class ComponentGenTest extends CodegenTestCase {
public void testComponent() {
createEnvironmentWithMockJdkAndIdeaAnnotations(ConfigurationKind.JDK_ONLY);
blackBoxFile("/multiDecl/component.kt");
String asm = generateToText();
//System.out.println(asm);
final String pattern = "NEW S\n";
final int index = asm.indexOf(pattern);
asm = asm.substring(index + pattern.length());
assertEquals(-1, asm.indexOf(pattern));
}
}
@@ -13,17 +13,15 @@
* 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;
import java.io.File;
/** This class is generated by {@link org.jetbrains.jet.codegen.AbstractMultiDeclTestCase}. DO NOT MODIFY MANUALLY */
@TestMetadata("compiler/testData/codegen/multiDecl")
@@ -37,6 +35,11 @@ public class MultiDeclTestGenerated extends AbstractMultiDeclTestCase {
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/ComplexInitializer.kt");
}
@TestMetadata("component.kt")
public void testComponent() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/component.kt");
}
@TestMetadata("SimpleVals.kt")
public void testSimpleVals() throws Exception {
blackBoxFileByFullPath("compiler/testData/codegen/multiDecl/SimpleVals.kt");