Chromium Code Reviews| OLD | NEW |
|---|---|
| (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:profiler'; | |
| 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); | |
|
koda
2014/07/29 15:34:30
Test setting to out-of-range value.
Cutch
2014/07/29 18:27:01
Done.
| |
| 18 } | |
| 19 | |
| 20 testGauge2() { | |
| 21 var gauge = new Gauge('test', 'alpha bravo', 1.0, 2.0); | |
| 22 Expect.equals(1.0, gauge.min); | |
| 23 Expect.equals(2.0, gauge.max); | |
| 24 Expect.equals(gauge.min, gauge.value); | |
| 25 Expect.equals('test', gauge.name); | |
| 26 Expect.equals('alpha bravo', gauge.description); | |
| 27 | |
| 28 Expect.throws(() { | |
| 29 // min > max. | |
| 30 gauge = new Gauge.range('test', 'alpha bravo', 2.0, 1.0); | |
| 31 }); | |
| 32 | |
| 33 Expect.throws(() { | |
| 34 // min == max. | |
| 35 gauge = new Gauge.range('test', 'alpha bravo', 1.0, 1.0); | |
| 36 }); | |
| 37 | |
| 38 Expect.throws(() { | |
| 39 // min is null | |
| 40 gauge = new Gauge.range('test', 'alpha bravo', null, 1.0); | |
| 41 }); | |
| 42 | |
| 43 Expect.throws(() { | |
| 44 // min is not a double | |
| 45 gauge = new Gauge.range('test', 'alpha bravo', 'string', 1.0); | |
| 46 }); | |
| 47 | |
| 48 Expect.throws(() { | |
| 49 // max is null | |
| 50 gauge = new Gauge.range('test', 'alpha bravo', 1.0, null); | |
| 51 }); | |
| 52 | |
| 53 Expect.throws(() { | |
| 54 // max is not a double | |
| 55 gauge = new Gauge.range('test', 'alpha bravo', 1.0, 4); | |
| 56 }); | |
| 57 } | |
| 58 | |
| 59 testCounter() { | |
| 60 var counter = new Counter('test', 'alpha bravo'); | |
| 61 Expect.equals(0.0, counter.value); | |
| 62 Expect.equals('test', counter.name); | |
| 63 Expect.equals('alpha bravo', counter.description); | |
| 64 counter.value = 1.0; | |
| 65 Expect.equals(1.0, counter.value); | |
| 66 } | |
| 67 | |
| 68 class CustomCounter extends Counter { | |
| 69 CustomCounter(name, description) : super(name, description); | |
| 70 // User provided getter. | |
| 71 double get value => 77.0; | |
| 72 } | |
| 73 | |
| 74 testCustomCounter() { | |
| 75 var counter = new CustomCounter('test', 'alpha bravo'); | |
| 76 Expect.equals(77.0, counter.value); | |
| 77 Expect.equals('test', counter.name); | |
| 78 Expect.equals('alpha bravo', counter.description); | |
| 79 // Should have no effect. | |
| 80 counter.value = 1.0; | |
| 81 Expect.equals(77.0, counter.value); | |
| 82 } | |
| 83 | |
| 84 main() { | |
| 85 testGauge1(); | |
| 86 testGauge2(); | |
| 87 testCounter(); | |
| 88 testCustomCounter(); | |
| 89 } | |
| OLD | NEW |