diff options
author | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
---|---|---|
committer | wisberg <wisberg> | 2002-12-16 18:51:06 +0000 |
commit | 144143c2970a1e874d74cdbd0f8c622d4282a3c3 (patch) | |
tree | b12383d3d9e76c7e1f25f7fbec83051ef17f81fb /tests/harness | |
parent | fafae443719b26159ab2d7dac1c9b46b5e00b671 (diff) | |
download | aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.tar.gz aspectj-144143c2970a1e874d74cdbd0f8c622d4282a3c3.zip |
initial version
Diffstat (limited to 'tests/harness')
-rw-r--r-- | tests/harness/ErrorTest.java | 9 | ||||
-rw-r--r-- | tests/harness/ErrorWarning.java | 22 | ||||
-rw-r--r-- | tests/harness/LenientTest.java | 11 | ||||
-rw-r--r-- | tests/harness/Messages.java | 16 | ||||
-rw-r--r-- | tests/harness/TestNoTester.java | 5 | ||||
-rw-r--r-- | tests/harness/TestTester.events | 2 | ||||
-rw-r--r-- | tests/harness/TestTester.java | 31 | ||||
-rw-r--r-- | tests/harness/TestTesterFail.java | 26 | ||||
-rw-r--r-- | tests/harness/TestTesterFile.java | 14 | ||||
-rw-r--r-- | tests/harness/TesterNotesFail.java | 10 | ||||
-rw-r--r-- | tests/harness/ajctest/Aspect.java | 11 | ||||
-rw-r--r-- | tests/harness/ajctest/CompilerError.java | 2 | ||||
-rw-r--r-- | tests/harness/ajctest/Driver.java | 21 | ||||
-rw-r--r-- | tests/harness/directTester.sh | 77 |
14 files changed, 257 insertions, 0 deletions
diff --git a/tests/harness/ErrorTest.java b/tests/harness/ErrorTest.java new file mode 100644 index 000000000..6adc5f891 --- /dev/null +++ b/tests/harness/ErrorTest.java @@ -0,0 +1,9 @@ + + +public class ErrorTest { + static Integer i() { return Integer.valueOf("0"); } + int i = i(); // CE 5 always + int j = i(); // CE 6 always +} + + diff --git a/tests/harness/ErrorWarning.java b/tests/harness/ErrorWarning.java new file mode 100644 index 000000000..0719f2993 --- /dev/null +++ b/tests/harness/ErrorWarning.java @@ -0,0 +1,22 @@ +import org.aspectj.testing.Tester; + +public class ErrorWarning { + public static void main (String[] args) { + boolean passed = true; + try { ok(); } + catch (Error e) { passed = false; } + Tester.check(passed, "did not catch error"); + } // end of main () + + public static void ok() { + try { + throw new Error();; // CE 13 unless -lenient + } catch(Error e) { } // CW 14 per aspect + } + static aspect A { + declare warning : withincode(void ErrorWarning.ok()) + && (handler(Error)) : "warning"; + } +} + + diff --git a/tests/harness/LenientTest.java b/tests/harness/LenientTest.java new file mode 100644 index 000000000..798f4439a --- /dev/null +++ b/tests/harness/LenientTest.java @@ -0,0 +1,11 @@ + +import org.aspectj.testing.Tester; + +public class LenientTest { + public void m() { + return;; // CE 6 in -lenient only + } + public static void main(String[] args) { + Tester.check(null != new LenientTest(), "no test"); + } +} diff --git a/tests/harness/Messages.java b/tests/harness/Messages.java new file mode 100644 index 000000000..22d034382 --- /dev/null +++ b/tests/harness/Messages.java @@ -0,0 +1,16 @@ + +public class Messages { + public static void main (String[] args) { + new C().run(); + } +} + +class C { + void run() { + } +} + +aspect A { + pointcut f() : receptions(void C.run()); // ME 14 + around() returns void : f() { } // ME 15 +} diff --git a/tests/harness/TestNoTester.java b/tests/harness/TestNoTester.java new file mode 100644 index 000000000..c411c1514 --- /dev/null +++ b/tests/harness/TestNoTester.java @@ -0,0 +1,5 @@ + +public class TestNoTester { + public static void main (String[] args) { + } +} diff --git a/tests/harness/TestTester.events b/tests/harness/TestTester.events new file mode 100644 index 000000000..41aa6a4a9 --- /dev/null +++ b/tests/harness/TestTester.events @@ -0,0 +1,2 @@ +event 1
+event 2
diff --git a/tests/harness/TestTester.java b/tests/harness/TestTester.java new file mode 100644 index 000000000..29c9d500b --- /dev/null +++ b/tests/harness/TestTester.java @@ -0,0 +1,31 @@ + +import org.aspectj.testing.Tester; + +public class TestTester { + public static void main (String[] args) { + Tester.event("1"); + Tester.note("note 1"); + Tester.note("note 2"); + int i = 1; + Tester.check("note " + (i++)); + Tester.check("note " + (i++), "second note failed"); + new TestTester().run(); + Tester.checkAllEvents(); // does this empty + // now check(String[]) + Tester.clear(); + Tester.event("one"); + Tester.event("two"); + Tester.checkEvents(new String[] { "one", "two"}); + } + static { + Tester.expectEvent("1"); + Tester.expectEvent("2"); + } + public void run() { + Tester.event("2"); + Tester.check(true, "no failure"); + Tester.checkEqual("1", "1", "no failure"); + Tester.checkEqual("1", "1"); + } + +} diff --git a/tests/harness/TestTesterFail.java b/tests/harness/TestTesterFail.java new file mode 100644 index 000000000..a2eb7ef64 --- /dev/null +++ b/tests/harness/TestTesterFail.java @@ -0,0 +1,26 @@ + +import org.aspectj.testing.Tester; +import org.aspectj.testing.Tester; + +public class TestTesterFail { + public static void main (String[] args) { + Tester.event("1"); + Tester.event("event 1"); + new TestTesterFail().run(); + Tester.checkAllEvents(); // does not include events + Tester.checkEventsFromFile("TestTester.events"); // should fail if FNF + } + static { + Tester.expectEvent("1"); + Tester.expectEvent("2"); // fail here - misentered below + Tester.expectEvent("3"); // fail here - expected but not found + } + public void run() { + Tester.event("2 "); // + Tester.event("event2"); // fail here - space + Tester.check(false, "failure"); // fail here - explicitly + Tester.checkEqual("1", "1 ", "failure"); // fail here - space + Tester.checkEqual("", "1"); // fail here + } + +} diff --git a/tests/harness/TestTesterFile.java b/tests/harness/TestTesterFile.java new file mode 100644 index 000000000..4e008d6b1 --- /dev/null +++ b/tests/harness/TestTesterFile.java @@ -0,0 +1,14 @@ + +import org.aspectj.testing.Tester; + +public class TestTesterFile { + public static void main (String[] args) { + Tester.event("event 1"); // in TestTester.events + new TestTesterFile().run(); + Tester.checkEventsFromFile("TestTester.events"); + } + public void run() { + Tester.event("event 2"); // in TestTester.events + } + +} diff --git a/tests/harness/TesterNotesFail.java b/tests/harness/TesterNotesFail.java new file mode 100644 index 000000000..61c8ace63 --- /dev/null +++ b/tests/harness/TesterNotesFail.java @@ -0,0 +1,10 @@ + +import org.aspectj.testing.Tester; + +/** @testcase fail when note not found */ +public class TesterNotesFail { + public static void main (String[] args) { + Tester.note("note "); + Tester.check("note"); // fail + } +} diff --git a/tests/harness/ajctest/Aspect.java b/tests/harness/ajctest/Aspect.java new file mode 100644 index 000000000..dddacf69a --- /dev/null +++ b/tests/harness/ajctest/Aspect.java @@ -0,0 +1,11 @@ + +import org.aspectj.lang.*; +import org.aspectj.lang.reflect.*; + +aspect Aspect { + before() : execution(public * (!java..*).*(..)) { + SourceLocation sl = thisJoinPointStaticPart.getSourceLocation(); + String s = thisJoinPoint + "@" + sl.getFileName() + ":" + sl.getLine(); + System.err.println(s); + } +} diff --git a/tests/harness/ajctest/CompilerError.java b/tests/harness/ajctest/CompilerError.java new file mode 100644 index 000000000..94c7ad210 --- /dev/null +++ b/tests/harness/ajctest/CompilerError.java @@ -0,0 +1,2 @@ + +compiler error diff --git a/tests/harness/ajctest/Driver.java b/tests/harness/ajctest/Driver.java new file mode 100644 index 000000000..dca23a717 --- /dev/null +++ b/tests/harness/ajctest/Driver.java @@ -0,0 +1,21 @@ + + +/** Drive normal, system.exit, error or exception result from main */ +public class Driver { + + /** + * @param args {[-exit <number>|[-error|-exception] <string>]} + */ + public static void main (String[] args) throws Exception { + for (int i = 0; i < args.length; i++) { + String arg = args[i]; + if ("-exit".equals(arg)) { + System.exit(Integer.valueOf(args[i+1]).intValue()); + } else if ("-error".equals(arg)) { + throw new Error(args[i+1]); + } else if ("-exception".equals(arg)) { + throw new RuntimeException(args[i+1]); + } + } + } +} diff --git a/tests/harness/directTester.sh b/tests/harness/directTester.sh new file mode 100644 index 000000000..5315ceae6 --- /dev/null +++ b/tests/harness/directTester.sh @@ -0,0 +1,77 @@ +#!/bin/sh
+# syntax: <mainFile> {file}...
+# info: compile files and run mainFile class (with Tester classes)
+# requires JDKDIR and build output be available
+
+[ -n "$DEBUG" ] && set -vx
+pathtojava() {
+ echo "$1" | sed 's|/cygdrive/\(c\)/|\1:/|' # todo
+}
+errMssg() {
+ echo "## $0 Error: $1"
+ if [ -n "$2" ] ; then exit "$2" ; fi
+}
+
+sourcesRunningInNew() {
+ cat<<EOF
+InnerInterfaceNames.java
+InnerInterfaceAccess.java
+PR691.java
+AroundDoubleAssignment.java
+AroundDoubleAssignmentC.java
+AroundChangeThis.java
+PointcutQualification.java
+PointcutQualification2.java
+AbstractPointcutAccess.java
+SourceLocationCall.java
+CallNotTarget.java
+AroundCall.java
+ArgsInCflow2.java
+FactorialCflow.java
+ArrayInc.java
+TargetObjectReplacement.java
+EOF
+}
+
+runAjc() {
+ "$JDKDIR/bin/java" -classpath "$compilerJar" org.aspectj.tools.ajc.Main \
+ -d "$classesDir" -classpath "$rtJar${PS}$clientJar" "${@}"
+}
+runJava() {
+ "$JDKDIR/bin/java" -classpath "$rtJar${PS}$clientJar${PS}$classesDir" "${@}"
+}
+
+if [ -n "$PS" ] ; then
+ case `uname` in
+ CYGWIN* ) PS=";" ;;
+ * ) PS=":" ;;
+ esac
+fi
+
+scriptDir=`dirname "$0"`
+scriptDir=`cd "$scriptDir"; pwd`
+java="$JDKDIR/bin/java"
+[ -x "$java" ] || errMssg "no java=$java"
+ajJarsDir=`cd "$scriptDir/../../../aj-build-modules/jars"; pwd`
+ajJarsDirJ=`pathtojava "$ajJarsDir"`
+
+clientJar="$ajJarsDirJ/testing-client.jar"
+compilerJar="${compilerJar:-ajJarsDirJ/alltesting.jar}"
+rtJar="$ajJarsDirJ/runtime.jar"
+classesDir=cl
+[ -f "$clientJar" ] || errMssg "no clientJar=$clientJar" 4
+[ -f "$rtJar" ] || errMssg "no rtJar=$rtJar" 4
+
+cd "$scriptDir/../new" || errMssg "no new directory" 4
+mkdir "$classesDir"
+sources="${@:-`sourcesRunningInNew`}"
+for srcFile in $sources ; do
+ [ -f "$srcFile" ] || errMssg "no srcFile=$srcFile" 4
+ className=`echo "$srcFile" | sed 's|\/|.|g;s|\.java||'`
+ [ -n "$className" ] || errMssg "no className" 4
+ rm -rf "$classesDir"/*
+ runAjc "${srcFile}"
+ runJava $className || echo '<<<< FAIL '"$srcFile"
+done
+rm -rf "$classesDir"
+
|