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

Unified Diff: test/codegen/corelib/collection_test.dart

Issue 1945153002: Add corelib tests (Closed) Base URL: https://github.com/dart-lang/dev_compiler@master
Patch Set: error_test and range_error_test now pass Created 4 years, 7 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
Index: test/codegen/corelib/collection_test.dart
diff --git a/test/codegen/corelib/collection_test.dart b/test/codegen/corelib/collection_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..680e20ab7268cb42862c6c961168a9776f246c39
--- /dev/null
+++ b/test/codegen/corelib/collection_test.dart
@@ -0,0 +1,42 @@
+// Copyright (c) 2011, 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 collection_test;
+
+import "package:expect/expect.dart";
+import 'dart:collection' show Queue;
+
+class CollectionTest {
+ CollectionTest(Iterable iterable) {
+ testFold(iterable);
+ }
+
+ void testFold(Iterable iterable) {
+ Expect.equals(28, iterable.fold(0, (prev, element) => prev + element));
+ Expect.equals(3024, iterable.fold(1, (prev, element) => prev * element));
+ }
+}
+
+
+main() {
+ final TEST_ELEMENTS = const [4, 2, 6, 7, 9];
+ // Const list.
+ new CollectionTest(TEST_ELEMENTS);
+
+ // Fixed size list.
+ var fixedList = new List(TEST_ELEMENTS.length);
+ for (int i = 0; i < TEST_ELEMENTS.length; i++) {
+ fixedList[i] = TEST_ELEMENTS[i];
+ }
+ new CollectionTest(fixedList);
+
+ // Growable list.
+ new CollectionTest(new List.from(TEST_ELEMENTS));
+
+ // Set.
+ new CollectionTest(new Set.from(TEST_ELEMENTS));
+
+ // Queue.
+ new CollectionTest(new Queue.from(TEST_ELEMENTS));
+}
« no previous file with comments | « test/codegen/corelib/collection_removes_test.dart ('k') | test/codegen/corelib/collection_to_string_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698