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

Side by Side 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, 4 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 | « pkg/logging/pubspec.yaml ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 5
6 library logging_test; 6 library logging_test;
7 7
8 import 'package:logging/logging.dart'; 8 import 'package:logging/logging.dart';
9 import 'package:unittest/unittest.dart'; 9 import 'package:unittest/unittest.dart';
10 10
(...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 // 'FINE: 8' is not loggable 411 // 'FINE: 8' is not loggable
412 'WARNING: 9', 412 'WARNING: 9',
413 'SHOUT: 10'])); 413 'SHOUT: 10']));
414 414
415 expect(cMessages, equals([ 415 expect(cMessages, equals([
416 // 1 - 7 are lower in the hierarchy 416 // 1 - 7 are lower in the hierarchy
417 // 'FINE: 8' is not loggable 417 // 'FINE: 8' is not loggable
418 'WARNING: 9', 418 'WARNING: 9',
419 'SHOUT: 10'])); 419 'SHOUT: 10']));
420 }); 420 });
421
422 test('message logging - lazy functions', () {
423 root.level = Level.INFO;
424 var messages = [];
425 root.onRecord.listen((record) {
426 messages.add('${record.level}: ${record.message}');
427 });
428
429 var callCount = 0;
430 var myClosure = () => "${++callCount}";
431
432 root.info(myClosure);
433 root.finer(myClosure); // Should not get evaluated.
434 root.warning(myClosure);
435
436 expect(messages, equals([
437 'INFO: 1',
438 'WARNING: 2',]));
439 });
440
441 test('message logging - calls toString', () {
442 root.level = Level.INFO;
443 var messages = [];
444 root.onRecord.listen((record) {
445 messages.add('${record.level}: ${record.message}');
446 });
447
448 root.info(5);
449 root.info(false);
450 root.info([1, 2, 3]);
451 root.info(() => 10);
452
453 expect(messages, equals([
454 'INFO: 5',
455 'INFO: false',
456 'INFO: [1, 2, 3]',
457 'INFO: 10',]));
458 });
421 }); 459 });
422 } 460 }
OLDNEW
« 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