From c847d180a71a54c7a7bdf94846e9d02a2d9be0d2 Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Fri, 20 Jun 2014 18:16:18 +0400 Subject: [PATCH] Eval4j: add ignore annotations for tests --- .../eval4j/test/IgnoreInReflectionTests.java | 24 +++++++++++++++++ .../org/jetbrains/eval4j/test/TestData.java | 2 ++ eval4j/test/org/jetbrains/eval4j/test/main.kt | 27 ++++++++++++------- 3 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 eval4j/test/org/jetbrains/eval4j/test/IgnoreInReflectionTests.java diff --git a/eval4j/test/org/jetbrains/eval4j/test/IgnoreInReflectionTests.java b/eval4j/test/org/jetbrains/eval4j/test/IgnoreInReflectionTests.java new file mode 100644 index 00000000000..f07142feff6 --- /dev/null +++ b/eval4j/test/org/jetbrains/eval4j/test/IgnoreInReflectionTests.java @@ -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 { +} diff --git a/eval4j/test/org/jetbrains/eval4j/test/TestData.java b/eval4j/test/org/jetbrains/eval4j/test/TestData.java index 00bcc84c8c3..f154809d09b 100644 --- a/eval4j/test/org/jetbrains/eval4j/test/TestData.java +++ b/eval4j/test/org/jetbrains/eval4j/test/TestData.java @@ -697,10 +697,12 @@ class TestData extends BaseTestData { return "Derived"; } + @IgnoreInReflectionTests String testInvokeSpecialForSuperCall() { return super.superCall(); } + @IgnoreInReflectionTests static String testInvokeSpecial() { TestData td = new TestData(); return td.invokeSpecialPrivateFun(""); diff --git a/eval4j/test/org/jetbrains/eval4j/test/main.kt b/eval4j/test/org/jetbrains/eval4j/test/main.kt index 56ff0890ec0..58138bb6d94 100644 --- a/eval4j/test/org/jetbrains/eval4j/test/main.kt +++ b/eval4j/test/org/jetbrains/eval4j/test/main.kt @@ -36,16 +36,25 @@ fun suite(): TestSuite = buildTestSuite { object : TestCase(getTestName(methodNode.name)) { override fun runTest() { - val value = interpreterLoop( - methodNode, - initFrame( - ownerClass.getInternalName(), - methodNode - ), - REFLECTION_EVAL - ) + if (!isIgnored(methodNode)) { + val value = interpreterLoop( + methodNode, + initFrame( + ownerClass.getInternalName(), + methodNode + ), + 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()) + } ?: false } } }