harmony-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "spark shen (JIRA)" <j...@apache.org>
Subject [jira] Created: (HARMONY-3865) [classlib][luni] AbstractMap seems to have a flawed equals method
Date Tue, 15 May 2007 06:06:16 GMT
[classlib][luni] AbstractMap seems to have a flawed equals method
-----------------------------------------------------------------

                 Key: HARMONY-3865
                 URL: https://issues.apache.org/jira/browse/HARMONY-3865
             Project: Harmony
          Issue Type: Bug
          Components: Classlib
            Reporter: spark shen


The following test case will fail on Harmony, but pass on RI

public class AMT extends AbstractMap {

        // Very crude AbstractMap implementation
        Vector values = new Vector();

        Vector keys = new Vector();

        public Set entrySet() {
            return new AbstractSet() {
                public Iterator iterator() {
                    return new Iterator() {
                        int index = 0;

                        public boolean hasNext() {
                            return index < values.size();
                        }

                        public Object next() {
                            if (index < values.size()) {
                                Map.Entry me = new Map.Entry() {
                                    Object v = values.elementAt(index);

                                    Object k = keys.elementAt(index);

                                    public Object getKey() {
                                        return k;
                                    }

                                    public Object getValue() {
                                        return v;
                                    }

                                    public Object setValue(Object value) {
                                        return null;
                                    }
                                };
                                index++;
                                return me;
                            }
                            return null;
                        }

                        public void remove() {
                        }
                    };
                }

                public int size() {
                    return values.size();
                }
            };
        }

        public Object put(Object k, Object v) {
            keys.add(k);
            values.add(v);
            return v;
        }
    }
    
    /**
     * @tests {@link java.util.AbstractMap#putAll(Map)}
     */
    public void test_putAllLMap() {
        Hashtable ht = new Hashtable();
        AMT amt = new AMT();
        ht.put("this", "that");
        amt.putAll(ht);
        amt.equals(ht);
        assertEquals("Should be equal", amt, ht);
    }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message