| 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('../../../lib/logging/logging.dart'); | 8 #import('../../../lib/logging/logging.dart'); |
| 9 #import('../../../lib/unittest/unittest.dart'); | 9 #import('../../../lib/unittest/unittest.dart'); |
| 10 | 10 |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 | 58 |
| 59 test('levels are hashable', () { | 59 test('levels are hashable', () { |
| 60 var map = new Map<Level, String>(); | 60 var map = new Map<Level, String>(); |
| 61 map[Level.INFO] = 'info'; | 61 map[Level.INFO] = 'info'; |
| 62 map[Level.SHOUT] = 'shout'; | 62 map[Level.SHOUT] = 'shout'; |
| 63 expect(map[Level.INFO], equals('info')); | 63 expect(map[Level.INFO], equals('info')); |
| 64 expect(map[Level.SHOUT], equals('shout')); | 64 expect(map[Level.SHOUT], equals('shout')); |
| 65 }); | 65 }); |
| 66 | 66 |
| 67 test('logger name cannot start with a "." ', () { | 67 test('logger name cannot start with a "." ', () { |
| 68 expectThrow(() => new Logger('.c')); | 68 expect(() => new Logger('.c'), throws); |
| 69 }); | 69 }); |
| 70 | 70 |
| 71 test('logger naming is hierarchical', () { | 71 test('logger naming is hierarchical', () { |
| 72 Logger c = new Logger('a.b.c'); | 72 Logger c = new Logger('a.b.c'); |
| 73 expect(c.name, equals('c')); | 73 expect(c.name, equals('c')); |
| 74 expect(c.parent.name, equals('b')); | 74 expect(c.parent.name, equals('b')); |
| 75 expect(c.parent.parent.name, equals('a')); | 75 expect(c.parent.parent.name, equals('a')); |
| 76 expect(c.parent.parent.parent.name, equals('')); | 76 expect(c.parent.parent.parent.name, equals('')); |
| 77 expect(c.parent.parent.parent.parent, isNull); | 77 expect(c.parent.parent.parent.parent, isNull); |
| 78 }); | 78 }); |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 a.on.record.clear(); | 127 a.on.record.clear(); |
| 128 b.on.record.clear(); | 128 b.on.record.clear(); |
| 129 c.on.record.clear(); | 129 c.on.record.clear(); |
| 130 d.on.record.clear(); | 130 d.on.record.clear(); |
| 131 e.on.record.clear(); | 131 e.on.record.clear(); |
| 132 hierarchicalLoggingEnabled = false; | 132 hierarchicalLoggingEnabled = false; |
| 133 root.level = Level.INFO; | 133 root.level = Level.INFO; |
| 134 }); | 134 }); |
| 135 | 135 |
| 136 test('cannot set level if hierarchy is disabled', () { | 136 test('cannot set level if hierarchy is disabled', () { |
| 137 expectThrow(() {a.level = Level.FINE;}); | 137 expect(() {a.level = Level.FINE;}, throws); |
| 138 }); | 138 }); |
| 139 | 139 |
| 140 test('loggers effective level - no hierarchy', () { | 140 test('loggers effective level - no hierarchy', () { |
| 141 expect(root.level, equals(Level.INFO)); | 141 expect(root.level, equals(Level.INFO)); |
| 142 expect(a.level, equals(Level.INFO)); | 142 expect(a.level, equals(Level.INFO)); |
| 143 expect(b.level, equals(Level.INFO)); | 143 expect(b.level, equals(Level.INFO)); |
| 144 | 144 |
| 145 root.level = Level.SHOUT; | 145 root.level = Level.SHOUT; |
| 146 | 146 |
| 147 expect(root.level, equals(Level.SHOUT)); | 147 expect(root.level, equals(Level.SHOUT)); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 327 'SHOUT: 10'])); | 327 'SHOUT: 10'])); |
| 328 | 328 |
| 329 expect(cMessages, equals([ | 329 expect(cMessages, equals([ |
| 330 // 1 - 7 are lower in the hierarchy | 330 // 1 - 7 are lower in the hierarchy |
| 331 // 'FINE: 8' is not loggable | 331 // 'FINE: 8' is not loggable |
| 332 'WARNING: 9', | 332 'WARNING: 9', |
| 333 'SHOUT: 10'])); | 333 'SHOUT: 10'])); |
| 334 }); | 334 }); |
| 335 }); | 335 }); |
| 336 } | 336 } |
| OLD | NEW |