summaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorSteven Knight <knight@baldmt.com>2003-04-16 06:20:26 (GMT)
committerSteven Knight <knight@baldmt.com>2003-04-16 06:20:26 (GMT)
commit5be86ed2d7fb824f775ca5159b93f045ac8cb56d (patch)
tree52e69d55e83393752a988e42dc2a2db0f268d101 /test
parent9de8ce86148b2b041ee81c62a1b2fe08bd1e7473 (diff)
downloadSCons-5be86ed2d7fb824f775ca5159b93f045ac8cb56d.zip
SCons-5be86ed2d7fb824f775ca5159b93f045ac8cb56d.tar.gz
SCons-5be86ed2d7fb824f775ca5159b93f045ac8cb56d.tar.bz2
Really parse .java files for inner class names. (Charles Crain)
Diffstat (limited to 'test')
-rw-r--r--test/JAVAC.py77
1 files changed, 75 insertions, 2 deletions
diff --git a/test/JAVAC.py b/test/JAVAC.py
index f2910a4..1651be0 100644
--- a/test/JAVAC.py
+++ b/test/JAVAC.py
@@ -111,11 +111,14 @@ javac = foo.Dictionary('JAVAC')
bar = foo.Copy(JAVAC = r'%s wrapper.py ' + javac)
foo.Java(target = 'classes', source = 'com/sub/foo')
bar.Java(target = 'classes', source = 'com/sub/bar')
+foo.Java(target = 'classes', source = 'src')
""" % python)
-test.subdir('com', ['com', 'sub'],
+test.subdir('com',
+ ['com', 'sub'],
['com', 'sub', 'foo'],
- ['com', 'sub', 'bar'])
+ ['com', 'sub', 'bar'],
+ 'src')
test.write(['com', 'sub', 'foo', 'Example1.java'], """\
package com.sub.foo;
@@ -201,6 +204,65 @@ public class Example6
}
""")
+# Acid-test file for parsing inner Java classes, courtesy Chad Austin.
+test.write(['src', 'Test.java'], """\
+class Empty {
+}
+
+interface Listener {
+ public void execute();
+}
+
+public
+class
+Test {
+ class Inner {
+ void go() {
+ use(new Listener() {
+ public void execute() {
+ System.out.println("In Inner");
+ }
+ });
+ }
+ String s1 = "class A";
+ String s2 = "new Listener() { }";
+ /* class B */
+ /* new Listener() { } */
+ }
+
+ public static void main(String[] args) {
+ new Test().run();
+ }
+
+ void run() {
+ use(new Listener() {
+ public void execute() {
+ use(new Listener( ) {
+ public void execute() {
+ System.out.println("Inside execute()");
+ }
+ });
+ }
+ });
+
+ new Inner().go();
+ }
+
+ void use(Listener l) {
+ l.execute();
+ }
+}
+
+class Private {
+ void run() {
+ new Listener() {
+ public void execute() {
+ }
+ };
+ }
+}
+""")
+
test.run(arguments = '.')
test.fail_test(test.read('wrapper.out') != "wrapper.py /usr/local/j2sdk1.3.1/bin/javac -d classes -sourcepath com/sub/bar com/sub/bar/Example4.java com/sub/bar/Example5.java com/sub/bar/Example6.java\n")
@@ -208,10 +270,21 @@ test.fail_test(test.read('wrapper.out') != "wrapper.py /usr/local/j2sdk1.3.1/bin
test.fail_test(not os.path.exists(test.workpath('classes', 'com', 'sub', 'foo', 'Example1.class')))
test.fail_test(not os.path.exists(test.workpath('classes', 'com', 'other', 'Example2.class')))
test.fail_test(not os.path.exists(test.workpath('classes', 'com', 'sub', 'foo', 'Example3.class')))
+
test.fail_test(not os.path.exists(test.workpath('classes', 'com', 'sub', 'bar', 'Example4.class')))
test.fail_test(not os.path.exists(test.workpath('classes', 'com', 'other', 'Example5.class')))
test.fail_test(not os.path.exists(test.workpath('classes', 'com', 'sub', 'bar', 'Example6.class')))
+test.fail_test(not os.path.exists(test.workpath('classes', 'Empty.class')))
+test.fail_test(not os.path.exists(test.workpath('classes', 'Listener.class')))
+test.fail_test(not os.path.exists(test.workpath('classes', 'Private.class')))
+test.fail_test(not os.path.exists(test.workpath('classes', 'Private$1.class')))
+test.fail_test(not os.path.exists(test.workpath('classes', 'Test.class')))
+test.fail_test(not os.path.exists(test.workpath('classes', 'Test$1.class')))
+test.fail_test(not os.path.exists(test.workpath('classes', 'Test$2.class')))
+test.fail_test(not os.path.exists(test.workpath('classes', 'Test$3.class')))
+test.fail_test(not os.path.exists(test.workpath('classes', 'Test$Inner.class')))
+
test.up_to_date(arguments = '.')
test.pass_test()