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

Unified Diff: pkg/logging/test/logging_test.dart

Issue 420553007: updated logging package to accept functions or other non-string objects when logging (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: "bump version and add example for logging with a closure" Created 6 years, 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/logging/pubspec.yaml ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/logging/test/logging_test.dart
diff --git a/pkg/logging/test/logging_test.dart b/pkg/logging/test/logging_test.dart
index 82ef3e12adaa4d04906181e4f85e9278250897c6..223498f0a1707b4ae93accfdc9fa4803717be98b 100644
--- a/pkg/logging/test/logging_test.dart
+++ b/pkg/logging/test/logging_test.dart
@@ -418,5 +418,43 @@ main() {
'WARNING: 9',
'SHOUT: 10']));
});
+
+ test('message logging - lazy functions', () {
+ root.level = Level.INFO;
+ var messages = [];
+ root.onRecord.listen((record) {
+ messages.add('${record.level}: ${record.message}');
+ });
+
+ var callCount = 0;
+ var myClosure = () => "${++callCount}";
+
+ root.info(myClosure);
+ root.finer(myClosure); // Should not get evaluated.
+ root.warning(myClosure);
+
+ expect(messages, equals([
+ 'INFO: 1',
+ 'WARNING: 2',]));
+ });
+
+ test('message logging - calls toString', () {
+ root.level = Level.INFO;
+ var messages = [];
+ root.onRecord.listen((record) {
+ messages.add('${record.level}: ${record.message}');
+ });
+
+ root.info(5);
+ root.info(false);
+ root.info([1, 2, 3]);
+ root.info(() => 10);
+
+ expect(messages, equals([
+ 'INFO: 5',
+ 'INFO: false',
+ 'INFO: [1, 2, 3]',
+ 'INFO: 10',]));
+ });
});
}
« no previous file with comments | « pkg/logging/pubspec.yaml ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698