xmlbeans-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From p...@apache.org
Subject cvs commit: xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam GoldenInvokable.java JamTestBase.java GoldenMethod.java
Date Tue, 02 Mar 2004 22:03:04 GMT
pcal        2004/03/02 14:03:04

  Modified:    v2       build.xml
               v2/src/jam java.g
               v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl
                        EClassImpl.java EElementImpl.java
                        EInvokableImpl.java EMemberImpl.java
                        EParameterImpl.java
               v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/ref
                        UnqualifiedJClassRef.java
               v2/test/src/jamtest build.xml
               v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam
                        JamTestBase.java
  Added:       v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam
                        GoldenInvokable.java
  Removed:     v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam
                        GoldenMethod.java
  Log:
  jam: fix equals on eclass
  
  Revision  Changes    Path
  1.44      +1 -0      xml-xmlbeans/v2/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/build.xml,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- build.xml	2 Mar 2004 16:50:54 -0000	1.43
  +++ build.xml	2 Mar 2004 22:03:04 -0000	1.44
  @@ -790,6 +790,7 @@
   
     <target name='jam.clean'>
       <delete dir='build/classes/jam'/>
  +    <delete dir='build/generatedsrc'/>
     </target>
   
     <target name="jam.parser.check">
  
  
  
  1.6       +15 -5     xml-xmlbeans/v2/src/jam/java.g
  
  Index: java.g
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/java.g,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- java.g	2 Mar 2004 04:26:17 -0000	1.5
  +++ java.g	2 Mar 2004 22:03:04 -0000	1.6
  @@ -164,7 +164,7 @@
     // ========================================================================
     // Constants
   
  -  private static final boolean VERBOSE = true;
  +  private static final boolean VERBOSE = false;
   
     // ========================================================================
     // Variables
  @@ -346,7 +346,10 @@
   
   
   constructor[EClass clazz, int modifiers, String name]
  -  : (LPAREN (parameterList[mParamList])? RPAREN (throwsClause[mExceptionList])? statement_block)
  +{
  +  List params = new ArrayList(); //FIXME try reuse this please
  +}
  +  : (LPAREN (parameterList[params])? RPAREN (throwsClause[mExceptionList])? statement_block)
   {
     if (!name.equals(clazz.getSimpleName())) {
       throw new IllegalArgumentException("FIXME not a constructor '"+
  @@ -354,7 +357,8 @@
     }
     EConstructorImpl constr = (EConstructorImpl)clazz.addNewConstructor();
     constr.setModifiers(modifiers);
  -  constr.setParameters(mParamList);
  +  System.out.println("============== Setting params "+params.size());
  +  constr.setParameters(params);
     constr.setUnqualifiedThrows(mExceptionList);
     applyJavadocs(constr);
   
  @@ -379,12 +383,15 @@
   	  )
   	  |
   	  (
  -      (LPAREN (parameterList[mParamList])? RPAREN tweener (throwsClause[mExceptionList])?
(statement_block | SEMI)) {
  +	  { List params = new ArrayList();  //FIXME can we reuse this please?
  +	  }
  +      (LPAREN (parameterList[params])? RPAREN tweener (throwsClause[mExceptionList])? (statement_block
| SEMI)) {
           if (VERBOSE) System.out.println("creating method "+name);
           EMethodImpl method = (EMethodImpl)clazz.addNewMethod();
           method.setSimpleName(name);
           method.setUnqualifiedReturnType(type);
           method.setModifiers(modifiers);
  +        System.out.println("============== Setting params "+params.size());
           method.setParameters(mParamList);
           method.setUnqualifiedThrows(mExceptionList);
           applyJavadocs(method);
  @@ -418,7 +425,7 @@
   
   
   // A list of formal parameters
  -parameterList[Collection list] { list.clear(); }
  +parameterList[Collection list] {}
   	:	(parameter[list] (COMMA parameter[list])*)
   ;
   
  @@ -429,10 +436,13 @@
     String name;
   }
   : tweener ("final")? t:IDENT tweener n:IDENT tweener {
  +
     EParameterImpl param = new EParameterImpl();
     param.setUnqualifiedType(t.getText());
     param.setSimpleName(n.getText());
     list.add(param);
  +  System.out.println("\n\n\nadded to list!! "+list.size()+"\n\n\n");
  +
   }
   ;
   
  
  
  
  1.6       +2 -2      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EClassImpl.java
  
  Index: EClassImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EClassImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- EClassImpl.java	2 Mar 2004 04:26:18 -0000	1.5
  +++ EClassImpl.java	2 Mar 2004 22:03:04 -0000	1.6
  @@ -144,7 +144,7 @@
   
     public boolean isAssignableFrom(JClass arg) {
       if (isPrimitive() || arg.isPrimitive()) {
  -      return this.equals(arg);
  +      return getQualifiedName().equals(arg.getQualifiedName());
       }
       return isAssignableFromRecursively(arg);
     }
  @@ -381,7 +381,7 @@
     // Private methods
   
     private boolean isAssignableFromRecursively(JClass arg) {
  -    if (this.equals(arg)) return true;
  +    if (this.getQualifiedName().equals(arg.getQualifiedName())) return true;
       // check all of arg's implemented interfaces, recursively
       JClass[] interfaces = arg.getInterfaces();
       if (interfaces != null) {
  
  
  
  1.6       +16 -0     xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EElementImpl.java
  
  Index: EElementImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EElementImpl.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- EElementImpl.java	2 Mar 2004 04:26:18 -0000	1.5
  +++ EElementImpl.java	2 Mar 2004 22:03:04 -0000	1.6
  @@ -138,5 +138,21 @@
       return "unnamed_"+count;
     }
   
  +  public boolean equals(Object o) {
  +    if (this == o) return true;
  +    if (!(o instanceof EElementImpl)) return false;
  +    final EElementImpl eElement = (EElementImpl) o;
  +    String qn = getQualifiedName();
  +    if (qn == null) return false;
  +    String oqn = eElement.getQualifiedName();
  +    if (oqn == null) return false;
  +    return qn.equals(oqn);
  +  }
  +
  +  public int hashCode() {
  +    String qn = getQualifiedName();
  +    return (qn == null) ? 0 : qn.hashCode();
  +  }
  +
   
   }
  
  
  
  1.4       +1 -0      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EInvokableImpl.java
  
  Index: EInvokableImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EInvokableImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EInvokableImpl.java	2 Mar 2004 20:21:53 -0000	1.3
  +++ EInvokableImpl.java	2 Mar 2004 22:03:04 -0000	1.4
  @@ -153,6 +153,7 @@
      * EParameterImpls.
      */
     public void setParameters(List paramList) {
  +    System.out.println("\n\n\n\nSET PARAMETER LIST "+paramList.size());
       if (paramList == null || paramList.size() == 0) {
         mParameters = null;
         return;
  
  
  
  1.4       +1 -0      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EMemberImpl.java
  
  Index: EMemberImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EMemberImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EMemberImpl.java	25 Feb 2004 18:56:49 -0000	1.3
  +++ EMemberImpl.java	2 Mar 2004 22:03:04 -0000	1.4
  @@ -95,6 +95,7 @@
     // Package methods
   
     /*package*/ void setContainingClass(EClassImpl c) {
  +    if (c == null) throw new IllegalArgumentException("null class");
       mContainingClass = c;
     }
   
  
  
  
  1.4       +2 -0      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EParameterImpl.java
  
  Index: EParameterImpl.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/EParameterImpl.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- EParameterImpl.java	25 Feb 2004 18:56:49 -0000	1.3
  +++ EParameterImpl.java	2 Mar 2004 22:03:04 -0000	1.4
  @@ -37,6 +37,7 @@
     // ========================================================================
     // Constructors
   
  +  // be careful with this one, should really only be used by the parser
     public EParameterImpl() {}
   
     public EParameterImpl(String simpleName,
  @@ -85,6 +86,7 @@
     // Package methods
   
     /*package*/ void setContainingMember(EMemberImpl member) {
  +    System.out.println("\n\n\n\nSSET CONTAINING MEMBER "+member);
       super.setContainingClass((EClassImpl)member.getContainingClass());
     }
   }
  
  
  
  1.3       +5 -3      xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/ref/UnqualifiedJClassRef.java
  
  Index: UnqualifiedJClassRef.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/src/jam/org/apache/xmlbeans/impl/jam/editable/impl/ref/UnqualifiedJClassRef.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- UnqualifiedJClassRef.java	2 Mar 2004 04:26:18 -0000	1.2
  +++ UnqualifiedJClassRef.java	2 Mar 2004 22:03:04 -0000	1.3
  @@ -48,12 +48,14 @@
     // ========================================================================
     // Constructors
   
  -  private UnqualifiedJClassRef(String unqualifiedClassname,
  +  private UnqualifiedJClassRef(String ucname,
                                  JClassRefContext ctx)
     {
  +    if (ctx == null) throw new IllegalArgumentException("null ctx");
  +    if (ucname == null) throw new IllegalArgumentException("null ucname");
       mContext = ctx;
  -    mUnqualifiedClassname = unqualifiedClassname;
  -    if (VERBOSE) System.out.println("[UnqualifiedJClassRef] "+unqualifiedClassname);
  +    mUnqualifiedClassname = ucname;
  +    if (VERBOSE) System.out.println("[UnqualifiedJClassRef] "+ucname);
     }
   
     // ========================================================================
  
  
  
  1.7       +5 -6      xml-xmlbeans/v2/test/src/jamtest/build.xml
  
  Index: build.xml
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/jamtest/build.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- build.xml	2 Mar 2004 06:32:13 -0000	1.6
  +++ build.xml	2 Mar 2004 22:03:04 -0000	1.7
  @@ -10,10 +10,8 @@
   
     <path id='classpath' >
   
  - <!-- prefer build/classes to jar just for develpment convenience -->
  -    <pathelement path='../../../build/classes' />
  -
  -    <pathelement path='../../../build/lib/xbean.jar' />
  + <!-- use build/classes instead of xbean.jar for develpment convenience -->
  +    <pathelement path='../../../build/classes/jam' />
       <pathelement location='${build-dir}' />
       <pathelement location='${junit-jar}'/>
       <pathelement path='${java.class.path}' />
  @@ -58,9 +56,10 @@
           <pathelement path='${classpath-value}'/> <!--ref no workie-->
         </classpath>
         <formatter type='plain' usefile='false'/>
  -<!--
  +
  +      <!--
         <test name='org.apache.xmlbeans.test.jam.ParserJamTest'/>
  --->
  +      -->
         <test name='org.apache.xmlbeans.test.jam.SourcesJamTest'/>
         <test name='org.apache.xmlbeans.test.jam.ClassesJamTest'/>
   
  
  
  
  1.7       +2 -2      xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/JamTestBase.java
  
  Index: JamTestBase.java
  ===================================================================
  RCS file: /home/cvs/xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/JamTestBase.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- JamTestBase.java	2 Mar 2004 20:21:53 -0000	1.6
  +++ JamTestBase.java	2 Mar 2004 22:03:04 -0000	1.7
  @@ -212,8 +212,8 @@
      */
     public void testFooImplMethods() {
       JClass fooImpl = resolved(mLoader.loadClass(DUMMY+".FooImpl"));
  -    GoldenMethod[] methods = GoldenMethod.createArray(FOOIMPL_METHODS);
  -    GoldenMethod.doComparison(fooImpl.getDeclaredMethods(),
  +    GoldenInvokable[] methods = GoldenInvokable.createArray(FOOIMPL_METHODS);
  +    GoldenInvokable.doComparison(fooImpl.getDeclaredMethods(),
                                 methods,isParameterNamesKnown(),this);
     }
   
  
  
  
  1.1                  xml-xmlbeans/v2/test/src/jamtest/tests/org/apache/xmlbeans/test/jam/GoldenInvokable.java
  
  Index: GoldenInvokable.java
  ===================================================================
  /*   Copyright 2004 The Apache Software Foundation
   *
   *   Licensed under the Apache License, Version 2.0 (the "License");
   *   you may not use this file except in compliance with the License.
   *   You may obtain a copy of the License at
   *
   *       http://www.apache.org/licenses/LICENSE-2.0
   *
   *   Unless required by applicable law or agreed to in writing, software
   *   distributed under the License is distributed on an "AS IS" BASIS,
   *   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   *   See the License for the specific language governing permissions and
   *  limitations under the License.
   */
  package org.apache.xmlbeans.test.jam;
  
  import org.apache.xmlbeans.impl.jam.*;
  
  import java.util.StringTokenizer;
  
  import junit.framework.Assert;
  
  /**
   * Independent test structure representing a method.  Can be compared
   * to a JMethod.
   *
   * @author Patrick Calahan <pcal@bea.com>
   */
  public class GoldenInvokable {
  
    // ========================================================================
    // Factory methods/static utils
  
    public static GoldenInvokable[] createArray(String[][] params) {
      GoldenInvokable[] out = new GoldenInvokable[params.length];
      for(int i=0; i<out.length; i++) {
        out[i] = new GoldenInvokable(params[i]);
      }
      return out;
    }
  
    public static void doComparison(JMethod[] result,
                                    GoldenInvokable[] expected,
                                    boolean compareParamNames,
                                    Assert a) {
      a.assertTrue("different number of methods ["+
                   result.length+","+expected.length+"]",
                   result.length == expected.length);
      for(int i=0; i<result.length; i++) {
        expected[i].compare(result[i],compareParamNames,a);
      }
    }
  
    public static void doComparison(JConstructor[] result,
                                    GoldenInvokable[] expected,
                                    boolean compareParamNames,
                                    Assert a) {
      a.assertTrue("different number of methods ["+
                   result.length+","+expected.length+"]",
                   result.length == expected.length);
      for(int i=0; i<result.length; i++) {
        expected[i].compare(result[i],compareParamNames,a);
      }
    }
  
    // ========================================================================
    // Variables
  
    private int mModifers;
    private String mReturnType;
    private String mName;
    private String[] mParamTypes;
    private String[] mParamNames;
    private String[] mExceptions;
  
  
    // ========================================================================
    // Constructors
  
    public GoldenInvokable(String[] modsTypeNameParams) {
      this(modsTypeNameParams[0],
           modsTypeNameParams[1],
           modsTypeNameParams[2],
           modsTypeNameParams[3],
           modsTypeNameParams[4]);
    }
  
    /**
     *
     * @param modiferString
     * @param name
     * @param paramString
     */
    public GoldenInvokable(String modiferString,
                        String type,
                        String name,
                        String paramString,
                        String exceptionList) {
      mModifers = ModifierHelper.parseModifiers(modiferString);
      mReturnType = type;
      mName = name;
      //parse parameter string
      if (paramString == null) {
        mParamTypes = new String[0];
        mParamNames = new String[0];
      } else {
        StringTokenizer st = new StringTokenizer(paramString,",");
        mParamTypes = new String[st.countTokens()];
        mParamNames = new String[st.countTokens()];
        int i = 0;
        while(st.hasMoreTokens()) {
          String token = st.nextToken().trim();
          int space = token.indexOf(" ");
          mParamNames[i] = token.substring(space).trim();
          mParamTypes[i] = token.substring(0,space).trim();
          i++;
        }
      }
      // parse the exception list
      if (exceptionList == null) {
        mExceptions = new String[0];
      } else {
        StringTokenizer st = new StringTokenizer(exceptionList,",");
        mExceptions = new String[st.countTokens()];
        int i = 0;
        while(st.hasMoreTokens()) {
          mExceptions[i] = st.nextToken().trim();
          i++;
        }
      }
    }
  
    public void compare(JMethod method, boolean compareParamNames, Assert a) {
      compare((JInvokable)method,compareParamNames,a);
      a.assertTrue("return types are different ["+
                   method.getReturnType().getQualifiedName()+","+
                   mReturnType+"]",
                   method.getReturnType().getQualifiedName().equals(mReturnType));
    }
  
  
    public void compare(JInvokable invk, boolean compareParamNames, Assert a) {
      a.assertTrue("invokable names are different",
                   invk.getSimpleName().equals(mName));
      a.assertTrue("modifiers are different on "+invk.getSimpleName()+
                   "["+invk.getModifiers()+","+mModifers+"]",
                   invk.getModifiers() == mModifers);
      {
        JParameter[] params = invk.getParameters();
        a.assertTrue("parameter lists are of different lengths",
                     params.length == mParamTypes.length);
        for(int i=0; i<params.length; i++) {
          a.assertTrue("parameter type is different on "+invk.getSimpleName()+
                       "["+params[i].getType().getQualifiedName()+","+mParamTypes[i]+"]",
                       params[i].getType().getQualifiedName().equals(mParamTypes[i]));
          if (compareParamNames) {
            a.assertTrue("parameter names are different on "+invk.getSimpleName(),
                         params[i].getSimpleName().equals(mParamNames[i]));
          }
        }
      }
      {
        JClass[] exceptions = invk.getExceptionTypes();
        for(int i=0; i<exceptions.length; i++) {
          a.assertTrue("exceptions type is different on "+invk.getSimpleName()+
                       "["+exceptions[i].getQualifiedName()+","+mExceptions[i]+"]",
                       exceptions[i].getQualifiedName().equals(mExceptions[i]));
        }
      }
    }
  
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: xmlbeans-cvs-unsubscribe@xml.apache.org
For additional commands, e-mail: xmlbeans-cvs-help@xml.apache.org


Mime
View raw message