1 /*
   2  * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /**
  25  * NASHORN-89 :  Date functions and constructor should evaluate vararg arguments in the order of appearance.
  26  *
  27  * @test
  28  * @run
  29  */
  30 
  31 function MyObj(val) {
  32     return {
  33         valueOf: function() { throw "value-" + val; }
  34     }
  35 }
  36 
  37 try {
  38     var d = new Date(1980, new MyObj(2), new MyObj(3), new MyObj(4));
  39 } catch(e) {
  40     if (e != 'value-2') {
  41         fail("expecting 'value-2' got " + e);
  42     }
  43 }
  44 
  45 try {
  46     var d = new Date(1980, 2, new MyObj(3), new MyObj(4), new MyObj(5));
  47 } catch(e) {
  48     if (e != 'value-3') {
  49         fail("expecting 'value-3' got " + e);
  50     }
  51 }
  52 
  53 try {
  54     var d = new Date(1980, 2, 1, new MyObj(4), new MyObj(5), new MyObj(6));
  55 } catch(e) {
  56     if (e != 'value-4') {
  57         fail("expecting 'value-4' got " + e);
  58     }
  59 }
  60 
  61 try {
  62     var d = new Date(1980, 2, 1, 1, new MyObj(5), new MyObj(6), new MyObj(7));
  63 } catch(e) {
  64     if (e != 'value-5') {
  65         fail("expecting 'value-5' got " + e);
  66     }
  67 }
  68 try {
  69     var d = new Date(1980, 2, 1, 1, 1, new MyObj(6), new MyObj(7));
  70 } catch(e) {
  71     if (e != 'value-6') {
  72         fail("expecting 'value-6' got " + e);
  73     }
  74 }
  75 try {
  76     var d = new Date(1980, 2, 1, 1, 1, 1, new MyObj(7));
  77 } catch(e) {
  78     if (e != 'value-7') {
  79         fail("expecting 'value-7' got " + e);
  80     }
  81 }