Browse Source

170 language tests

tags/V1_7_0RC1
aclement 12 years ago
parent
commit
13475b2ce5

+ 14
- 0
tests/bugs170/language/Diamond.java View File

@@ -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<>();
}
}

+ 11
- 0
tests/bugs170/language/DiamondITD.java View File

@@ -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<>();
}

+ 13
- 0
tests/bugs170/language/Literals.java View File

@@ -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;
}

}

+ 11
- 0
tests/bugs170/language/LiteralsITD.java View File

@@ -0,0 +1,11 @@
public class LiteralsITD {
public static void main(String []argv) {
}
}

aspect Foo {
before(): execution(* *(..)) {
}

public int LiteralsITD.id = 0b100_000;
}

+ 31
- 0
tests/bugs170/language/MultiCatch.java View File

@@ -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 {
}


+ 37
- 0
tests/bugs170/language/MultiCatchWithHandler.java View File

@@ -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");
}
}

+ 37
- 0
tests/bugs170/language/MultiCatchWithHandler2.java View File

@@ -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");
}
}

+ 33
- 0
tests/bugs170/language/StringSwitch.java View File

@@ -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() {}

}

+ 15
- 0
tests/bugs170/language/TryResources.java View File

@@ -0,0 +1,15 @@
public class TryResources {
}

aspect Foo {
before(): execution(* *(..)) {
try (
InputStream in = new FileInputStream(src);
OutputStream out = new FileOutputStream(dest))
{
// code
}

}
}

+ 50
- 1
tests/src/org/aspectj/systemtest/ajc170/Ajc170Tests.java View File

@@ -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");
}

+ 65
- 0
tests/src/org/aspectj/systemtest/ajc170/ajc170.xml View File

@@ -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="'&lt;&gt;' 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>

Loading…
Cancel
Save