diff options
author | aclement <aclement> | 2011-12-15 01:25:35 +0000 |
---|---|---|
committer | aclement <aclement> | 2011-12-15 01:25:35 +0000 |
commit | 13475b2ce5f6ebdfd9656ca7a5b40c2d28d5c4d7 (patch) | |
tree | 07584131d2d34c33e6c302b59a838014bc04d644 | |
parent | 3bffe3bda11e8cb06e4e32d5137825547b860ad7 (diff) | |
download | aspectj-13475b2ce5f6ebdfd9656ca7a5b40c2d28d5c4d7.tar.gz aspectj-13475b2ce5f6ebdfd9656ca7a5b40c2d28d5c4d7.zip |
170 language tests
-rw-r--r-- | tests/bugs170/language/Diamond.java | 14 | ||||
-rw-r--r-- | tests/bugs170/language/DiamondITD.java | 11 | ||||
-rw-r--r-- | tests/bugs170/language/Literals.java | 13 | ||||
-rw-r--r-- | tests/bugs170/language/LiteralsITD.java | 11 | ||||
-rw-r--r-- | tests/bugs170/language/MultiCatch.java | 31 | ||||
-rw-r--r-- | tests/bugs170/language/MultiCatchWithHandler.java | 37 | ||||
-rw-r--r-- | tests/bugs170/language/MultiCatchWithHandler2.java | 37 | ||||
-rw-r--r-- | tests/bugs170/language/StringSwitch.java | 33 | ||||
-rw-r--r-- | tests/bugs170/language/TryResources.java | 15 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java | 51 | ||||
-rw-r--r-- | tests/src/org/aspectj/systemtest/ajc170/ajc170.xml | 65 |
11 files changed, 317 insertions, 1 deletions
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<String> 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<String> 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 @@ <suite> + <ajc-test dir="bugs170/language" title="diamond 1"> + <compile files="Diamond.java" options="-1.5"> + <message kind="error" line="11" text="'<>' operator is not allowed for source level below 1.7"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs170/language" title="diamond 2"> + <compile files="Diamond.java" options="-1.7"> + </compile> + </ajc-test> + + <ajc-test dir="bugs170/language" title="diamond itd 1"> + <compile files="DiamondITD.java" options="-1.7"> + </compile> + </ajc-test> + + <ajc-test dir="bugs170/language" title="literals 1"> + <compile files="Literals.java" options="-1.5"> + <message kind="error" line="8" text="Underscores can only be used with source level 1.7 or greater"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs170/language" title="literals 2"> + <compile files="Literals.java" options="-1.7"> + </compile> + </ajc-test> + + <ajc-test dir="bugs170/language" title="literals itd 1"> + <compile files="LiteralsITD.java" options="-1.7"> + </compile> + </ajc-test> + + <ajc-test dir="bugs170/language" title="string switch 1"> + <compile files="StringSwitch.java" options="-1.5"> + <message kind="error" line="9" text="Cannot switch on a value of type String for source level below 1.7. Only convertible int values or enum constants are permitted"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs170/language" title="string switch 2"> + <compile files="StringSwitch.java" options="-1.7"> + </compile> + </ajc-test> + + <ajc-test dir="bugs170/language" title="multi catch 1"> + <compile files="MultiCatch.java" options="-1.5"> + <message kind="error" line="6" text="Multi-catch parameters are not allowed for source level below 1.7"/> + </compile> + </ajc-test> + + <ajc-test dir="bugs170/language" title="multi catch 2"> + <compile files="MultiCatch.java" options="-1.7"> + </compile> + </ajc-test> + + <ajc-test dir="bugs170/language" title="multi catch with handler 1"> + <compile files="MultiCatchWithHandler.java" options="-1.7"> + </compile> + </ajc-test> + + <ajc-test dir="bugs170/language" title="multi catch with handler 2"> + <compile files="MultiCatchWithHandler2.java" options="-1.7"> + </compile> + <run class="MultiCatchWithHandler2"></run> + </ajc-test> + <ajc-test dir="bugs170/sanity" title="sanity 1"> <compile files="DeclareAtType.java" options="-1.5"> </compile> |