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

Unified Diff: test/mjsunit/es6/typedarray-indexing.js

Issue 2744283002: [typedarrays] Implement %TypedArray%.prototype.lastIndexOf in C++ (Closed)
Patch Set: Correct integral value check Created 3 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/js/typedarray.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/es6/typedarray-indexing.js
diff --git a/test/mjsunit/es6/typedarray-indexing.js b/test/mjsunit/es6/typedarray-indexing.js
index 44472e3eb3ed1207e91da2d343e7d3e36a82af11..1c439f9ddac48ea7efd847e59be70cf97e981f5c 100644
--- a/test/mjsunit/es6/typedarray-indexing.js
+++ b/test/mjsunit/es6/typedarray-indexing.js
@@ -42,6 +42,16 @@ for (var constructor of typedArrayConstructors) {
Object.defineProperty(array, 'length', {value: 1});
assertEquals(array.indexOf(2), 1);
+ // Index of infinite value
+ array = new constructor([NaN, 2, 3, +Infinity, -Infinity, 5, 6]);
+ if (constructor == Float32Array || constructor == Float64Array) {
+ assertEquals(3, array.indexOf(Infinity));
+ assertEquals(4, array.indexOf(-Infinity));
+ } else {
+ assertEquals(-1, array.indexOf(Infinity));
+ assertEquals(-1, array.indexOf(-Infinity));
+ }
+ assertEquals(-1, array.indexOf(NaN));
// ----------------------------------------------------------------------
// %TypedArray%.prototype.lastIndexOf.
@@ -68,4 +78,15 @@ for (var constructor of typedArrayConstructors) {
Object.defineProperty(array, 'length', {value: 1});
assertEquals(array.lastIndexOf(2), 10);
delete array.length;
+
+ // Index of infinite value
+ array = new constructor([NaN, 2, 3, +Infinity, -Infinity, 5, 6]);
+ if (constructor == Float32Array || constructor == Float64Array) {
+ assertEquals(3, array.lastIndexOf(Infinity));
+ assertEquals(4, array.lastIndexOf(-Infinity));
+ } else {
+ assertEquals(-1, array.lastIndexOf(Infinity));
+ assertEquals(-1, array.lastIndexOf(-Infinity));
+ }
+ assertEquals(-1, array.lastIndexOf(NaN));
}
« no previous file with comments | « src/js/typedarray.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698