nashorn/test/script/basic/JDK-8163945.js
author hannesw
Tue, 16 Aug 2016 15:04:51 +0200
changeset 40477 e3d7b60299cd
permissions -rw-r--r--
8163945: Honor Number type hint in toPrimitive on Numbers Reviewed-by: jlaskey, mhaupt
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
40477
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
     1
/*
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
     2
 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
     4
 *
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
     8
 *
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    13
 * accompanied this code).
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    14
 *
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    18
 *
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    21
 * questions.
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    22
 */
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    23
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    24
/**
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    25
 * JDK-8163945: Honor Number type hint in toPrimitive on Numbers
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    26
 *
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    27
 * @test
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    28
 * @run
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    29
 */
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    30
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    31
function assertLessThan(a, b) {
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    32
    Assert.assertTrue(a < b);
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    33
    Assert.assertTrue(a <= b);
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    34
    Assert.assertFalse(a >= b);
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    35
    Assert.assertFalse(a > b);
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    36
}
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    37
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    38
assertLessThan(new java.lang.Long(2), new java.lang.Long(10));
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    39
assertLessThan(new java.lang.Long(2), 10);
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    40
assertLessThan(2, new java.lang.Long(10));
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    41
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    42
assertLessThan(new java.math.BigInteger(2), new java.math.BigInteger(10));
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    43
assertLessThan(new java.math.BigInteger(2), 10);
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    44
assertLessThan(2, new java.math.BigInteger(10));
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    45
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    46
assertLessThan(new java.util.concurrent.atomic.AtomicInteger(2), new java.util.concurrent.atomic.AtomicInteger(10));
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    47
assertLessThan(new java.util.concurrent.atomic.AtomicInteger(2), 10);
e3d7b60299cd 8163945: Honor Number type hint in toPrimitive on Numbers
hannesw
parents:
diff changeset
    48
assertLessThan(2, new java.util.concurrent.atomic.AtomicInteger(10));