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

Unified Diff: tests/standalone/typed_data_test.dart

Issue 24239003: Fix range checks for typed data in native code and the optimizer. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 3 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 | « runtime/vm/flow_graph_optimizer.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/standalone/typed_data_test.dart
===================================================================
--- tests/standalone/typed_data_test.dart (revision 27650)
+++ tests/standalone/typed_data_test.dart (working copy)
@@ -143,9 +143,18 @@
testSetRangeHelper(new Uint8ClampedList(3));
}
-void testIndexOutOfRangeHelper(typed_data) {
- List<int> list = const [0, 1, 2, 3];
+class C {
+ final x;
+ C(this.x);
+ operator<(o) => false;
+ operator>=(o) => false;
+ operator*(o) => x;
+}
+void testIndexOutOfRangeHelper(typed_data, value) {
+ List<int> list = new List<int>(typed_data.length + 1);
+ for (int i = 0; i < list.length; i++) list[i] = i;
+
Expect.throws(() {
typed_data.setRange(0, 4, list);
});
@@ -153,11 +162,36 @@
Expect.throws(() {
typed_data.setRange(3, 4, list);
});
+
+ Expect.throws(() {
+ typed_data[new C(-4000000)] = value;
+ });
+
+ Expect.throws(() {
+ var size = typed_data.elementSizeInBytes;
+ var i = (typed_data.length - 1) * size + 1;
+ typed_data[new C(i)] = value;
+ });
+
+ Expect.throws(() {
+ typed_data[new C(-1)] = value;
+ });
}
void testIndexOutOfRange() {
- testIndexOutOfRangeHelper(new Uint8List(3));
- testIndexOutOfRangeHelper(new Uint8ClampedList(3));
+ testIndexOutOfRangeHelper(new Int8List(3), 0);
+ testIndexOutOfRangeHelper(new Uint8List(3), 0);
+ testIndexOutOfRangeHelper(new Uint8ClampedList(3), 0);
+ testIndexOutOfRangeHelper(new Int16List(3), 0);
+ testIndexOutOfRangeHelper(new Uint16List(3), 0);
+ testIndexOutOfRangeHelper(new Int32List(3), 0);
+ testIndexOutOfRangeHelper(new Uint32List(3), 0);
+ testIndexOutOfRangeHelper(new Int64List(3), 0);
+ testIndexOutOfRangeHelper(new Uint64List(3), 0);
+ testIndexOutOfRangeHelper(new Float32List(3), 0.0);
+ testIndexOutOfRangeHelper(new Float64List(3), 0.0);
+ testIndexOutOfRangeHelper(new Int64List(3), 0);
+ testIndexOutOfRangeHelper(new Uint64List(3), 0);
}
void testIndexOfHelper(list) {
« no previous file with comments | « runtime/vm/flow_graph_optimizer.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698