| OLD | NEW |
| 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 Loading... |
| 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 } |
| OLD | NEW |