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

Unified Diff: test/codegen/lib/typed_data/constructor_checks_test.dart

Issue 1673863002: Infra for running lib tests (Closed) Base URL: https://github.com/dart-lang/dev_compiler.git@master
Patch Set: Reformat Created 4 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 | « test/codegen/lib/typed_data/byte_data_test.dart ('k') | test/codegen/lib/typed_data/endianness_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/codegen/lib/typed_data/constructor_checks_test.dart
diff --git a/test/codegen/lib/typed_data/constructor_checks_test.dart b/test/codegen/lib/typed_data/constructor_checks_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..826a4e01be86e8772773daa26b2163901405808c
--- /dev/null
+++ b/test/codegen/lib/typed_data/constructor_checks_test.dart
@@ -0,0 +1,71 @@
+// Copyright (c) 2014, 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.
+
+import 'dart:typed_data';
+import 'package:expect/expect.dart';
+
+checkLengthConstructors() {
+ check(creator) {
+ Expect.throws(() => creator(null));
+ Expect.throws(() => creator(8.5));
+ Expect.throws(() => creator('10'));
+ var a = creator(10);
+ Expect.equals(10, a.length);
+ }
+
+ check((a) => new Float32List(a));
+ check((a) => new Float64List(a));
+ check((a) => new Int8List(a));
+ check((a) => new Int8List(a));
+ check((a) => new Int16List(a));
+ check((a) => new Int32List(a));
+ check((a) => new Uint8List(a));
+ check((a) => new Uint16List(a));
+ check((a) => new Uint32List(a));
+}
+
+checkViewConstructors() {
+ var buffer = new Int8List(256).buffer;
+
+ check1(creator) {
+ Expect.throws(() => creator(10));
+ Expect.throws(() => creator(null));
+ var a = creator(buffer);
+ Expect.equals(buffer, a.buffer);
+ }
+
+ check2(creator) {
+ Expect.throws(() => creator(10, 0));
+ Expect.throws(() => creator(null, 0));
+ Expect.throws(() => creator(buffer, null));
+ Expect.throws(() => creator(buffer, '8'));
+ var a = creator(buffer, 8);
+ Expect.equals(buffer, a.buffer);
+ }
+
+ check1((a) => new Float32List.view(a));
+ check1((a) => new Float64List.view(a));
+ check1((a) => new Int8List.view(a));
+ check1((a) => new Int8List.view(a));
+ check1((a) => new Int16List.view(a));
+ check1((a) => new Int32List.view(a));
+ check1((a) => new Uint8List.view(a));
+ check1((a) => new Uint16List.view(a));
+ check1((a) => new Uint32List.view(a));
+
+ check2((a, b) => new Float32List.view(a, b));
+ check2((a, b) => new Float64List.view(a, b));
+ check2((a, b) => new Int8List.view(a, b));
+ check2((a, b) => new Int8List.view(a, b));
+ check2((a, b) => new Int16List.view(a, b));
+ check2((a, b) => new Int32List.view(a, b));
+ check2((a, b) => new Uint8List.view(a, b));
+ check2((a, b) => new Uint16List.view(a, b));
+ check2((a, b) => new Uint32List.view(a, b));
+}
+
+main() {
+ checkLengthConstructors();
+ checkViewConstructors();
+}
« no previous file with comments | « test/codegen/lib/typed_data/byte_data_test.dart ('k') | test/codegen/lib/typed_data/endianness_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698