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  * JDK-8028210: Missing conversions on array index expression
  26  *
  27  * @test
  28  * @run
  29  */
  30 
  31 var array = [1, 2];
  32 var key1 = [[[0]]];
  33 var key2 = new String("1");
  34 var key3 = {
  35     toString: function() {
  36         print("toString called");
  37         return "2";
  38     }
  39 };
  40 
  41 print(array[key1]);
  42 print(array[key2]);
  43 array[key3] = 3;
  44 print(array[key3]);
  45 print(key3 in array);
  46 print(array.hasOwnProperty(key3));
  47 print(delete array[key3]);
  48 print(array[key3]);
  49 
  50 // string access
  51 print("abc"[key1]);
  52 print("abc"[key2]);
  53 print("abc"[key3]);
  54 
  55 // arguments object
  56 (function(a, b, c) {
  57     print(arguments[key3]);
  58     delete arguments[key3];
  59     print(arguments[key3], c);
  60 })(1, 2, 3);
  61 
  62 // int keys
  63 array = [];
  64 array[4294967294] = 1;
  65 print(array[-2]);
  66 print(array[4294967294]);
  67 print(-2 in array);
  68 print(4294967294 in array);
  69 print(delete(array[-2]));
  70 print(array[4294967294]);
  71 print(delete(array[4294967294]));
  72 print(array[4294967294]);
  73 
  74 array = [];
  75 array[-2] = 1;
  76 print(array[-2]);
  77 print(array[4294967294]);
  78 print(-2 in array);
  79 print(4294967294 in array);
  80 print(delete(array[4294967294]));
  81 print(array[-2]);
  82 print(delete(array[-2]));
  83 print(array[-2]);