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

Side by Side Diff: pkg/unittest/lib/src/test_case.dart

Issue 11770004: Rename Date to DateTime. (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Address comments and keep Backwards-compatibility class Date. Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « pkg/unittest/lib/mock.dart ('k') | pkg/unittest/test/mock_test.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 /** 5 /**
6 * testcase.dart: this file is sourced by unittest.dart. It defines [TestCase] 6 * testcase.dart: this file is sourced by unittest.dart. It defines [TestCase]
7 * and assumes unittest defines the type [TestFunction]. 7 * and assumes unittest defines the type [TestFunction].
8 */ 8 */
9 9
10 /** Summarizes information about a single test case. */ 10 /** Summarizes information about a single test case. */
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 * One of [PASS], [FAIL], [ERROR], or [null] if the test hasn't run yet. 46 * One of [PASS], [FAIL], [ERROR], or [null] if the test hasn't run yet.
47 */ 47 */
48 String result; 48 String result;
49 49
50 /** Stack trace associated with this test, or null if it succeeded. */ 50 /** Stack trace associated with this test, or null if it succeeded. */
51 String stackTrace; 51 String stackTrace;
52 52
53 /** The group (or groups) under which this test is running. */ 53 /** The group (or groups) under which this test is running. */
54 final String currentGroup; 54 final String currentGroup;
55 55
56 Date startTime; 56 DateTime startTime;
57 57
58 Duration runningTime; 58 Duration runningTime;
59 59
60 bool enabled = true; 60 bool enabled = true;
61 61
62 bool _doneTeardown = false; 62 bool _doneTeardown = false;
63 63
64 TestCase(this.id, this.description, this.test, 64 TestCase(this.id, this.description, this.test,
65 this.callbackFunctionsOutstanding) 65 this.callbackFunctionsOutstanding)
66 : currentGroup = _currentGroup, 66 : currentGroup = _currentGroup,
67 _setUp = _testSetup, 67 _setUp = _testSetup,
68 _tearDown = _testTeardown; 68 _tearDown = _testTeardown;
69 69
70 bool get isComplete => !enabled || result != null; 70 bool get isComplete => !enabled || result != null;
71 71
72 void run() { 72 void run() {
73 if (enabled) { 73 if (enabled) {
74 result = stackTrace = null; 74 result = stackTrace = null;
75 message = ''; 75 message = '';
76 _doneTeardown = false; 76 _doneTeardown = false;
77 if (_setUp != null) { 77 if (_setUp != null) {
78 _setUp(); 78 _setUp();
79 } 79 }
80 _config.onTestStart(this); 80 _config.onTestStart(this);
81 startTime = new Date.now(); 81 startTime = new DateTime.now();
82 runningTime = null; 82 runningTime = null;
83 test(); 83 test();
84 } 84 }
85 } 85 }
86 86
87 void _complete() { 87 void _complete() {
88 if (runningTime == null) { 88 if (runningTime == null) {
89 // TODO(gram): currently the duration measurement code is blocked 89 // TODO(gram): currently the duration measurement code is blocked
90 // by issue 4437. When that is fixed replace the line below with: 90 // by issue 4437. When that is fixed replace the line below with:
91 // runningTime = new Date.now().difference(startTime); 91 // runningTime = new DateTime.now().difference(startTime);
92 runningTime = new Duration(milliseconds: 0); 92 runningTime = new Duration(milliseconds: 0);
93 } 93 }
94 if (!_doneTeardown) { 94 if (!_doneTeardown) {
95 if (_tearDown != null) { 95 if (_tearDown != null) {
96 _tearDown(); 96 _tearDown();
97 } 97 }
98 _doneTeardown = true; 98 _doneTeardown = true;
99 } 99 }
100 _config.onTestResult(this); 100 _config.onTestResult(this);
101 } 101 }
(...skipping 18 matching lines...) Expand all
120 } 120 }
121 } 121 }
122 122
123 void error(String messageText, [String stack = '']) { 123 void error(String messageText, [String stack = '']) {
124 result = ERROR; 124 result = ERROR;
125 message = messageText; 125 message = messageText;
126 stackTrace = stack; 126 stackTrace = stack;
127 _complete(); 127 _complete();
128 } 128 }
129 } 129 }
OLDNEW
« no previous file with comments | « pkg/unittest/lib/mock.dart ('k') | pkg/unittest/test/mock_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698