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

Unified Diff: tests/corelib_strong/stopwatch_test.dart

Issue 2989473002: Migrated test block 27 to Dart 2.0. (Closed)
Patch Set: Addressed Bob's nits and fixed test failures Created 3 years, 5 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
« no previous file with comments | « tests/corelib_strong/stopwatch2_test.dart ('k') | tests/corelib_strong/string_base_vm_test.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/corelib_strong/stopwatch_test.dart
diff --git a/tests/corelib_strong/stopwatch_test.dart b/tests/corelib_strong/stopwatch_test.dart
deleted file mode 100644
index e6b8a97982120223a83823a909316e7c4e995918..0000000000000000000000000000000000000000
--- a/tests/corelib_strong/stopwatch_test.dart
+++ /dev/null
@@ -1,128 +0,0 @@
-// Copyright (c) 2012, 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.
-
-library stopwatch_test;
-
-import "package:expect/expect.dart";
-
-class StopwatchTest {
- static bool checkTicking(Stopwatch sw) {
- Expect.isFalse(sw.isRunning);
- sw.start();
- Expect.isTrue(sw.isRunning);
- for (int i = 0; i < 1000000; i++) {
- int.parse(i.toString());
- if (sw.elapsedTicks > 0) {
- break;
- }
- }
- return sw.elapsedTicks > 0;
- }
-
- static bool checkStopping(Stopwatch sw) {
- sw.stop();
- Expect.isFalse(sw.isRunning);
- int v1 = sw.elapsedTicks;
- Expect.isTrue(v1 > 0); // Expect a non-zero elapsed time.
- Stopwatch sw2 = new Stopwatch(); // Used for verification.
- sw2.start();
- Expect.isTrue(sw2.isRunning);
- int sw2LastElapsed = 0;
- for (int i = 0; i < 100000; i++) {
- int.parse(i.toString());
- int v2 = sw.elapsedTicks;
- if (v1 != v2) {
- return false;
- }
- // If sw2 elapsed twice then sw must have advanced too if it wasn't
- // stopped.
- if (sw2LastElapsed > 0 && sw2.elapsedTicks > sw2LastElapsed) {
- break;
- }
- sw2LastElapsed = sw2.elapsedTicks;
- }
- // The test only makes sense if measureable time elapsed and elapsed time
- // on the stopped Stopwatch did not increase.
- Expect.isTrue(sw2.elapsedTicks > 0);
- return true;
- }
-
- static checkRestart() {
- Stopwatch sw = new Stopwatch();
- Expect.isFalse(sw.isRunning);
- sw.start();
- Expect.isTrue(sw.isRunning);
- for (int i = 0; i < 100000; i++) {
- int.parse(i.toString());
- if (sw.elapsedTicks > 0) {
- break;
- }
- }
- sw.stop();
- Expect.isFalse(sw.isRunning);
- int initial = sw.elapsedTicks;
- sw.start();
- Expect.isTrue(sw.isRunning);
- for (int i = 0; i < 100000; i++) {
- int.parse(i.toString());
- if (sw.elapsedTicks > initial) {
- break;
- }
- }
- sw.stop();
- Expect.isFalse(sw.isRunning);
- Expect.isTrue(sw.elapsedTicks > initial);
- }
-
- static checkReset() {
- Stopwatch sw = new Stopwatch();
- Expect.isFalse(sw.isRunning);
- sw.start();
- Expect.isTrue(sw.isRunning);
- for (int i = 0; i < 100000; i++) {
- int.parse(i.toString());
- if (sw.elapsedTicks > 0) {
- break;
- }
- }
- sw.stop();
- Expect.isFalse(sw.isRunning);
- sw.reset();
- Expect.isFalse(sw.isRunning);
- Expect.equals(0, sw.elapsedTicks);
- sw.start();
- Expect.isTrue(sw.isRunning);
- for (int i = 0; i < 100000; i++) {
- int.parse(i.toString());
- if (sw.elapsedTicks > 0) {
- break;
- }
- }
- sw.reset();
- Expect.isTrue(sw.isRunning);
- for (int i = 0; i < 100000; i++) {
- int.parse(i.toString());
- if (sw.elapsedTicks > 0) {
- break;
- }
- }
- sw.stop();
- Expect.isFalse(sw.isRunning);
- Expect.isTrue(sw.elapsedTicks > 0);
- }
-
- static testMain() {
- Stopwatch sw = new Stopwatch();
- Expect.isTrue(checkTicking(sw));
- Expect.isTrue(checkStopping(sw));
- checkRestart();
- checkReset();
- }
-}
-
-main() {
- StopwatchTest.testMain();
-}
« no previous file with comments | « tests/corelib_strong/stopwatch2_test.dart ('k') | tests/corelib_strong/string_base_vm_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698