Index: tests/lib/profiler/metrics_test.dart |
diff --git a/tests/lib/profiler/metrics_test.dart b/tests/lib/profiler/metrics_test.dart |
new file mode 100644 |
index 0000000000000000000000000000000000000000..ec74233b7e2637666e210c513c92daafc50aa76a |
--- /dev/null |
+++ b/tests/lib/profiler/metrics_test.dart |
@@ -0,0 +1,83 @@ |
+// Copyright (c) 2014, 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. |
+// |
+ |
+import 'dart:profiler'; |
+import 'package:expect/expect.dart'; |
+ |
+testGauge() { |
+ var gauge = new Gauge('test', 'alpha bravo'); |
+ Expect.equals(0.0, gauge.value); |
+ Expect.equals('test', gauge.name); |
+ Expect.equals('alpha bravo', gauge.description); |
+ Expect.equals(null, gauge.min); |
+ Expect.equals(null, gauge.max); |
+ gauge.value = 44.0; |
+ Expect.equals(44.0, gauge.value); |
+} |
+ |
+testGaugeRange() { |
+ var gauge = new Gauge.range('test', 'alpha bravo', 1.0, 2.0); |
+ Expect.equals(0.0, gauge.value); |
+ Expect.equals('test', gauge.name); |
+ Expect.equals('alpha bravo', gauge.description); |
+ Expect.equals(1.0, gauge.min); |
+ Expect.equals(2.0, gauge.max); |
+ |
+ Expect.throws(() { |
+ // min > max. |
+ gauge = new Gauge.range('test', 'alpha bravo', 2.0, 1.0); |
+ }); |
+ |
+ Expect.throws(() { |
+ // min == max. |
+ gauge = new Gauge.range('test', 'alpha bravo', 1.0, 1.0); |
+ }); |
+ |
+ Expect.throws(() { |
+ // min == max. |
+ gauge = new Gauge.range('test', 'alpha bravo', 1.0, 1.0); |
+ }); |
+ |
+ Expect.throws(() { |
+ // min is null |
+ gauge = new Gauge.range('test', 'alpha bravo', null, 1.0); |
+ }); |
+ |
+ Expect.throws(() { |
+ // min is not a double |
+ gauge = new Gauge.range('test', 'alpha bravo', 'string', 1.0); |
+ }); |
+ |
+ Expect.throws(() { |
+ // max is null |
+ gauge = new Gauge.range('test', 'alpha bravo', 1.0, null); |
+ }); |
+ |
+ Expect.throws(() { |
+ // max is not a double |
+ gauge = new Gauge.range('test', 'alpha bravo', 1.0, 4); |
+ }); |
+ |
+ Expect.equals(0.0, gauge.value); |
+ Expect.equals('test', gauge.name); |
+ Expect.equals('alpha bravo', gauge.description); |
+ Expect.equals(1.0, gauge.min); |
+ Expect.equals(2.0, gauge.max); |
+} |
+ |
+testCounter() { |
+ var counter = new Counter('test', 'alpha bravo'); |
+ Expect.equals(0.0, counter.value); |
+ Expect.equals('test', counter.name); |
+ Expect.equals('alpha bravo', counter.description); |
+ counter.add(1.0); |
+ Expect.equals(1.0, counter.value); |
+} |
+ |
+main() { |
+ testGauge(); |
+ testGaugeRange(); |
+ testCounter(); |
+} |