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

Side by Side Diff: tests/lib/developer/metrics_test.dart

Issue 1138993005: Revert 45783 (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 5 years, 7 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 | « tests/lib/developer/metrics_num_test.dart ('k') | tests/lib/developer/user_tags_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) 2014, 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
6 import 'dart:developer';
7 import 'package:expect/expect.dart';
8
9 testGauge1() {
10 var gauge = new Gauge('test', 'alpha bravo', 0.0, 100.0);
11 Expect.equals(0.0, gauge.min);
12 Expect.equals(0.0, gauge.value);
13 Expect.equals(100.0, gauge.max);
14 Expect.equals('test', gauge.name);
15 Expect.equals('alpha bravo', gauge.description);
16 gauge.value = 44.0;
17 Expect.equals(44.0, gauge.value);
18 // Test setting below min.
19 gauge.value = -1.0;
20 Expect.equals(0.0, gauge.value);
21 // Test setting above max.
22 gauge.value = 101.0;
23 Expect.equals(100.0, gauge.value);
24 }
25
26 testGauge2() {
27 var gauge = new Gauge('test', 'alpha bravo', 1.0, 2.0);
28 Expect.equals(1.0, gauge.min);
29 Expect.equals(2.0, gauge.max);
30 Expect.equals(gauge.min, gauge.value);
31 Expect.equals('test', gauge.name);
32 Expect.equals('alpha bravo', gauge.description);
33
34 Expect.throws(() {
35 // min argument > max argument .
36 gauge = new Gauge('test', 'alpha bravo', 2.0, 1.0);
37 });
38
39 Expect.throws(() {
40 // min argument == max argument .
41 gauge = new Gauge('test', 'alpha bravo', 1.0, 1.0);
42 });
43
44 Expect.throws(() {
45 // min argument is null
46 gauge = new Gauge('test', 'alpha bravo', null, 1.0);
47 });
48
49 Expect.throws(() {
50 // min argument is not a double
51 gauge = new Gauge('test', 'alpha bravo', 'string', 1.0);
52 });
53
54 Expect.throws(() {
55 // max argument is null
56 gauge = new Gauge('test', 'alpha bravo', 1.0, null);
57 });
58 }
59
60 testCounter() {
61 var counter = new Counter('test', 'alpha bravo');
62 Expect.equals(0.0, counter.value);
63 Expect.equals('test', counter.name);
64 Expect.equals('alpha bravo', counter.description);
65 counter.value = 1.0;
66 Expect.equals(1.0, counter.value);
67 }
68
69 class CustomCounter extends Counter {
70 CustomCounter(name, description) : super(name, description);
71 // User provided getter.
72 double get value => 77.0;
73 }
74
75 testCustomCounter() {
76 var counter = new CustomCounter('test', 'alpha bravo');
77 Expect.equals(77.0, counter.value);
78 Expect.equals('test', counter.name);
79 Expect.equals('alpha bravo', counter.description);
80 // Should have no effect.
81 counter.value = 1.0;
82 Expect.equals(77.0, counter.value);
83 }
84
85 testMetricNameCollision() {
86 var counter = new Counter('a.b.c', 'alpha bravo charlie');
87 var counter2 = new Counter('a.b.c', 'alpha bravo charlie collider');
88 Metrics.register(counter);
89 Expect.throws(() {
90 Metrics.register(counter2);
91 });
92 Metrics.deregister(counter);
93 Metrics.register(counter);
94 var counter3 = new Counter('a.b.c.d', '');
95 Metrics.register(counter3);
96 }
97
98 testBadName() {
99 Expect.throws(() {
100 var counter = new Counter('a.b/c', 'description');
101 });
102 Expect.throws(() {
103 var counter = new Counter('vm', 'description');
104 });
105 }
106
107 main() {
108 testGauge1();
109 testGauge2();
110 testCounter();
111 testCustomCounter();
112 testMetricNameCollision();
113 testBadName();
114 }
OLDNEW
« no previous file with comments | « tests/lib/developer/metrics_num_test.dart ('k') | tests/lib/developer/user_tags_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698