NASHORN-184.js revision 877:cf4d2252d444
1177633Sdfr/* 2177633Sdfr * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. 3177633Sdfr * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4177633Sdfr * 5177633Sdfr * This code is free software; you can redistribute it and/or modify it 6177633Sdfr * under the terms of the GNU General Public License version 2 only, as 7177633Sdfr * published by the Free Software Foundation. 8177633Sdfr * 9177633Sdfr * This code is distributed in the hope that it will be useful, but WITHOUT 10177633Sdfr * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 11177633Sdfr * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 12177633Sdfr * version 2 for more details (a copy is included in the LICENSE file that 13177633Sdfr * accompanied this code). 14177633Sdfr * 15177633Sdfr * You should have received a copy of the GNU General Public License version 16177633Sdfr * 2 along with this work; if not, write to the Free Software Foundation, 17177633Sdfr * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18177633Sdfr * 19177633Sdfr * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20177633Sdfr * or visit www.oracle.com if you need additional information or have any 21177633Sdfr * questions. 22177633Sdfr */ 23177633Sdfr 24177633Sdfr/** 25177633Sdfr * NASHORN-184 : Array.prototype.reduce and other generic array functions should accept strings 26177633Sdfr * 27177633Sdfr * @test 28177633Sdfr * @run 29177633Sdfr */ 30177633Sdfr 31177633Sdfrvar str = "java"; 32177633Sdfr 33177633Sdfrfunction callback(acc, prev, idx) { 34177633Sdfr print(acc + ' ' + prev + ' ' + idx); 35177633Sdfr return prev; 36177633Sdfr} 37177633Sdfr 38177633SdfrArray.prototype.reduce.call(str, callback); 39177633Sdfr