From 144143c2970a1e874d74cdbd0f8c622d4282a3c3 Mon Sep 17 00:00:00 2001 From: wisberg Date: Mon, 16 Dec 2002 18:51:06 +0000 Subject: initial version --- tests/harness/ErrorTest.java | 9 ++++ tests/harness/ErrorWarning.java | 22 +++++++++ tests/harness/LenientTest.java | 11 +++++ tests/harness/Messages.java | 16 +++++++ tests/harness/TestNoTester.java | 5 +++ tests/harness/TestTester.events | 2 + tests/harness/TestTester.java | 31 +++++++++++++ tests/harness/TestTesterFail.java | 26 +++++++++++ tests/harness/TestTesterFile.java | 14 ++++++ tests/harness/TesterNotesFail.java | 10 +++++ tests/harness/ajctest/Aspect.java | 11 +++++ tests/harness/ajctest/CompilerError.java | 2 + tests/harness/ajctest/Driver.java | 21 +++++++++ tests/harness/directTester.sh | 77 ++++++++++++++++++++++++++++++++ 14 files changed, 257 insertions(+) create mode 100644 tests/harness/ErrorTest.java create mode 100644 tests/harness/ErrorWarning.java create mode 100644 tests/harness/LenientTest.java create mode 100644 tests/harness/Messages.java create mode 100644 tests/harness/TestNoTester.java create mode 100644 tests/harness/TestTester.events create mode 100644 tests/harness/TestTester.java create mode 100644 tests/harness/TestTesterFail.java create mode 100644 tests/harness/TestTesterFile.java create mode 100644 tests/harness/TesterNotesFail.java create mode 100644 tests/harness/ajctest/Aspect.java create mode 100644 tests/harness/ajctest/CompilerError.java create mode 100644 tests/harness/ajctest/Driver.java create mode 100644 tests/harness/directTester.sh (limited to 'tests/harness') 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 |[-error|-exception] ]} + */ + 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: {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<