@@ -21,8 +21,9 @@ class FruitEvent implements Trackable {
21
21
final LogicValue apple;
22
22
final String banana;
23
23
final int carrot;
24
+ final String ? pear;
24
25
25
- FruitEvent (this .apple, this .banana, this .carrot);
26
+ FruitEvent (this .apple, this .banana, this .carrot, this .pear );
26
27
27
28
@override
28
29
String ? trackerString (TrackerField field) {
@@ -35,6 +36,8 @@ class FruitEvent implements Trackable {
35
36
return carrot.toString ();
36
37
case 'Durian' :
37
38
return (carrot * 2 ).toRadixString (16 );
39
+ case 'Pear' :
40
+ return pear;
38
41
}
39
42
return null ;
40
43
}
@@ -48,17 +51,22 @@ void main() {
48
51
const TrackerField ('Apple' , columnWidth: 10 ),
49
52
const TrackerField ('Banana' , columnWidth: 5 ),
50
53
const TrackerField ('Carrot' , columnWidth: 12 , justify: Justify .center),
51
- const TrackerField ('Durian' , columnWidth: 12 , mapOnly: true )
54
+ const TrackerField ('Durian' , columnWidth: 12 , mapOnly: true ),
55
+ const TrackerField ('Pear' , columnWidth: 12 )
52
56
],
53
57
)
54
- ..record (FruitEvent (LogicValue .ofString ('1x0' ), 'banana' , 25 ))
55
58
..record (
56
- FruitEvent (LogicValue .ofString ('1x01111000011010101' ), 'aaa' , 5 ));
59
+ FruitEvent (LogicValue .ofString ('1x0' ), 'banana' , 25 , 'green pear' ),
60
+ defaults: {'Pear' : 'red pear' })
61
+ ..record (
62
+ FruitEvent (
63
+ LogicValue .ofString ('1x01111000011010101' ), 'aaa' , 5 , null ),
64
+ defaults: {'Pear' : 'red pear' });
57
65
58
66
// Expect JSON log to look like:
59
67
// {"records":[
60
- // {"Apple": "3'b1x0", "Banana": "banana", "Carrot": "25", "Durian": "32"}
61
- // , {"Apple": "19'b1x01111000011010101", "Banana": "aaa", "Carrot": "4", "Durian": "8"}
68
+ // {"Apple": "3'b1x0", "Banana": "banana", "Carrot": "25", "Durian": "32", "Pear": "green pear" }
69
+ // , {"Apple": "19'b1x01111000011010101", "Banana": "aaa", "Carrot": "4", "Durian": "8", "Pear": "red pear" }
62
70
// ]}
63
71
64
72
await tracker.terminate ();
@@ -68,22 +76,24 @@ void main() {
68
76
expect (jsonOutput['records' ].length, equals (2 ));
69
77
expect (jsonOutput['records' ][0 ]['Banana' ], equals ('banana' ));
70
78
expect (jsonOutput['records' ][1 ]['Durian' ], equals ('a' ));
79
+ expect (jsonOutput['records' ][0 ]['Pear' ], equals ('green pear' ));
80
+ expect (jsonOutput['records' ][1 ]['Pear' ], equals ('red pear' ));
71
81
72
82
// Expect table log to look like:
73
- // ---------------------------------------
74
- // | A | B | C |
75
- // | P | A | A |
76
- // | P | N | R |
77
- // | L | A | R |
78
- // | E | N | O |
79
- // | | A | T |
80
- // ---------------------------------------
81
- // | 3'b1x0 | bana* | 25 | {Apple: 3'b1x0, Banana: banana, Carrot: 25, Durian: 32}
82
- // | 19'b1x011* | aaa | 5 | {Apple: 19'b1x01111000011010101, Banana: aaa, Carrot: 5, Durian: a}
83
+ // --------------- ---------------------------------------
84
+ // | A | B | C | P |
85
+ // | P | A | A | E |
86
+ // | P | N | R | A |
87
+ // | L | A | R | R |
88
+ // | E | N | O | |
89
+ // | | A | T | |
90
+ // --------------- ---------------------------------------
91
+ // | 3'b1x0 | bana* | 25 | green pear | {Apple: 3'b1x0, Banana: banana, Carrot: 25, Durian: 32, Pear: green pear }
92
+ // | 19'b1x011* | aaa | 5 | red pear | {Apple: 19'b1x01111000011010101, Banana: aaa, Carrot: 5, Durian: a, Pear: red pear }
83
93
84
94
final logOutput = File (tracker.tableFileName).readAsStringSync ();
85
95
expect (logOutput.contains ('bana*' ), equals (true ));
86
- expect (logOutput.split ('\n ' )[1 ].split ('|' ).length, equals (5 ));
96
+ expect (logOutput.split ('\n ' )[1 ].split ('|' ).length, equals (6 ));
87
97
88
98
File (tracker.jsonFileName).deleteSync ();
89
99
File (tracker.tableFileName).deleteSync ();
0 commit comments