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

Side by Side Diff: pkg/unittest/test/breath_test.dart

Issue 807193003: Re-apply "Remove unittest and matcher from the repo." (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Code review changes Created 6 years 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
(Empty)
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
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.
4
5 library unittest.breath_test;
6
7 import 'dart:async';
8
9 import 'package:unittest/unittest.dart';
10
11 void main() {
12 // Test the sync test 'breath' feature of unittest.
13
14 // We use the testStartStopwatch to determine if the 'starve'
15 // test was executed within a small enough time interval from
16 // the first test that we are guaranteed the second test is
17 // running in a microtask. If the second test is running as a
18 // microtask we are guaranteed the timer scheduled in the
19 // first test has not been run yet.
20 var testStartStopwatch = new Stopwatch()..start();
21
22 group('breath', () {
23 var sentinel = 0;
24
25 test('initial', () {
26 Timer.run(() {
27 sentinel = 1;
28 });
29 });
30
31 test('starve', () {
32 // If less than BREATH_INTERVAL time has passed since before
33 // we started the test group then the previous test's timer
34 // has not been run (at least this is what we are testing).
35 if (testStartStopwatch.elapsed.inMilliseconds <= BREATH_INTERVAL) {
36 expect(sentinel, 0);
37 }
38
39 // Next we wait for at least BREATH_INTERVAL to guaranteed the
40 // next (third) test is run using a timer which means it will
41 // run after the timer scheduled in the first test and hence
42 // the sentinel should have been set to 1.
43 var sw = new Stopwatch()..start();
44 while (sw.elapsed.inMilliseconds < BREATH_INTERVAL);
45 });
46
47 test('breathed', () {
48 expect(sentinel, 1);
49 });
50 });
51 }
OLDNEW
« no previous file with comments | « pkg/unittest/test/async_setup_teardown_test.dart ('k') | pkg/unittest/test/completion_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698