]> Sergey Matveev's repositories - zsh-autoenv.git/blob - tests/_autoenv_stack.t
Improve zsh/zstat integration; also make it handle dirs
[zsh-autoenv.git] / tests / _autoenv_stack.t
1 Tests for internal stack handling.
2
3   $ source $TESTDIR/setup.sh
4
5 Non-existing entries are allowed and handled without error.
6
7   $ _autoenv_stack_entered_add non-existing
8   $ echo $_autoenv_stack_entered
9   non-existing
10
11 Add existing entries.
12
13   $ mkdir -p sub/sub2
14   $ touch -t 201401010101 sub/file
15   $ touch -t 201401010102 sub
16   $ touch -t 201401010103 sub/sub2
17   $ _autoenv_stack_entered_add sub
18   $ _autoenv_stack_entered_add sub/file
19   $ _autoenv_stack_entered_add sub/sub2
20   $ echo $_autoenv_stack_entered
21   non-existing sub sub/file sub/sub2
22
23   $ _autoenv_stack_entered_add non-existing
24   $ echo $_autoenv_stack_entered
25   sub sub/file sub/sub2 non-existing
26
27   $ echo ${(k)_autoenv_stack_entered}
28   sub sub/file sub/sub2 non-existing
29
30   $ echo $_autoenv_stack_entered_mtime
31   1388538180 1388538060 1388538120 0
32
33 Touch the file and re-add it.
34
35   $ touch -t 201401012359 sub/file
36   $ _autoenv_stack_entered_add sub/file
37
38 The mtime should have been updated.
39
40   $ echo ${_autoenv_stack_entered_mtime[sub/file]}
41   1388620740
42
43 It should have moved to the end of the stack.
44
45   $ echo ${(k)_autoenv_stack_entered}
46   sub sub/sub2 non-existing sub/file
47
48 Test lookup of containing elements.
49
50   $ _autoenv_stack_entered_contains sub/file
51   $ _autoenv_stack_entered_contains non-existing
52   $ _autoenv_stack_entered_contains not-added
53   [1]
54
55 Test removing.
56
57   $ _autoenv_stack_entered_remove sub
58   $ echo ${_autoenv_stack_entered}
59   sub/sub2 non-existing sub/file
60