matryer / is

Professional lightweight testing mini-framework for Go.
MIT License
1.78k stars 58 forks source link

Small simplification #46

Open kpym opened 2 years ago

kpym commented 2 years ago

The following code

    if isNil(a) || isNil(b) {
        is.logf("%s != %s", is.valWithType(a), is.valWithType(b))
    } else if reflect.ValueOf(a).Type() == reflect.ValueOf(b).Type() {
        is.logf("%v != %v", a, b)
    } else {
        is.logf("%s != %s", is.valWithType(a), is.valWithType(b))
    }

can be simplified to

        if isNil(a) || isNil(b) || reflect.ValueOf(a).Type() != reflect.ValueOf(b).Type() {
        is.logf("%s != %s", is.valWithType(a), is.valWithType(b))
    } else {
        is.logf("%v != %v", a, b)
    }