nashorn/test/script/basic/JDK-8087312.js
author hannesw
Wed, 17 Jun 2015 09:10:45 +0200
changeset 31197 1af1f3366c49
permissions -rw-r--r--
8087312: PropertyMapWrapper.equals should compare className Reviewed-by: sundar, attila
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
31197
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
     1
/*
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
     2
 * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
     4
 * 
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
     7
 * published by the Free Software Foundation.
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
     8
 * 
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    13
 * accompanied this code).
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    14
 * 
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    18
 * 
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    21
 * questions.
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    22
 */
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    23
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    24
/**
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    25
 * JDK-8087312: PropertyMapWrapper.equals should compare className
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    26
 *
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    27
 * @test
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    28
 * @run
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    29
 * @fork
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    30
 * @option -Dnashorn.debug=true
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    31
 */
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    32
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    33
function createObject(type) {
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    34
    // we want to make sure two different object literals with the same keys and types share the same property map.
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    35
    if (type) {
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    36
        return {
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    37
            a: "a",
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    38
            b: 1,
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    39
            c: 0.1
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    40
        }
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    41
    } else {
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    42
        return {
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    43
            a: "x",
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    44
            b: 10,
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    45
            c: 3.4
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    46
        }
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    47
    }
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    48
}
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    49
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    50
var o1 = createObject(false);
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    51
var o2 = createObject(true);
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    52
Assert.assertTrue(Debug.map(o1) === Debug.map(o2));
1af1f3366c49 8087312: PropertyMapWrapper.equals should compare className
hannesw
parents:
diff changeset
    53