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

Side by Side Diff: tests/corelib/src/SortHelper.dart

Issue 8534001: Adds typechecking of return values (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: better runtime checks Created 9 years, 1 month 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 class SortHelper { 5 class SortHelper {
6 6
7 SortHelper(this.sortFunction, this.compareFunction) {} 7 SortHelper(this.sortFunction, this.compareFunction) {}
8 8
9 void run() { 9 void run() {
10 testSortIntLists(); 10 testSortIntLists();
11 testSortDoubleLists(); 11 testSortDoubleLists();
12 } 12 }
13 13
14 void printList(List a) { 14 void printList(List a) {
15 StringBuffer buffer = new StringBuffer(); 15 StringBuffer buffer = new StringBuffer();
16 for (int i = 0; i < a.length; i++) { 16 for (int i = 0; i < a.length; i++) {
17 if (i != 0) buffer.add(","); 17 if (i != 0) buffer.add(",");
18 buffer.add(a[i]); 18 buffer.add(a[i]);
19 } 19 }
20 print("[$buffer]"); 20 print("[$buffer]");
21 } 21 }
22 22
23 void isSorted(List a) { 23 bool isSorted(List a) {
24 for (int i = 1; i < a.length; i++) { 24 for (int i = 1; i < a.length; i++) {
25 if (compareFunction(a[i - 1], a[i]) > 0) { 25 if (compareFunction(a[i - 1], a[i]) > 0) {
26 return false; 26 return false;
27 } 27 }
28 } 28 }
29 return true; 29 return true;
30 } 30 }
31 31
32 void testSortIntLists() { 32 void testSortIntLists() {
33 List a = new List(40); 33 List a = new List(40);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 153
154 for (int i = 0; i < a.length; i++) { 154 for (int i = 0; i < a.length; i++) {
155 a[i] = 1.5; 155 a[i] = 1.5;
156 } 156 }
157 testSort(a); 157 testSort(a);
158 } 158 }
159 159
160 Function sortFunction; 160 Function sortFunction;
161 Function compareFunction; 161 Function compareFunction;
162 } 162 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698