nashorn/test/script/basic/NASHORN-556.js
author psandoz
Tue, 13 Aug 2013 11:16:37 +0200
changeset 19424 c4524285927f
parent 17758 2b056941e4dd
child 24778 2ff5d7041566
permissions -rw-r--r--
8022797: Clarify spliterator characteristics for collections containing no elements Reviewed-by: alanb, mduigou
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     1
/*
16151
97c1e756ae1e 8005663: Update copyright year to 2013
jlaskey
parents: 16147
diff changeset
     2
 * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved.
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     4
 * 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     7
 * published by the Free Software Foundation.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     8
 * 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    13
 * accompanied this code).
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    14
 * 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    18
 * 
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    21
 * questions.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    22
 */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    23
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    24
/*
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    25
 * NASHORN-556: Need more tests to exercise code in jdk.nashorn.internal.runtime.array package.
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    26
 *
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    27
 * @test
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    28
 * @run
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    29
 */
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    30
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    31
function p() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    32
  var s = "";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    33
  for each (var i in arguments) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    34
    s += ((i !== undefined) ? i : "") + ",";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    35
  }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    36
  s = s.length != 0 ? s.substr(0, s.length - 1) : s;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    37
  print(s);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    38
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    39
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    40
function assertEq(expected, actual) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    41
  if (actual !== expected && !(isNaN(actual) && isNaN(expected))) {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    42
    throw "expected=" + expected + " actual=" + actual;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    43
  }
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    44
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    45
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    46
function f1() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    47
  // (NoTypeArrayData)
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    48
  var empty = {};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    49
  empty.length = 10;
17758
2b056941e4dd 8014797: rename Java.toJavaArray/toJavaScriptArray to Java.to/from, respectively.
attila
parents: 16151
diff changeset
    50
  Java.to(empty);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    51
  delete empty[0];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    52
  Array.prototype.slice.call(empty, 0, 1);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    53
  Array.prototype.pop.call(empty);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    54
  Array.prototype.shift.call(empty);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    55
  empty = {};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    56
  empty[0] = eval("84") >>> 1; assertEq(42, empty[0]);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    57
  empty = {};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    58
  Array.prototype.unshift.call(empty, "x"); assertEq("x", empty[0]);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    59
  empty = {};
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    60
  empty[0] = 8.4; assertEq(8.4, empty[0]);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    61
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    62
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    63
function f2() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    64
  // DeletedArrayFilter
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    65
  var deleted = [,1,,2,,3,,4,,];
17758
2b056941e4dd 8014797: rename Java.toJavaArray/toJavaScriptArray to Java.to/from, respectively.
attila
parents: 16151
diff changeset
    66
  assertEq(2, Java.to(deleted)[3]);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    67
  assertEq(undefined, deleted.pop());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    68
  assertEq(4, deleted.pop());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    69
  deleted.unshift(5);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    70
  p.apply(null, deleted);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    71
  assertEq(5, deleted.shift());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    72
  print(deleted.slice(0,3), deleted.slice(1,7));
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    73
  assertEq(1, deleted[3] >>> 1);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    74
  deleted[3] = eval("84") >>> 1; assertEq(42, deleted[3]);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    75
  p.apply(null, deleted);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    76
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    77
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    78
function f3() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    79
  // DeletedRangeArrayFilter
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    80
  var delrange = [1,2,3,,,,,,,,,,];
17758
2b056941e4dd 8014797: rename Java.toJavaArray/toJavaScriptArray to Java.to/from, respectively.
attila
parents: 16151
diff changeset
    81
  Java.to(delrange);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    82
  delrange.unshift(4);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    83
  p.apply(null, delrange);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    84
  print(delrange.slice(1,3), delrange.slice(2,6));
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    85
  assertEq(4, delrange.shift());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    86
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    87
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    88
function f4() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    89
  // NumberArrayData
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    90
  var num = [1.1,2.2,3.3,4.4,5.5];
17758
2b056941e4dd 8014797: rename Java.toJavaArray/toJavaScriptArray to Java.to/from, respectively.
attila
parents: 16151
diff changeset
    91
  Java.to(num);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    92
  assertEq(2, num[3] >>> 1);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    93
  assertEq(5, num[4] | 0);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    94
  assertEq(5.5, num.pop());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    95
  num.unshift(13.37);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    96
  print(num.slice(1,4));
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    97
  assertEq(13.37, num.shift());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    98
  p.apply(null, num);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
    99
  num.length = 20;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   100
  delete num[0];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   101
  num[0] = eval("14") >>> 1;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   102
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   103
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   104
function f5() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   105
  // ObjectArrayData
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   106
  var obj = [2,"two",3.14,"pi",14,"fourteen"];
17758
2b056941e4dd 8014797: rename Java.toJavaArray/toJavaScriptArray to Java.to/from, respectively.
attila
parents: 16151
diff changeset
   107
  Java.to(obj);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   108
  assertEq(-12.86, obj[2] - 16);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   109
  assertEq(7, obj[4] >>> 1);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   110
  obj.unshift("one");
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   111
  obj[0] = 1.3;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   112
  obj[0] = eval("14") >>> 1;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   113
  assertEq(7, obj.shift());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   114
  p.apply(null, obj);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   115
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   116
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   117
function f6() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   118
  // SparseArrayData
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   119
  var sparse = [9,8,7,6,5,4,3,2,1];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   120
  sparse[0x76543210] = 84;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   121
  assertEq(42, sparse[0x76543210] >>> 1);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   122
  assertEq(42, sparse[0x76543210] - 42);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   123
  assertEq(85, sparse[0x76543210] | 1);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   124
  sparse[0x76543210] = 7.2;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   125
  sparse[0x76543210] = eval("84") >>> 1;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   126
  sparse.unshift(10);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   127
  print(sparse.slice(0,12));
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   128
  print(sparse.slice(0x76543209, 0x76543213));
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   129
  assertEq(10, sparse.shift());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   130
  assertEq(42, sparse.pop());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   131
  sparse.length = 1024*1024;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   132
  sparse.push(sparse.length);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   133
  delete sparse[sparse.length-1];
17758
2b056941e4dd 8014797: rename Java.toJavaArray/toJavaScriptArray to Java.to/from, respectively.
attila
parents: 16151
diff changeset
   134
  //print(Java.to(sparse).length);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   135
  (function(){}).apply(null, sparse);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   136
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   137
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   138
function f7() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   139
  // UndefinedArrayFilter
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   140
  var undef = [1,2,3,4,5,undefined,7,8,9,19];
17758
2b056941e4dd 8014797: rename Java.toJavaArray/toJavaScriptArray to Java.to/from, respectively.
attila
parents: 16151
diff changeset
   141
  Java.to(undef);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   142
  assertEq(4, undef[8] >>> 1);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   143
  var tmp = undef[9] >>> 1;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   144
  undef[8] = tmp;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   145
  undef.unshift(21);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   146
  print(undef.slice(0, 4), undef.slice(4, 5));
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   147
  assertEq(21, undef.shift());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   148
  undef.push(20);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   149
  assertEq(20, undef.pop());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   150
  assertEq(19, undef.pop());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   151
  p.apply(null, undef);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   152
  undef.length = 20;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   153
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   154
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   155
function f8() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   156
  // LongArrayData
17758
2b056941e4dd 8014797: rename Java.toJavaArray/toJavaScriptArray to Java.to/from, respectively.
attila
parents: 16151
diff changeset
   157
  var j = Java.from(Java.to([23,37,42,86,47], "long[]"));
2b056941e4dd 8014797: rename Java.toJavaArray/toJavaScriptArray to Java.to/from, respectively.
attila
parents: 16151
diff changeset
   158
  Java.to(j);
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   159
  p.apply(null, j);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   160
  assertEq(43, j[3] >>> 1);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   161
  assertEq(36, j[4] - 11);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   162
  j.unshift(eval("14") >>> 1);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   163
  print(j.slice(0,4));
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   164
  assertEq(7, j.shift());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   165
  assertEq(47, j.pop());
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   166
  j.push("asdf");
17758
2b056941e4dd 8014797: rename Java.toJavaArray/toJavaScriptArray to Java.to/from, respectively.
attila
parents: 16151
diff changeset
   167
  j = Java.from(Java.to([23,37,42,86,47], "long[]"));
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   168
  j.length = 3;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   169
  j[0] = 13;
17758
2b056941e4dd 8014797: rename Java.toJavaArray/toJavaScriptArray to Java.to/from, respectively.
attila
parents: 16151
diff changeset
   170
  j = Java.from(Java.to([23,37,42,86,47], "long[]"));
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   171
  delete j[0];
17758
2b056941e4dd 8014797: rename Java.toJavaArray/toJavaScriptArray to Java.to/from, respectively.
attila
parents: 16151
diff changeset
   172
  j = Java.from(Java.to([23,37,42,86,47], "long[]"));
16147
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   173
  j.length = 20;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   174
  j[0] = 13.37;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   175
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   176
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   177
function f9() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   178
  // FrozenArrayFilter
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   179
  var a1 = [10,11,12,13,14,15];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   180
  Object.freeze(a1);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   181
  assertEq(true, Object.isFrozen(a1));
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   182
  Object.getOwnPropertyDescriptor(a1, 0);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   183
  a1[1] = 1;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   184
  a1[2] = eval("14") >>> 1;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   185
  a1[3] = 3.14;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   186
  a1[4] = "asdf";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   187
  print(a1.slice(1,4));
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   188
  a1.length = 20;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   189
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   190
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   191
function f10() {
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   192
  // SealedArrayFilter
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   193
  var a1 = [10,11,12,13,14,15];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   194
  Object.seal(a1);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   195
  assertEq(true, Object.isSealed(a1));
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   196
  Object.getOwnPropertyDescriptor(a1, 0);
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   197
  a1[1] = 1;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   198
  a1[2] = eval("14") >>> 1;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   199
  a1[3] = 3.14;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   200
  a1[4] = "asdf";
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   201
  print(a1.slice(1,4));
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   202
  delete a1[0];
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   203
  a1.length = 20;
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   204
}
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   205
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   206
f1();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   207
f2();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   208
f3();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   209
f4();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   210
f5();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   211
f6();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   212
f7();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   213
f8();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   214
f9();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   215
f10();
e63b63819133 8005403: Open-source Nashorn
jlaskey
parents:
diff changeset
   216