about summary refs log tree commit diff
path: root/Test/V01zmodload.ztst
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2001-05-18 12:01:53 +0000
committerBart Schaefer <barts@users.sourceforge.net>2001-05-18 12:01:53 +0000
commit9a7d4529ea622a9871fe21d40ce53c86a6e6b212 (patch)
tree7bb31286d07eb970c9f62d92486f667097dadca7 /Test/V01zmodload.ztst
parente3727418747e76adc937c56e80a3ad1fd3d96c4d (diff)
downloadzsh-9a7d4529ea622a9871fe21d40ce53c86a6e6b212.tar.gz
zsh-9a7d4529ea622a9871fe21d40ce53c86a6e6b212.tar.xz
zsh-9a7d4529ea622a9871fe21d40ce53c86a6e6b212.zip
Add zmodload tests.
Diffstat (limited to 'Test/V01zmodload.ztst')
-rw-r--r--Test/V01zmodload.ztst146
1 files changed, 146 insertions, 0 deletions
diff --git a/Test/V01zmodload.ztst b/Test/V01zmodload.ztst
new file mode 100644
index 000000000..2575b271c
--- /dev/null
+++ b/Test/V01zmodload.ztst
@@ -0,0 +1,146 @@
+# Test basic module loading
+
+%prep
+# Figure out which modules it ought to be possible to load by looking at
+# the config.modules file.  This differs for static vs. dynamic builds.
+
+ mods=()
+ while read name modfile link auto load funcs
+ do
+   [[ $name == \#* ]] && continue
+   eval "$name $modfile $link $auto $load"
+   [[ $link == no ]] && continue
+   mods=($mods $name)
+ done < $ZTST_testdir/../config.modules
+
+%test
+
+# This first test depends on knowing that zsh is run with +Z from the
+# Makefile, and that ztst.zsh loads the parameter module.
+
+ zmodload -L
+0:List the loaded modules
+>zmodload zsh/main
+>zmodload zsh/parameter
+
+ zmodload zsh/main
+1:Test reloading an already-loaded module
+?ZTST_execchunk:zmodload:2: module zsh/main already loaded.
+
+# Loop over the modules fond above and attempt to load each one.  Use
+# the -i flag in case dependencies cause multiple modules to be loaded,
+# or in case some previous test loaded a module.
+
+ for m in $mods
+ do
+   zmodload -i $m || mods[(r)$m]=()
+ done
+0d:Test loading of all compiled modules
+
+ zmodload -e $mods
+0d:Check that zsh believes the modules did load
+
+# Now check for proper failure conditions by trying some operations on
+# a nonexistent module.
+
+ zmodload -i bogus/notamodule
+1D:Check that loading a nonexistent module fails
+
+ zmodload -u bogus/notamodule
+1D:Check that unloading a nonexistent module fails
+
+# Test adding and removing autoloads, using a nonexistent module.
+
+ zmodload -ab bogus
+ zmodload -ub bogus
+0:Add/remove autoloaded builtin
+
+ zmodload -ac bogus
+ zmodload -uc bogus
+0:Add/remove autoloaded condition
+
+ zmodload -ap bogus
+ zmodload -up bogus
+0:Add/remove autoloaded parameter
+
+ zmodload -af bogus
+ zmodload -uf bogus
+0:Add/remove autoloaded math function
+
+# If the "example" module is available, test various autoloading behavior.
+
+ if [[ $mods[(r)zsh/example] == zsh/example ]]; then
+   zmodload -u zsh/example
+   zmodload -ab zsh/example example
+   builtin example
+   zmodload -e zsh/example
+ else :
+ fi
+0d:Autoload a module via a builtin
+
+ if [[ $mods[(r)zsh/example] == zsh/example ]]; then
+   zmodload -u zsh/example
+   zmodload -ac -I zsh/example ex
+   [[ exam -ex ple ]]
+   zmodload -e zsh/example
+ else :
+ fi
+0d:Autoload a module via a condition
+
+ if [[ $mods[(r)zsh/example] == zsh/example ]]; then
+   zmodload -u zsh/example
+   zmodload -ap zsh/example exint
+   : $exint
+   zmodload -e zsh/example
+ else :
+ fi
+0d:Autoload a module via a parameter
+
+ if [[ $mods[(r)zsh/example] == zsh/example ]]; then
+   zmodload -u zsh/example
+   zmodload -af zsh/example sum
+   (( sum(1) ))
+   zmodload -e zsh/example
+ else :
+ fi
+0d:Autoload a module via a math function
+
+# Test module aliases
+
+ zmodload -A example=zsh/example
+ zmodload -A
+0:Test creating a module alias
+>example -> zsh/example
+
+ if [[ $mods[(r)zsh/example] == zsh/example ]]; then
+   zmodload -u example
+   zmodload -ab example
+   builtin example
+   zmodload -e example
+ else :
+ fi
+0d:Unload/autoload the module via its alias
+
+ zmodload -R example
+ zmodload -e example
+1:Delete the module alias again
+
+# Remove all inter-module dependencies so that we can unload in any order.
+# Skip the two modules that are required by the test system!
+
+ mods[(r)zsh/main]=()
+ mods[(r)zsh/parameter]=()
+ for m in $mods
+ do
+   zmodload -ud $m
+ done
+0d:Remove module dependecies
+
+# Unload all the modules again (except the two we skipped, of course).
+
+ zmodload -u $mods
+0d:Unload the modules loaded by this test suite
+
+%clean
+
+ unset name modfile link auto load funcs mods m