2 # vim:ts=4:sw=4:expandtab
4 # Tests whether we can switch to a non-existant workspace
5 # (necessary for further tests)
7 use List::Util qw(first);
10 my $tmp = fresh_workspace;
11 ok(workspace_exists($tmp), 'workspace created');
12 # if the workspace could not be created, we cannot run any other test
13 # (every test starts by creating its workspace)
14 if (!workspace_exists($tmp)) {
15 BAIL_OUT('Cannot create workspace, further tests make no sense');
18 my $otmp = fresh_workspace;
19 diag("Other temporary workspace name: $otmp\n");
21 # As the old workspace was empty, it should get
22 # cleaned up as we switch away from it
23 cmd "workspace $otmp";
24 ok(!workspace_exists($tmp), 'old workspace cleaned up');
26 # Switch to the same workspace again to make sure it doesn’t get cleaned up
27 cmd "workspace $otmp";
28 cmd "workspace $otmp";
29 ok(workspace_exists($otmp), 'other workspace still exists');
32 #####################################################################
33 # check if the workspace next / prev commands work
34 #####################################################################
38 ok(!workspace_exists('next'), 'workspace "next" does not exist');
43 ok(workspace_exists($tmp), 'workspace created');
45 cmd "workspace $otmp";
48 ok(workspace_exists($tmp), 'workspace tmp still exists');
49 ok(workspace_exists($otmp), 'workspace otmp created');
51 is(focused_ws(), $otmp, 'focused workspace is otmp');
54 is(focused_ws(), $tmp, 'focused workspace is tmp after workspace prev');
57 is(focused_ws(), $otmp, 'focused workspace is otmp after workspace next');
60 #####################################################################
61 # check that wrapping works
62 #####################################################################
65 is(focused_ws(), '1', 'focused workspace is 1 after workspace next');
68 is(focused_ws(), $tmp, 'focused workspace is tmp after workspace next');
71 is(focused_ws(), $otmp, 'focused workspace is otmp after workspace next');
75 is(focused_ws(), $tmp, 'focused workspace is tmp after workspace prev');
78 is(focused_ws(), '1', 'focused workspace is tmp after workspace prev');
81 is(focused_ws(), $otmp, 'focused workspace is otmp after workspace prev');
84 #####################################################################
85 # check if we can change to "next" / "prev"
86 #####################################################################
88 cmd 'workspace "next"';
90 ok(workspace_exists('next'), 'workspace "next" exists');
91 is(focused_ws(), 'next', 'now on workspace next');
93 cmd 'workspace "prev"';
95 ok(workspace_exists('prev'), 'workspace "prev" exists');
96 is(focused_ws(), 'prev', 'now on workspace prev');