Eval4j: add ignore annotations for tests

This commit is contained in:
Natalia Ukhorskaya
2014-06-20 18:16:18 +04:00
parent fab770a346
commit c847d180a7
3 changed files with 44 additions and 9 deletions
@@ -0,0 +1,24 @@
/*
* Copyright 2010-2014 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.eval4j.test;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@Retention(RetentionPolicy.RUNTIME)
public @interface IgnoreInReflectionTests {
}
@@ -697,10 +697,12 @@ class TestData extends BaseTestData {
return "Derived"; return "Derived";
} }
@IgnoreInReflectionTests
String testInvokeSpecialForSuperCall() { String testInvokeSpecialForSuperCall() {
return super.superCall(); return super.superCall();
} }
@IgnoreInReflectionTests
static String testInvokeSpecial() { static String testInvokeSpecial() {
TestData td = new TestData(); TestData td = new TestData();
return td.invokeSpecialPrivateFun(""); return td.invokeSpecialPrivateFun("");
+10 -1
View File
@@ -36,6 +36,7 @@ fun suite(): TestSuite = buildTestSuite {
object : TestCase(getTestName(methodNode.name)) { object : TestCase(getTestName(methodNode.name)) {
override fun runTest() { override fun runTest() {
if (!isIgnored(methodNode)) {
val value = interpreterLoop( val value = interpreterLoop(
methodNode, methodNode,
initFrame( initFrame(
@@ -44,10 +45,18 @@ fun suite(): TestSuite = buildTestSuite {
), ),
REFLECTION_EVAL REFLECTION_EVAL
) )
assertEquals(expected, value) assertEquals(expected, value)
} }
} }
private fun isIgnored(methodNode: MethodNode): Boolean {
return methodNode.visibleAnnotations?.any {
val annotationDesc = it.desc
annotationDesc != null &&
Type.getType(annotationDesc) == Type.getType(javaClass<IgnoreInReflectionTests>())
} ?: false
}
}
} }
fun Class<*>.getInternalName(): String = Type.getType(this).getInternalName() fun Class<*>.getInternalName(): String = Type.getType(this).getInternalName()