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

Unified Diff: pkg/kernel/test/heap_test.dart

Issue 2848083002: Implement Dart 1.0 LUB algorithm (for interface types) in kernel. (Closed)
Patch Set: Created 3 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
Index: pkg/kernel/test/heap_test.dart
diff --git a/pkg/kernel/test/heap_test.dart b/pkg/kernel/test/heap_test.dart
new file mode 100644
index 0000000000000000000000000000000000000000..56d4b47ea61be3d3d7c3cf43eea3455832dd1454
--- /dev/null
+++ b/pkg/kernel/test/heap_test.dart
@@ -0,0 +1,26 @@
+// Copyright (c) 2017, 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 'package:kernel/heap.dart';
+import 'package:test/test.dart';
+
+main() {
+ test('sort', () {
+ var values = <int>[3, 1, 4, 1, 5, 9, 2, 6];
ahe 2017/05/01 16:50:34 Would it make sense to test a list that is sorted,
Paul Berry 2017/05/01 18:12:14 Yes, good idea. Done.
+ var heap = new _intHeap();
+ values.forEach(heap.add);
+ values.sort();
+ var result = <int>[];
+ while (heap.isNotEmpty) {
+ expect(heap.isEmpty, isFalse);
+ result.add(heap.remove());
+ }
+ expect(heap.isEmpty, isTrue);
+ expect(result, values);
+ });
+}
+
+class _intHeap extends Heap<int> {
+ bool sortsBefore(int a, int b) => a < b;
+}

Powered by Google App Engine
This is Rietveld 408576698