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

Side by Side Diff: test/frontend/timeout_test.dart

Issue 1604043003: Add support for a timeout flag. (Closed) Base URL: git@github.com:dart-lang/test@master
Patch Set: Code review changes Created 4 years, 10 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
« no previous file with comments | « pubspec.yaml ('k') | test/runner/runner_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
(Empty)
1 // Copyright (c) 2016, 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 import 'dart:async';
6
7 import 'package:test/src/backend/state.dart';
8 import 'package:test/test.dart';
9
10 void main() {
11 group("Timeout.parse", () {
12 group('for "none"', () {
13 test("successfully parses", () {
14 expect(new Timeout.parse("none"), equals(Timeout.none));
15 });
16
17 test("rejects invalid input", () {
18 expect(() => new Timeout.parse(" none"), throwsFormatException);
19 expect(() => new Timeout.parse("none "), throwsFormatException);
20 expect(() => new Timeout.parse("xnone"), throwsFormatException);
21 expect(() => new Timeout.parse("nonex"), throwsFormatException);
22 expect(() => new Timeout.parse("noxe"), throwsFormatException);
23 });
24 });
25
26 group("for a relative timeout", () {
27 test("successfully parses", () {
28 expect(new Timeout.parse("1x"), equals(new Timeout.factor(1)));
29 expect(new Timeout.parse("2.5x"), equals(new Timeout.factor(2.5)));
30 expect(new Timeout.parse("1.2e3x"), equals(new Timeout.factor(1.2e3)));
31 });
32
33 test("rejects invalid input", () {
34 expect(() => new Timeout.parse(".x"), throwsFormatException);
35 expect(() => new Timeout.parse("x"), throwsFormatException);
36 expect(() => new Timeout.parse("ax"), throwsFormatException);
37 expect(() => new Timeout.parse("1x "), throwsFormatException);
38 expect(() => new Timeout.parse("1x5m"), throwsFormatException);
39 });
40 });
41
42 group("for an absolute timeout", () {
43 test("successfully parses all supported units", () {
44 expect(new Timeout.parse("2d"),
45 equals(new Timeout(new Duration(days: 2))));
46 expect(new Timeout.parse("2h"),
47 equals(new Timeout(new Duration(hours: 2))));
48 expect(new Timeout.parse("2m"),
49 equals(new Timeout(new Duration(minutes: 2))));
50 expect(new Timeout.parse("2s"),
51 equals(new Timeout(new Duration(seconds: 2))));
52 expect(new Timeout.parse("2ms"),
53 equals(new Timeout(new Duration(milliseconds: 2))));
54 expect(new Timeout.parse("2us"),
55 equals(new Timeout(new Duration(microseconds: 2))));
56 });
57
58 test("supports non-integer units", () {
59 expect(new Timeout.parse("2.73d"),
60 equals(new Timeout(new Duration(days: 1) * 2.73)));
61 });
62
63 test("supports multiple units", () {
64 expect(new Timeout.parse("1d 2h3m 4s5ms\t6us"),
65 equals(new Timeout(new Duration(
66 days: 1,
67 hours: 2,
68 minutes: 3,
69 seconds: 4,
70 milliseconds: 5,
71 microseconds: 6))));
72 });
73
74 test("rejects invalid input", () {
75 expect(() => new Timeout.parse(".d"), throwsFormatException);
76 expect(() => new Timeout.parse("d"), throwsFormatException);
77 expect(() => new Timeout.parse("ad"), throwsFormatException);
78 expect(() => new Timeout.parse("1z"), throwsFormatException);
79 expect(() => new Timeout.parse("1u"), throwsFormatException);
80 expect(() => new Timeout.parse("1d5x"), throwsFormatException);
81 expect(() => new Timeout.parse("1d*5m"), throwsFormatException);
82 });
83 });
84 });
85 }
OLDNEW
« no previous file with comments | « pubspec.yaml ('k') | test/runner/runner_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698