NASHORN-30.js revision 6:5a1b0714df0e
1139776Simp/* 275374Sbp * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 375374Sbp * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 475374Sbp * 575374Sbp * This code is free software; you can redistribute it and/or modify it 675374Sbp * under the terms of the GNU General Public License version 2 only, as 775374Sbp * published by the Free Software Foundation. 875374Sbp * 975374Sbp * This code is distributed in the hope that it will be useful, but WITHOUT 1075374Sbp * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1175374Sbp * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1275374Sbp * version 2 for more details (a copy is included in the LICENSE file that 1375374Sbp * accompanied this code). 1475374Sbp * 1575374Sbp * You should have received a copy of the GNU General Public License version 1675374Sbp * 2 along with this work; if not, write to the Free Software Foundation, 1775374Sbp * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1875374Sbp * 1975374Sbp * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 2075374Sbp * or visit www.oracle.com if you need additional information or have any 2175374Sbp * questions. 2275374Sbp */ 2375374Sbp 2475374Sbp/** 2575374Sbp * NASHORN-30 : < operator with string on LHS does not call valueOf of obj on RHS. 2675374Sbp * 2775374Sbp * @test 2875374Sbp * @run 2975374Sbp */ 3075374Sbp 3175374Sbpvar obj = { 3275374Sbp valueOf: function() { 3375374Sbp print("valueOf call"); 3475374Sbp return -2 3575374Sbp }, 3675374Sbp 37163652Sphk toString: function() { 3875374Sbp print("toString call"); 3975374Sbp return "-2"; 4075374Sbp } 4175374Sbp}; 4275374Sbp 4375374Sbpif ("-1" < obj) { 4475374Sbp fail("('-1' < obj) should be true"); 4575374Sbp} else { 4675374Sbp print("yes, ('-1' < obj) is true"); 4775374Sbp} 4875374Sbp 4975374Sbp