github.com/mem/u-root@v2.0.1-0.20181004165302-9b18b4636a33+incompatible/cmds/elvish/eval/builtin_fn_str_test.go (about) 1 package eval 2 3 import "testing" 4 5 func TestBuiltinFnStr(t *testing.T) { 6 runTests(t, []Test{ 7 That(`==s haha haha`).Puts(true), 8 That(`==s 10 10.0`).Puts(false), 9 That(`<s a b`).Puts(true), 10 That(`<s 2 10`).Puts(false), 11 12 That(`joins : [/usr /bin /tmp]`).Puts("/usr:/bin:/tmp"), 13 That(`joins : ['' a '']`).Puts(":a:"), 14 That(`splits : /usr:/bin:/tmp`).Puts("/usr", "/bin", "/tmp"), 15 That(`splits : /usr:/bin:/tmp &max=2`).Puts("/usr", "/bin:/tmp"), 16 That(`replaces : / ":usr:bin:tmp"`).Puts("/usr/bin/tmp"), 17 That(`replaces &max=2 : / :usr:bin:tmp`).Puts("/usr/bin:tmp"), 18 19 That(`ord a`).Puts("0x61"), 20 That(`base 16 42 233`).Puts("2a", "e9"), 21 That(`base 1 1`).Errors(), // no base-1 22 That(`base 37 10`).Errors(), // no letter for base-37 23 That(`wcswidth 你好`).Puts("4"), 24 That(`-override-wcwidth x 10; wcswidth 1x2x; -override-wcwidth x 1`).Puts("22"), 25 26 That(`has-prefix golang go`).Puts(true), 27 That(`has-prefix golang x`).Puts(false), 28 That(`has-suffix golang x`).Puts(false), 29 30 That(`echo " ax by cz \n11\t22 33" | eawk [@a]{ put $a[-1] }`).Puts( 31 "cz", "33"), 32 }) 33 }