Skip to content

Commit 51ef8b6

Browse files
log: cleanup tests (#15320)
1 parent 867f500 commit 51ef8b6

File tree

1 file changed

+7
-18
lines changed

1 file changed

+7
-18
lines changed

vlib/log/log_test.v

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -19,18 +19,23 @@ fn log_mutable_statements(mut log Log) {
1919

2020
fn logger_mutable_statements(mut log Logger) {
2121
println(@FN + ' start')
22+
// the given logger instance could have a level to filter some levels used here
2223
log.info('info')
2324
log.warn('warn')
2425
log.error('error')
2526
log.debug('no output for debug')
26-
// log.set_level(.debug) // not usable here because not part of Logger interface
27+
log.set_level(.debug) // change logging level, now part of the Logger interface
28+
log.debug('output for debug now')
29+
log.info('output for info now')
2730
println(@FN + ' end')
2831
}
2932

3033
fn delay() {
3134
time.sleep(1 * time.second)
3235
}
3336

37+
// Note that Log and Logger methods requires a mutable instance
38+
3439
// new_log create and return a new Log reference
3540
pub fn new_log() &Log {
3641
return &Log{
@@ -54,22 +59,6 @@ fn test_log_mutable() {
5459
println(@FN + ' end')
5560
}
5661

57-
/*
58-
// TODO: with Logger methods requiring a mutable instance, now I get a compilation error: `l` is immutable, declare it with `mut` to make it mutable ... check if it's good the same now and/or what to do ... wip
59-
fn test_log_not_mutable() {
60-
println(@FN + ' start')
61-
l := log.Log{}
62-
63-
l.info('info')
64-
l.warn('warn')
65-
l.error('error')
66-
l.debug('no output for debug')
67-
68-
assert true
69-
println(@FN + ' end')
70-
}
71-
*/
72-
7362
fn test_log_mutable_reference() {
7463
println(@FN + ' start')
7564
mut log := new_log()
@@ -84,7 +73,7 @@ fn test_logger_mutable_reference() {
8473
println(@FN + ' start')
8574
// get log as Logger and use it
8675
mut logger := new_log_as_logger()
87-
logger.set_level(.debug)
76+
logger.set_level(.warn)
8877
assert typeof(logger).name == '&log.Logger'
8978
go logger_mutable_statements(mut logger)
9079
delay() // wait to finish

0 commit comments

Comments
 (0)