mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-05 03:17:50 +08:00
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package eval_test
|
|
|
|
import (
|
|
"testing"
|
|
|
|
. "github.com/elves/elvish/pkg/eval/evaltest"
|
|
)
|
|
|
|
func TestBool(t *testing.T) {
|
|
Test(t,
|
|
That(`bool $true`).Puts(true),
|
|
That(`bool a`).Puts(true),
|
|
That(`bool [a]`).Puts(true),
|
|
// "Empty" values are also true in Elvish
|
|
That(`bool []`).Puts(true),
|
|
That(`bool [&]`).Puts(true),
|
|
That(`bool 0`).Puts(true),
|
|
That(`bool ""`).Puts(true),
|
|
// Only errors and $false are false
|
|
That(`bool ?(fail x)`).Puts(false),
|
|
That(`bool $false`).Puts(false),
|
|
|
|
That(`not $false`).Puts(true),
|
|
That(`not ?(fail x)`).Puts(true),
|
|
That(`not $true`).Puts(false),
|
|
That(`not 0`).Puts(false),
|
|
|
|
That(`is 1 1`).Puts(true),
|
|
That(`is a b`).Puts(false),
|
|
That(`is [] []`).Puts(true),
|
|
That(`is [1] [1]`).Puts(false),
|
|
|
|
That(`eq 1 1`).Puts(true),
|
|
That(`eq a b`).Puts(false),
|
|
That(`eq [] []`).Puts(true),
|
|
That(`eq [1] [1]`).Puts(true),
|
|
That(`eq 1 1 2`).Puts(false),
|
|
|
|
That(`not-eq a b`).Puts(true),
|
|
That(`not-eq a a`).Puts(false),
|
|
// not-eq is true as long as each adjacent pair is not equal.
|
|
That(`not-eq 1 2 1`).Puts(true),
|
|
)
|
|
}
|