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

Unified Diff: tests/corelib/src/SortHelper.dart

Issue 10244009: test rename overhaul: step 7 - corelib tests (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 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: tests/corelib/src/SortHelper.dart
diff --git a/tests/corelib/src/SortHelper.dart b/tests/corelib/src/SortHelper.dart
deleted file mode 100644
index 4efa33bbc1bedb346f00d44b56807ca2aaf5e66b..0000000000000000000000000000000000000000
--- a/tests/corelib/src/SortHelper.dart
+++ /dev/null
@@ -1,162 +0,0 @@
-// 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.
-
-class SortHelper {
-
- SortHelper(this.sortFunction, this.compareFunction) {}
-
- void run() {
- testSortIntLists();
- testSortDoubleLists();
- }
-
- void printList(List a) {
- StringBuffer buffer = new StringBuffer();
- for (int i = 0; i < a.length; i++) {
- if (i != 0) buffer.add(",");
- buffer.add(a[i]);
- }
- print("[$buffer]");
- }
-
- bool isSorted(List a) {
- for (int i = 1; i < a.length; i++) {
- if (compareFunction(a[i - 1], a[i]) > 0) {
- return false;
- }
- }
- return true;
- }
-
- void testSortIntLists() {
- List a = new List(40);
-
- for (int i = 0; i < a.length; i++) {
- a[i] = i;
- }
- testSort(a);
-
- for (int i = 0; i < a.length; i++) {
- a[a.length - i - 1] = i;
- }
- testSort(a);
-
- for (int i = 0; i < 21; i++) {
- a[i] = 1;
- }
- for (int i = 21; i < a.length; i++) {
- a[i] = 2;
- }
- testSort(a);
-
- // Same with bad pivot-choices.
- for (int i = 0; i < 21; i++) {
- a[i] = 1;
- }
- for (int i = 21; i < a.length; i++) {
- a[i] = 2;
- }
- a[6] = 1;
- a[13] = 1;
- a[19] = 1;
- a[25] = 1;
- a[33] = 2;
- testSort(a);
-
- for (int i = 0; i < 21; i++) {
- a[i] = 2;
- }
- for (int i = 21; i < a.length; i++) {
- a[i] = 1;
- }
- testSort(a);
-
- // Same with bad pivot-choices.
- for (int i = 0; i < 21; i++) {
- a[i] = 2;
- }
- for (int i = 21; i < a.length; i++) {
- a[i] = 1;
- }
- a[6] = 2;
- a[13] = 2;
- a[19] = 2;
- a[25] = 2;
- a[33] = 1;
- testSort(a);
-
- var a2 = new List(0);
- testSort(a2);
-
- var a3 = new List(1);
- a3[0] = 1;
- testSort(a3);
-
- // --------
- // Test insertion sort.
- testInsertionSort(0, 1, 2, 3);
- testInsertionSort(0, 1, 3, 2);
- testInsertionSort(0, 3, 2, 1);
- testInsertionSort(0, 3, 1, 2);
- testInsertionSort(0, 2, 1, 3);
- testInsertionSort(0, 2, 3, 1);
- testInsertionSort(1, 0, 2, 3);
- testInsertionSort(1, 0, 3, 2);
- testInsertionSort(1, 2, 3, 0);
- testInsertionSort(1, 2, 0, 3);
- testInsertionSort(1, 3, 2, 0);
- testInsertionSort(1, 3, 0, 2);
- testInsertionSort(2, 0, 1, 3);
- testInsertionSort(2, 0, 3, 1);
- testInsertionSort(2, 1, 3, 0);
- testInsertionSort(2, 1, 0, 3);
- testInsertionSort(2, 3, 1, 0);
- testInsertionSort(2, 3, 0, 1);
- testInsertionSort(3, 0, 1, 2);
- testInsertionSort(3, 0, 2, 1);
- testInsertionSort(3, 1, 2, 0);
- testInsertionSort(3, 1, 0, 2);
- testInsertionSort(3, 2, 1, 0);
- testInsertionSort(3, 2, 0, 1);
- }
-
- void testSort(List a) {
- printList(a);
- sortFunction(a);
- printList(a);
- bool sorted = isSorted(a);
- Expect.equals(true, sorted);
- print(sorted);
- }
-
- void testInsertionSort(int i1, int i2, int i3, int i4) {
- var a = new List(4);
- a[0] = i1;
- a[1] = i2;
- a[2] = i3;
- a[3] = i4;
- testSort(a);
- }
-
- void testSortDoubleLists() {
- List a = new List(40);
- for (int i = 0; i < a.length; i++) {
- a[i] = 1.0 * i + 0.5;
- }
- testSort(a);
-
- for (int i = 0; i < a.length; i++) {
- a[i] = 1.0 * (a.length - i) + 0.5;
- }
- testSort(a);
-
- for (int i = 0; i < a.length; i++) {
- a[i] = 1.5;
- }
- testSort(a);
- }
-
- Function sortFunction;
- Function compareFunction;
-}
« no previous file with comments | « tests/corelib/src/SetTest.dart ('k') | tests/corelib/src/SortTest.dart » ('j') | tools/test.dart » ('J')

Powered by Google App Engine
This is Rietveld 408576698