diff options
author | Steven Knight <knight@baldmt.com> | 2003-05-09 22:07:35 (GMT) |
---|---|---|
committer | Steven Knight <knight@baldmt.com> | 2003-05-09 22:07:35 (GMT) |
commit | 8c7c96993d069298a66834db8bddb038725a6637 (patch) | |
tree | 656788d5ff27d9265809eae81a6c62dd3a82744e /src/engine/SCons/Tool/JavaCommonTests.py | |
parent | 3ff79698a1d206f9be1804376004777c6c7f7929 (diff) | |
download | SCons-8c7c96993d069298a66834db8bddb038725a6637.zip SCons-8c7c96993d069298a66834db8bddb038725a6637.tar.gz SCons-8c7c96993d069298a66834db8bddb038725a6637.tar.bz2 |
Java parser fix for // comments. (Charles Crain)
Diffstat (limited to 'src/engine/SCons/Tool/JavaCommonTests.py')
-rw-r--r-- | src/engine/SCons/Tool/JavaCommonTests.py | 46 |
1 files changed, 45 insertions, 1 deletions
diff --git a/src/engine/SCons/Tool/JavaCommonTests.py b/src/engine/SCons/Tool/JavaCommonTests.py index 96bd31d..1b5421c 100644 --- a/src/engine/SCons/Tool/JavaCommonTests.py +++ b/src/engine/SCons/Tool/JavaCommonTests.py @@ -23,13 +23,14 @@ __revision__ = "__FILE__ __REVISION__ __DATE__ __DEVELOPER__" +import sys import unittest import SCons.Tool.JavaCommon class parse_javaTestCase(unittest.TestCase): - def test_empty(self): + def test_bare_bones(self): """Test a bare-bones class""" pkg_dir, classes = SCons.Tool.JavaCommon.parse_java("""\ @@ -123,6 +124,49 @@ class Private { ] assert classes == expect, classes + def test_comments(self): + """Test a class with comments""" + + pkg_dir, classes = SCons.Tool.JavaCommon.parse_java("""\ +package com.sub.foo; + +import java.rmi.Naming; +import java.rmi.RemoteException; +import java.rmi.RMISecurityManager; +import java.rmi.server.UnicastRemoteObject; + +public class Example1 extends UnicastRemoteObject implements Hello { + + public Example1() throws RemoteException { + super(); + } + + public String sayHello() { + return "Hello World!"; + } + + public static void main(String args[]) { + if (System.getSecurityManager() == null) { + System.setSecurityManager(new RMISecurityManager()); + } + // a comment + try { + Example1 obj = new Example1(); + + Naming.rebind("//myhost/HelloServer", obj); + + System.out.println("HelloServer bound in registry"); + } catch (Exception e) { + System.out.println("Example1 err: " + e.getMessage()); + e.printStackTrace(); + } + } +} +""") + + assert pkg_dir == 'com/sub/foo', pkg_dir + assert classes == ['Example1'], classes + if __name__ == "__main__": suite = unittest.TestSuite() tclasses = [ parse_javaTestCase ] |