From 7bdec4ffc724ef6730143be200df32ec189ba8a5 Mon Sep 17 00:00:00 2001 From: "Egor.Ushakov" Date: Fri, 14 Oct 2016 18:29:00 +0300 Subject: [PATCH] decompiler: a test for the pull request #394 --- .../java/decompiler/SingleClassesTest.java | 1 + testData/classes/pkg/TestAsserts.class | Bin 0 -> 557 bytes testData/results/TestAsserts.dec | 34 ++++++++++++++++++ testData/src/pkg/TestAsserts.java | 26 ++++++++++++++ 4 files changed, 61 insertions(+) create mode 100644 testData/classes/pkg/TestAsserts.class create mode 100644 testData/results/TestAsserts.dec create mode 100644 testData/src/pkg/TestAsserts.java diff --git a/test/org/jetbrains/java/decompiler/SingleClassesTest.java b/test/org/jetbrains/java/decompiler/SingleClassesTest.java index 48e8b7d..ac0e891 100644 --- a/test/org/jetbrains/java/decompiler/SingleClassesTest.java +++ b/test/org/jetbrains/java/decompiler/SingleClassesTest.java @@ -90,6 +90,7 @@ public class SingleClassesTest { @Test public void testSyntheticAccess() { doTest("pkg/TestSyntheticAccess"); } @Test public void testIllegalVarName() { doTest("pkg/TestIllegalVarName"); } @Test public void testKotlinConstructor() { doTest("pkg/TestKotlinConstructorKt"); } + @Test public void testAsserts() { doTest("pkg/TestAsserts"); } private void doTest(String testFile, String... companionFiles) { ConsoleDecompiler decompiler = fixture.getDecompiler(); diff --git a/testData/classes/pkg/TestAsserts.class b/testData/classes/pkg/TestAsserts.class new file mode 100644 index 0000000000000000000000000000000000000000..1c42d7ea7b76a8ad9cbc3fd852ddafcd8f0572ff GIT binary patch literal 557 zcmYjOO-sW-5Ph3$n;4_5t*JFyLGYl0=Hg8e#SaktI4FX>rR^%QH7QBzkMSl7Uc9KF zprChulZdn1YQ4pOrYOj$56I)Dru10@SOMh%QvC}Z4!%TS#0lSIU6 z5QWKRkodKhXfUuULv|$ygLIWapPf5q;2TjxFywZFQ0#XuY9c<8WGbIVks|Fd3>~I^ zy}9SNdo^>V-s-7Xhfyc4i|s)6uB*Yx;<_HMSL@}$tA~g&nN4cc>&=l(NiX8U~CMGSA3f c!Qgk``V%zivMc!OQi^1t*=ur_f+`n(05yVU4FCWD literal 0 HcmV?d00001 diff --git a/testData/results/TestAsserts.dec b/testData/results/TestAsserts.dec new file mode 100644 index 0000000..f260d9e --- /dev/null +++ b/testData/results/TestAsserts.dec @@ -0,0 +1,34 @@ +package pkg; + +public class TestAsserts { + public static int foo() { + byte var0 = 1;// 21 + + assert var0 > 1;// 22 + + assert var0 > 1 && var0 < 5;// 23 + + return 1;// 24 + } +} + +class 'pkg/TestAsserts' { + method 'foo ()I' { + 0 4 + 1 4 + 9 6 + a 6 + 1c 8 + 1d 8 + 21 8 + 22 8 + 2d 10 + 2e 10 + } +} + +Lines mapping: +21 <-> 5 +22 <-> 7 +23 <-> 9 +24 <-> 11 diff --git a/testData/src/pkg/TestAsserts.java b/testData/src/pkg/TestAsserts.java new file mode 100644 index 0000000..29c7480 --- /dev/null +++ b/testData/src/pkg/TestAsserts.java @@ -0,0 +1,26 @@ +/* + * Copyright 2000-2016 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 pkg; + + +public class TestAsserts { + public static int foo() { + int i=1; + assert i > 1; + assert i> 1 && i < 5; + return 1; + } +}