author | psandoz |
Tue, 13 Aug 2013 11:16:37 +0200 | |
changeset 19424 | c4524285927f |
parent 16767 | e286a6e8c642 |
child 24778 | 2ff5d7041566 |
permissions | -rw-r--r-- |
16767
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
1 |
/* |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
2 |
* Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
3 |
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
4 |
* |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
5 |
* This code is free software; you can redistribute it and/or modify it |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
6 |
* under the terms of the GNU General Public License version 2 only, as |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
7 |
* published by the Free Software Foundation. |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
8 |
* |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
9 |
* This code is distributed in the hope that it will be useful, but WITHOUT |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
10 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
11 |
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
12 |
* version 2 for more details (a copy is included in the LICENSE file that |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
13 |
* accompanied this code). |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
14 |
* |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
15 |
* You should have received a copy of the GNU General Public License version |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
16 |
* 2 along with this work; if not, write to the Free Software Foundation, |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
17 |
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
18 |
* |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
19 |
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
20 |
* or visit www.oracle.com if you need additional information or have any |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
21 |
* questions. |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
22 |
*/ |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
23 |
|
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
24 |
/** |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
25 |
* JDK-8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
26 |
* |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
27 |
* @test |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
28 |
* @run |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
29 |
*/ |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
30 |
|
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
31 |
var startValueOf = 0; |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
32 |
var endValueOf = 0; |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
33 |
|
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
34 |
[].slice( |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
35 |
{ |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
36 |
valueOf: function() { |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
37 |
startValueOf++; |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
38 |
} |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
39 |
}, |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
40 |
{ |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
41 |
valueOf: function() { |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
42 |
endValueOf++; |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
43 |
} |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
44 |
} |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
45 |
); |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
46 |
|
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
47 |
if (startValueOf !== 1) { |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
48 |
fail("Array.prototype.slice should call valueOf on start arg once"); |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
49 |
} |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
50 |
|
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
51 |
if (endValueOf !== 1) { |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
52 |
fail("Array.prototype.slice should call valueOf on end arg once"); |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
53 |
} |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
54 |
|
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
55 |
startValueOf = 0; |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
56 |
|
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
57 |
[].splice( |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
58 |
{ |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
59 |
valueOf: function() { |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
60 |
startValueOf++; |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
61 |
} |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
62 |
} |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
63 |
); |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
64 |
|
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
65 |
if (startValueOf !== 1) { |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
66 |
fail("Array.prototype.splice should call valueOf on start arg once"); |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
67 |
} |
e286a6e8c642
8011357: Array.prototype.slice and Array.prototype.splice should not call user defined valueOf of start, end arguments more than once
sundar
parents:
diff
changeset
|
68 |