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

Unified Diff: tests/language/vm/typed_data_polymorphic_view_test.dart

Issue 160613002: Inline polymorphic typed array view stores (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 years, 10 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/intermediate_language.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/language/vm/typed_data_polymorphic_view_test.dart
diff --git a/tests/language/vm/typed_data_polymorphic_view_test.dart b/tests/language/vm/typed_data_polymorphic_view_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..0b5475915dd2a2b87e099aa8edb829be2ad4fb13
--- /dev/null
+++ b/tests/language/vm/typed_data_polymorphic_view_test.dart
@@ -0,0 +1,35 @@
+import 'dart:typed_data';
+import 'package:expect/expect.dart';
+
+final V = 5;
+
+void run(view) {
+ for (int i = 0; i < view.length; i++) {
+ view[i] = V;
+ }
+}
+
+void verify(view) {
+ var sum = 0;
+ for (int i = 0; i < view.length; i++) {
+ sum += view[i];
+ }
+ // 1285 * view.length.
+ Expect.equals(657920, sum);
+}
+
+void main() {
+ var int8 = new Uint8List(1024);
+ var int16 = new Uint16List(512);
+
+ var view = new Uint8List.view(int8.buffer);
+ view[0] = V;
+
+ view = new Uint8List.view(int16.buffer);
+ for (int i = 0; i < 1000; i++) {
+ run(view);
+ }
+
+ Expect.equals(1285, int16[0]);
+ verify(int16);
+}
« no previous file with comments | « runtime/vm/intermediate_language.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698