elvish/pkg/eval/eval_test.elvts
Qi Xiao d7fe04414b pkg/eval/evaltest: Import all builtin modules.
This removes the need for various "use-foo" setups for the standard library
modules - test code can just call "use foo" like normal Elvish code.
2024-02-01 14:46:37 +00:00

69 lines
1.1 KiB
Plaintext

//////////////////////////////////
# $before-chdir and $after-chdir #
//////////////////////////////////
//in-temp-dir
~> use os
os:mkdir d
var before-dst after-dst
set @before-chdir = {|dst| set before-dst = $dst }
set @after-chdir = {|dst| set after-dst = $dst }
cd d
put $before-dst $after-dst
▶ d
▶ d
////////
# $pid #
////////
~> > $pid 0
▶ $true
////////////////
# $num-bg-jobs #
////////////////
~> put $num-bg-jobs
▶ 0
// TODO(xiaq): Test cases where $num-bg-jobs > 0. This cannot be done with { put
// $num-bg-jobs }& because the output channel may have already been closed when
// the closure is run.
/////////
# $args #
/////////
~> put $args
▶ []
## non-empty ##
//args foo bar
~> put $args
▶ [foo bar]
////////////////////////
# multiple evaluations #
////////////////////////
~> var x = hello
~> put $x
▶ hello
## variable shadowing ##
// Regression test for b.elv.sh/1213
~> fn f { put old }
~> fn f { put new }
~> f
▶ new
## deleting variable ##
// Regression test for b.elv.sh/1213
~> var x = foo
~> del x
~> put $x
Compilation error: variable $x not found
[tty]:1:5-6: put $x