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

Ben Elliston <[email protected]>
Newsgroups gmane.comp.sysutils.dejagnu.general
Message-ID <20181208014400.GA21709@bapbop>
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

_______________________________________________
DejaGnu mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/dejagnu
signature.asc (application/pgp-signature, 833 B)
-----BEGIN PGP SIGNATURE-----

iQIzBAABCgAdFiEEFS8+rdM1/2KWERKFZ9rcPj90NkkFAlwLId4ACgkQZ9rcPj90
NkmRyw/8C1cscOg8TvIh1IY9stjmzvWckDwr3jhjCLdU6ijFoHEehnVnF4OOFfme
ujyF5SKbBYCrNrGUg1qcIbx3uurzLNYDxTqu0tt5v/o8kMNS36UzJW9uBfONNmBe
0y26h9+Uelh2lmdILyuT9Tt3wX4fxERqZj/g+vHCHsyF5mDmdwO74Vza/hLpKO4f
li4zAVIGJMPWtZnmZuZnZSsHPKhbz2Z2eatb9w7NstiyvR1RBvoI4X1NfGmwwDmy
X/iiuICLXXecKDTJcCdIA2OtOV6hdKq5CYYVE8igKw8qCulqP9jLAVvT+aD2RViK
qJxBbqDt1biyl4sZl7/b//zG3H30d1mqaRF2PsJ9pPWaFf/NsriEk4FMNE/yyrdc
yK2bNOzu3k0MzUwYlDv2XVzq5HhbBoNQjlU6UE815HpbvHRfXE/E5v6D6ASNhoPo
qZjcTzT/vI2kNDer/3sxcZWY3CrBsuCd8HHCSb3oFgEvXVgAeInuXiQAKRrxhFfu
ItOlsKs/5dl+nTKL4FVZsTrZI6C8TgtkfJ/15phiDHJVPHXEivDUBSC3pRT75khh
rRS05h9Im+/4VqX8bQBMs0pHoN5ADjkq3lbT3hcP2oBTaEJcT+OrgZ4t75tD60Hp
l9O+SWHyIpbVscxy4PFIzXEv0FmLcS5wtrmvg/GidMXmqrgopdQ=
=zpWO
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.