Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4)

Side by Side Diff: test/mjsunit/harmony/typedarray-reverse.js

Issue 1215863003: Include Harmony Array/TypedArray methods unconditionally (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: remove the flag and move the tests Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/mjsunit/harmony/typedarray-reduce.js ('k') | test/mjsunit/harmony/typedarray-slice.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2015 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 // Flags: --harmony-arrays
6
7 function ArrayMaker(x) {
8 return x;
9 }
10 ArrayMaker.prototype = Array.prototype;
11
12 var arrayConstructors = [
13 Uint8Array,
14 Int8Array,
15 Uint16Array,
16 Int16Array,
17 Uint32Array,
18 Int32Array,
19 Uint8ClampedArray,
20 Float32Array,
21 Float64Array,
22 ArrayMaker // Also test arrays
23 ];
24
25 function assertArrayLikeEquals(value, expected, type) {
26 assertEquals(value.__proto__, type.prototype);
27 assertEquals(expected.length, value.length);
28 for (var i = 0; i < value.length; ++i) {
29 assertEquals(expected[i], value[i]);
30 }
31 }
32
33 for (var constructor of arrayConstructors) {
34 // Test reversing both even and odd length arrays
35 var a = new constructor([1, 2, 3]);
36 assertArrayLikeEquals(a.reverse(), [3, 2, 1], constructor);
37 assertArrayLikeEquals(a, [3, 2, 1], constructor);
38
39 a = new constructor([1, 2, 3, 4]);
40 assertArrayLikeEquals(a.reverse(), [4, 3, 2, 1], constructor);
41 assertArrayLikeEquals(a, [4, 3, 2, 1], constructor);
42
43 if (constructor != ArrayMaker) {
44 // Cannot be called on objects which are not TypedArrays
45 assertThrows(function () { a.reverse.call({ length: 0 }); }, TypeError);
46 } else {
47 // Array.reverse works on array-like objects
48 var x = { length: 2, 1: 5 };
49 a.reverse.call(x);
50 assertEquals(2, x.length);
51 assertFalse(Object.hasOwnProperty(x, '1'));
52 assertEquals(5, x[0]);
53 }
54
55 assertEquals(0, a.reverse.length);
56 }
OLDNEW
« no previous file with comments | « test/mjsunit/harmony/typedarray-reduce.js ('k') | test/mjsunit/harmony/typedarray-slice.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698