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

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

Issue 8537011: Rename StopWatch to Stopwatch. Add new Stopwatch.start() and Stopwatch.reset(). (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Move break on new line. 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 side-by-side diff with in-line comments
Download patch
Index: tests/corelib/src/StopWatchTest.dart
diff --git a/tests/corelib/src/StopWatchTest.dart b/tests/corelib/src/StopWatchTest.dart
deleted file mode 100644
index 2b47cba58f0003acaa20d020cfae3f6758d8ddc2..0000000000000000000000000000000000000000
--- a/tests/corelib/src/StopWatchTest.dart
+++ /dev/null
@@ -1,65 +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.
-
-// Dart test program for testing stopwatch support.
-
-class StopWatchTest {
- static bool checkTicking(StopWatch sw) {
- sw.start();
- for (int i = 0; i < 10000; i++) {
- Math.parseInt(i.toString());
- if (sw.elapsed() > 0) {
- break;
- }
- }
- return sw.elapsed() > 0;
- }
-
- static bool checkStopping(StopWatch sw) {
- sw.stop();
- int v1 = sw.elapsed();
- Expect.isTrue(v1 > 0); // Expect a non-zero elapsed time.
- StopWatch sw2 = new StopWatch(); // Used for verification.
- sw2.start();
- for (int i = 0; i < 10000; i++) {
- Math.parseInt(i.toString());
- int v2 = sw.elapsed();
- if (v1 != v2) {
- return false;
- }
- v1 = v2;
- }
- // The test only makes sense if measureable time elapsed and elapsed time
- // on the stopped StopWatch did not increase.
- Expect.isTrue(sw2.elapsed() > 0);
- return true;
- }
-
- static checkRestart() {
- StopWatch sw = new StopWatch();
- sw.start();
- for (int i = 0; i < 1000; i++) {
- Math.parseInt(i.toString());
- }
- sw.stop();
- int initial = sw.elapsed();
- sw.start();
- for (int i = 0; i < 10; i++) {
- Math.parseInt(i.toString());
- }
- sw.stop();
- Expect.isTrue(sw.elapsed() >= initial);
- }
-
- static testMain() {
- StopWatch sw = new StopWatch();
- Expect.isTrue(checkTicking(sw));
- Expect.isTrue(checkStopping(sw));
- checkRestart();
- }
-}
-
-main() {
- StopWatchTest.testMain();
-}

Powered by Google App Engine
This is Rietveld 408576698