dejagnu
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: PATCH: add support for verifying errors in internal unit tests


From: Ben Elliston
Subject: Re: PATCH: add support for verifying errors in internal unit tests
Date: Sat, 8 Dec 2018 12:44:00 +1100
User-agent: Mutt/1.9.4 (2018-02-28)

On Fri, Dec 07, 2018 at 06:59:01PM -0600, Jacob Bachmeyer wrote:

> +     if { [string match "$pattern" $result] } {
> +         return 1
> +     } else {
> +         return 0
> +     }

This can be simplified to:
     return [string match $pattern $result]

> +     if { [regexp -- $regexp $result] } {
> +         return 1
> +     } else {
> +         return 0
> +     }

Likewise here for [regexp ...].

> +     if { $result eq $val } {
> +         return 1
> +     } else {
> +         return 0
> +     }

This can be simplified to:
     return [string equal $result $val]

> +     if { $val } {
> +         if { $result } { return 1 } else { return 0 }
> +     } else {
> +         if { $result } { return 0 } else { return 1 }
> +     }

This could be simplified to:

     if {$val} {
        return [expr $result != 0]
     } else {
        return [expr $result == 0]
     }

Cherrs,
Ben

Attachment: signature.asc
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]