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

Unified Diff: test/codegen/lib/html/typed_arrays_2_test.dart

Issue 1930043002: Add all dart:html tests from the sdk to test/codegen. (Closed) Base URL: git@github.com:dart-lang/dev_compiler.git@master
Patch Set: ptal Created 4 years, 8 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 | « test/codegen/lib/html/typed_arrays_1_test.dart ('k') | test/codegen/lib/html/typed_arrays_3_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/lib/html/typed_arrays_2_test.dart
diff --git a/test/codegen/lib/html/typed_arrays_2_test.dart b/test/codegen/lib/html/typed_arrays_2_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..5a0d83a4db8076814fdbe6859c4ad56f8addeca6
--- /dev/null
+++ b/test/codegen/lib/html/typed_arrays_2_test.dart
@@ -0,0 +1,86 @@
+// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+library TypedArrays2Test;
+import 'package:unittest/unittest.dart';
+import 'package:unittest/html_config.dart';
+import 'dart:html';
+import 'dart:typed_data';
+
+main() {
+ useHtmlConfiguration();
+
+ // Only perform tests if ArrayBuffer is supported.
+ if (!Platform.supportsTypedData) {
+ return;
+ }
+
+ test('viewTest_dynamic', () {
+ var a1 = new Uint8List(1024);
+ for (int i = 0; i < a1.length; i++) {
+ a1[i] = i; // 0,1,2,...,254,255,0,1,2,...
+ }
+
+ var a2 = new Uint32List.view(a1.buffer);
+ expect(1024 ~/ 4, a2.length);
+ expect(a2[0], 0x03020100);
+ expect(a2[1], 0x07060504);
+ expect(a2[2], 0x0B0A0908);
+ expect(a2[50], 0xCBCAC9C8);
+ expect(a2[51], 0xCFCECDCC);
+ expect(a2[64], 0x03020100);
+
+ a2 = new Uint32List.view(a1.buffer, 200);
+ expect(a2.length, (1024 - 200) ~/ 4);
+ expect(a2[0], 0xCBCAC9C8);
+ expect(a2[1], 0xCFCECDCC);
+ expect(a2[14], 0x03020100);
+
+ a2 = new Uint32List.view(a1.buffer, 456, 20);
+ expect(a2.length, 20);
+ expect(a2[0], 0xCBCAC9C8);
+ expect(a2[1], 0xCFCECDCC);
+ expect(a2[14], 0x03020100);
+
+ // OPTIONALS a2 = new Uint32List.view(a1.buffer, length: 30, byteOffset: 456);
+ a2 = new Uint32List.view(a1.buffer, 456, 30);
+ expect(a2.length, 30);
+ expect(a2[0], 0xCBCAC9C8);
+ expect(a2[1], 0xCFCECDCC);
+ expect(a2[14], 0x03020100);
+ });
+
+ test('viewTest_typed', () {
+ Uint8List a1 = new Uint8List(1024);
+ for (int i = 0; i < a1.length; i++) {
+ a1[i] = i;
+ }
+
+ Uint32List a2 = new Uint32List.view(a1.buffer);
+ expect(a2.length, 1024 ~/ 4);
+ expect(a2[0], 0x03020100);
+ expect(a2[50], 0xCBCAC9C8);
+ expect(a2[51], 0xCFCECDCC);
+ expect(a2[64], 0x03020100);
+
+ a2 = new Uint32List.view(a1.buffer, 200);
+ expect(a2.length, (1024 - 200) ~/ 4);
+ expect(a2[0], 0xCBCAC9C8);
+ expect(a2[1], 0xCFCECDCC);
+ expect(a2[14], 0x03020100);
+
+ a2 = new Uint32List.view(a1.buffer, 456, 20);
+ expect(20, a2.length);
+ expect(a2[0], 0xCBCAC9C8);
+ expect(a2[1], 0xCFCECDCC);
+ expect(a2[14], 0x03020100);
+
+ // OPTIONALS a2 = new Uint32List.view(a1.buffer, length: 30, byteOffset: 456);
+ a2 = new Uint32List.view(a1.buffer, 456, 30);
+ expect(a2.length, 30);
+ expect(a2[0], 0xCBCAC9C8);
+ expect(a2[1], 0xCFCECDCC);
+ expect(a2[14], 0x03020100);
+ });
+}
« no previous file with comments | « test/codegen/lib/html/typed_arrays_1_test.dart ('k') | test/codegen/lib/html/typed_arrays_3_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698