Fri, 14 Jul 2017 14:30:06 -0700
Merge
sundar@1833 | 1 | /* |
sundar@1833 | 2 | * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
sundar@1833 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
sundar@1833 | 4 | * |
sundar@1833 | 5 | * This code is free software; you can redistribute it and/or modify it |
sundar@1833 | 6 | * under the terms of the GNU General Public License version 2 only, as |
sundar@1833 | 7 | * published by the Free Software Foundation. |
sundar@1833 | 8 | * |
sundar@1833 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
sundar@1833 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
sundar@1833 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
sundar@1833 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
sundar@1833 | 13 | * accompanied this code). |
sundar@1833 | 14 | * |
sundar@1833 | 15 | * You should have received a copy of the GNU General Public License version |
sundar@1833 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
sundar@1833 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
sundar@1833 | 18 | * |
sundar@1833 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
sundar@1833 | 20 | * or visit www.oracle.com if you need additional information or have any |
sundar@1833 | 21 | * questions. |
sundar@1833 | 22 | */ |
sundar@1833 | 23 | |
sundar@1833 | 24 | /** |
sundar@1833 | 25 | * JDK-8157819: TypeError when a java.util.Comparator object is invoked as a function |
sundar@1833 | 26 | * |
sundar@1833 | 27 | * @test |
sundar@1833 | 28 | * @run |
sundar@1833 | 29 | */ |
sundar@1833 | 30 | |
sundar@1833 | 31 | var compare = java.util.Comparator.naturalOrder() |
sundar@1833 | 32 | Assert.assertTrue(compare("nashorn", "ecmascript") > 0) |
sundar@1833 | 33 | Assert.assertTrue(compare("abc", "xyz") < 0) |
sundar@1833 | 34 | Assert.assertTrue(compare("hello", "hello") == 0) |
sundar@1833 | 35 | |
sundar@1833 | 36 | var rcompare = java.util.Comparator.reverseOrder() |
sundar@1833 | 37 | Assert.assertTrue(rcompare("nashorn", "ecmascript") < 0) |
sundar@1833 | 38 | Assert.assertTrue(rcompare("abc", "xyz") > 0) |
sundar@1833 | 39 | Assert.assertTrue(rcompare("hello", "hello") == 0) |
sundar@1833 | 40 | |
sundar@1833 | 41 | var arr = [ "nashorn", "JavaScript", "ECMAScript", "ecmascript", "js" ] |
sundar@1833 | 42 | Assert.assertEquals(arr.sort(compare).join(), |
sundar@1833 | 43 | "ECMAScript,JavaScript,ecmascript,js,nashorn") |
sundar@1833 | 44 | Assert.assertEquals(arr.sort(rcompare).join(), |
sundar@1833 | 45 | "nashorn,js,ecmascript,JavaScript,ECMAScript") |
sundar@1833 | 46 |