src.elv.sh@v0.21.0-dev.0.20240515223629-06979efb9a2a/pkg/eval/builtin_ns_test.elvts (about) 1 /////////////////////////////////////////////////////// 2 # builtin module may be used implicitly or explicitly # 3 /////////////////////////////////////////////////////// 4 5 ~> put $true 6 ▶ $true 7 // regression test for b.elv.sh/1414 8 ~> use builtin 9 put $builtin:true 10 ▶ $true 11 12 /////////////////////////////////// 13 # builtin functions are read-only # 14 /////////////////////////////////// 15 16 ~> set return~ = { } 17 Compilation error: variable $return~ is read-only 18 [tty]:1:5-11: set return~ = { } 19 20 ////////// 21 # $paths # 22 ////////// 23 24 //each:unset-env PATH 25 26 ## $E:PATH to $paths ## 27 ~> use path 28 ~> set E:PATH = /bin1$path:list-separator/bin2 29 ~> put $paths 30 ▶ [/bin1 /bin2] 31 32 ## $paths to $E:PATH ## 33 ~> use path 34 ~> set paths = [/bin1 /bin2] 35 ~> eq $E:PATH /bin1$path:list-separator/bin2 36 ▶ $true 37 38 ## invalid values ## 39 ~> set paths = [$true] 40 Exception: path must be string 41 [tty]:1:5-9: set paths = [$true] 42 ~> set paths = ["/invalid:;path"] 43 Exception: path cannot contain NUL byte, colon on Unix or semicolon on Windows 44 [tty]:1:5-9: set paths = ["/invalid:;path"] 45 ~> set paths = ["/invalid\000path"] 46 Exception: path cannot contain NUL byte, colon on Unix or semicolon on Windows 47 [tty]:1:5-9: set paths = ["/invalid\000path"] 48 49 //////// 50 # $pwd # 51 //////// 52 53 //each:in-temp-dir 54 55 ~> use os 56 use path 57 // Test both reading and writing $pwd. 58 ~> var start = $pwd 59 os:mkdir d 60 set pwd = d 61 eq $pwd (path:join $start d) 62 ▶ $true 63 64 ## bad assignment ## 65 ~> set pwd = (num 1) 66 Exception: path must be string 67 [tty]:1:5-7: set pwd = (num 1) 68 69 ## concrete value (Unix) ## 70 //only-on unix 71 ~> cd / 72 put $pwd 73 ▶ / 74 75 ## concrete value (Windows) ## 76 //only-on windows 77 ~> cd C:\ 78 put $pwd 79 ▶ C:\ 80 81 ## getwd error ## 82 //mock-getwd-error can't get working directory 83 ~> put $pwd 84 ▶ /unknown/pwd