From 13475b2ce5f6ebdfd9656ca7a5b40c2d28d5c4d7 Mon Sep 17 00:00:00 2001 From: aclement Date: Thu, 15 Dec 2011 01:25:35 +0000 Subject: 170 language tests --- tests/bugs170/language/Diamond.java | 14 +++++ tests/bugs170/language/DiamondITD.java | 11 ++++ tests/bugs170/language/Literals.java | 13 +++++ tests/bugs170/language/LiteralsITD.java | 11 ++++ tests/bugs170/language/MultiCatch.java | 31 +++++++++++ tests/bugs170/language/MultiCatchWithHandler.java | 37 ++++++++++++ tests/bugs170/language/MultiCatchWithHandler2.java | 37 ++++++++++++ tests/bugs170/language/StringSwitch.java | 33 +++++++++++ tests/bugs170/language/TryResources.java | 15 +++++ .../org/aspectj/systemtest/ajc170/Ajc170Tests.java | 51 ++++++++++++++++- tests/src/org/aspectj/systemtest/ajc170/ajc170.xml | 65 ++++++++++++++++++++++ 11 files changed, 317 insertions(+), 1 deletion(-) create mode 100644 tests/bugs170/language/Diamond.java create mode 100644 tests/bugs170/language/DiamondITD.java create mode 100644 tests/bugs170/language/Literals.java create mode 100644 tests/bugs170/language/LiteralsITD.java create mode 100644 tests/bugs170/language/MultiCatch.java create mode 100644 tests/bugs170/language/MultiCatchWithHandler.java create mode 100644 tests/bugs170/language/MultiCatchWithHandler2.java create mode 100644 tests/bugs170/language/StringSwitch.java create mode 100644 tests/bugs170/language/TryResources.java diff --git a/tests/bugs170/language/Diamond.java b/tests/bugs170/language/Diamond.java new file mode 100644 index 000000000..2987ccad3 --- /dev/null +++ b/tests/bugs170/language/Diamond.java @@ -0,0 +1,14 @@ +import java.util.*; + +public class Diamond { + public static void main(String []argv) { + } +} + +aspect Foo { + before(): execution(* *(..)) { + // in advice + List ls = new ArrayList<>(); + } + +} diff --git a/tests/bugs170/language/DiamondITD.java b/tests/bugs170/language/DiamondITD.java new file mode 100644 index 000000000..a6acbe001 --- /dev/null +++ b/tests/bugs170/language/DiamondITD.java @@ -0,0 +1,11 @@ +import java.util.*; + +public class DiamondITD { + public static void main(String []argv) { + } +} + +aspect Foo { + + public List DiamondITD.ls = new ArrayList<>(); +} diff --git a/tests/bugs170/language/Literals.java b/tests/bugs170/language/Literals.java new file mode 100644 index 000000000..60a39a7c5 --- /dev/null +++ b/tests/bugs170/language/Literals.java @@ -0,0 +1,13 @@ +public class Literals { + public static void main(String []argv) { + } +} + +aspect Foo { + before(): execution(* *(..)) { + int onemill = 1_000_000; + int four =0b100; + } + + +} diff --git a/tests/bugs170/language/LiteralsITD.java b/tests/bugs170/language/LiteralsITD.java new file mode 100644 index 000000000..ea25d9d8a --- /dev/null +++ b/tests/bugs170/language/LiteralsITD.java @@ -0,0 +1,11 @@ +public class LiteralsITD { + public static void main(String []argv) { + } +} + +aspect Foo { + before(): execution(* *(..)) { + } + + public int LiteralsITD.id = 0b100_000; +} diff --git a/tests/bugs170/language/MultiCatch.java b/tests/bugs170/language/MultiCatch.java new file mode 100644 index 000000000..8beede752 --- /dev/null +++ b/tests/bugs170/language/MultiCatch.java @@ -0,0 +1,31 @@ +public class MultiCatch { + + public static void main(String[] args) { + try { + foo("abc"); + } catch (ExceptionA | ExceptionB ex) { + bar(ex); + } + } + + public static void bar(Exception ea) { + + } + + public static void foo(String s) throws ExceptionA, ExceptionB { + if (s.equals("ta")) { + throw new ExceptionA(); + } else { + throw new ExceptionB(); + } + } +} + +@SuppressWarnings("serial") +class ExceptionA extends Exception { +} + +@SuppressWarnings("serial") +class ExceptionB extends Exception { +} + diff --git a/tests/bugs170/language/MultiCatchWithHandler.java b/tests/bugs170/language/MultiCatchWithHandler.java new file mode 100644 index 000000000..bb0373f79 --- /dev/null +++ b/tests/bugs170/language/MultiCatchWithHandler.java @@ -0,0 +1,37 @@ +public class MultiCatchWithHandler { + + public static void main(String[] args) { + try { + foo("abc"); + } catch (ExceptionA | ExceptionB ex) { + bar(ex); + } + } + + public static void bar(Exception ea) { + + } + + public static void foo(String s) throws ExceptionA, ExceptionB { + if (s.equals("ta")) { + throw new ExceptionA(); + } else { + throw new ExceptionB(); + } + } +} + +@SuppressWarnings("serial") +class ExceptionA extends Exception { +} + +@SuppressWarnings("serial") +class ExceptionB extends Exception { +} + + +aspect X { + before(ExceptionA ea): handler(ExceptionA) && args(ea) { + System.out.println("in advice"); + } +} diff --git a/tests/bugs170/language/MultiCatchWithHandler2.java b/tests/bugs170/language/MultiCatchWithHandler2.java new file mode 100644 index 000000000..0a8f7a739 --- /dev/null +++ b/tests/bugs170/language/MultiCatchWithHandler2.java @@ -0,0 +1,37 @@ +public class MultiCatchWithHandler2 { + + public static void main(String[] args) { + try { + foo("ta"); + } catch (ExceptionA | ExceptionB ex) { + bar(ex); + } + } + + public static void bar(Exception ea) { + + } + + public static void foo(String s) throws ExceptionA, ExceptionB { + if (s.equals("ta")) { + throw new ExceptionA(); + } else { + throw new ExceptionB(); + } + } +} + +@SuppressWarnings("serial") +class ExceptionA extends Exception { +} + +@SuppressWarnings("serial") +class ExceptionB extends Exception { +} + + +aspect X { + before(ExceptionA ea): handler(ExceptionA) && args(ea) { + System.out.println("advice"); + } +} diff --git a/tests/bugs170/language/StringSwitch.java b/tests/bugs170/language/StringSwitch.java new file mode 100644 index 000000000..140d3b198 --- /dev/null +++ b/tests/bugs170/language/StringSwitch.java @@ -0,0 +1,33 @@ +public class StringSwitch { + public static void main(String []argv) { + } +} + +aspect Foo { + before(): execution(* *(..)) { +String s = "abc"; +switch(s) { + case "quux": + foo(); + // fall-through + + case "foo": + case "bar": + foo(); + break; + + case "baz": + foo(); + // fall-through + + default: + foo(); + break; +} + + } + + + public void foo() {} + +} diff --git a/tests/bugs170/language/TryResources.java b/tests/bugs170/language/TryResources.java new file mode 100644 index 000000000..308000445 --- /dev/null +++ b/tests/bugs170/language/TryResources.java @@ -0,0 +1,15 @@ +public class TryResources { +} + +aspect Foo { + before(): execution(* *(..)) { +try ( + InputStream in = new FileInputStream(src); + OutputStream out = new FileOutputStream(dest)) +{ + // code +} + + + } +} diff --git a/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java b/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java index a7374e2fa..e065a4716 100644 --- a/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java +++ b/tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java @@ -21,10 +21,59 @@ import org.aspectj.testing.XMLBasedAjcTestCase; */ public class Ajc170Tests extends org.aspectj.testing.XMLBasedAjcTestCase { + // not specifying -1.7 + public void testDiamond1() { + runTest("diamond 1"); + } + + public void testDiamond2() { + runTest("diamond 2"); + } + + public void testDiamondItd1() { + runTest("diamond itd 1"); + } + + public void testLiterals1() { + runTest("literals 1"); + } + + public void testLiterals2() { + runTest("literals 2"); + } + + public void testLiteralsItd1() { + runTest("literals itd 1"); + } + + public void testStringSwitch1() { + runTest("string switch 1"); + } + + public void testStringSwitch2() { + runTest("string switch 2"); + } + + public void testMultiCatch1() { + runTest("multi catch 1"); + } + + public void testMultiCatch2() { + runTest("multi catch 2"); + } + + public void testMultiCatchWithHandler1() { + runTest("multi catch with handler 1"); + } + + // public void testMultiCatchWithHandler2() { + // runTest("multi catch with handler 2"); + // } + public void testSanity1() { runTest("sanity 1"); } - + public void testMissingImpl_363979() { runTest("missing impl"); } diff --git a/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml b/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml index a0822caaf..2b775c154 100644 --- a/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml +++ b/tests/src/org/aspectj/systemtest/ajc170/ajc170.xml @@ -2,6 +2,71 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- cgit v1.2.3