]> git.sur5r.net Git - i3/i3/blobdiff - testcases/t/187-commands-parser.t
Add tests for backslash unescaping
[i3/i3] / testcases / t / 187-commands-parser.t
index 37deb94256e7708556d03cb676593fdf49245b37..6d67731a1e71a9914485962ebc3fc73215d1b042 100644 (file)
@@ -52,6 +52,8 @@ is(parser_calls(
    'move window to workspace 3; ' .
    'move container to workspace 3; ' .
    'move workspace foobar; ' .
+   'move workspace torrent; ' .
+   'move workspace to output LVDS1; ' .
    'move workspace 3: foobar; ' .
    'move workspace "3: foobar"; ' .
    'move workspace "3: foobar, baz"; '),
@@ -59,6 +61,8 @@ is(parser_calls(
    "cmd_move_con_to_workspace_name(3)\n" .
    "cmd_move_con_to_workspace_name(3)\n" .
    "cmd_move_con_to_workspace_name(foobar)\n" .
+   "cmd_move_con_to_workspace_name(torrent)\n" .
+   "cmd_move_workspace_to_output(LVDS1)\n" .
    "cmd_move_con_to_workspace_name(3: foobar)\n" .
    "cmd_move_con_to_workspace_name(3: foobar)\n" .
    "cmd_move_con_to_workspace_name(3: foobar, baz)",
@@ -140,7 +144,7 @@ is(parser_calls("\nworkspace test"),
 ################################################################################
 
 is(parser_calls('unknown_literal'),
-   "ERROR: Expected one of these tokens: <end>, '[', 'move', 'exec', 'exit', 'restart', 'reload', 'border', 'layout', 'append_layout', 'workspace', 'focus', 'kill', 'open', 'fullscreen', 'split', 'floating', 'mark', 'resize', 'rename', 'nop', 'scratchpad', 'mode'\n" .
+   "ERROR: Expected one of these tokens: <end>, '[', 'move', 'exec', 'exit', 'restart', 'reload', 'shmlog', 'debuglog', 'border', 'layout', 'append_layout', 'workspace', 'focus', 'kill', 'open', 'fullscreen', 'split', 'floating', 'mark', 'unmark', 'resize', 'rename', 'nop', 'scratchpad', 'mode', 'bar'\n" .
    "ERROR: Your command: unknown_literal\n" .
    "ERROR:               ^^^^^^^^^^^^^^^",
    'error for unknown literal ok');
@@ -152,7 +156,7 @@ is(parser_calls('move something to somewhere'),
    'error for unknown literal ok');
 
 ################################################################################
-# 3: Verify that escaping of double quotes works correctly
+# 3: Verify that escaping works correctly
 ################################################################################
 
 is(parser_calls('workspace "foo"'),
@@ -167,4 +171,31 @@ is(parser_calls('workspace "foo \"bar"'),
    'cmd_workspace_name(foo "bar)',
    'Command with escaped double quotes ok');
 
+is(parser_calls('workspace "foo \\'),
+   'cmd_workspace_name(foo \\)',
+   'Command with single backslash in the end ok');
+
+is(parser_calls('workspace "foo\\\\bar"'),
+   'cmd_workspace_name(foo\\bar)',
+   'Command with escaped backslashes ok');
+
+is(parser_calls('workspace "foo\\\\\\"bar"'),
+   'cmd_workspace_name(foo\\"bar)',
+   'Command with escaped double quotes after escaped backslashes ok');
+
+################################################################################
+# 4: Verify that resize commands with a "px or ppt"-construction are parsed
+# correctly
+################################################################################
+
+is(parser_calls("resize shrink width 10 px or"),
+   "ERROR: Expected one of these tokens: <word>\n" .
+   "ERROR: Your command: resize shrink width 10 px or\n" .
+   "ERROR:                                           ",
+   "error for resize command with incomplete 'or'-construction ok");
+
+is(parser_calls("resize grow left 10 px or 20 ppt"),
+   "cmd_resize(grow, left, 10, 20)",
+   "resize command with 'or'-construction ok");
+
 done_testing;