X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=testcases%2Ft%2F187-commands-parser.t;h=5c0cc99f615be22cdca7a4b5ea1ef257439bf989;hb=7270206e24d53dfc927e7a965dec30b66b7c7ff5;hp=bbb89d93be9d902aaf56089e2d3f78bddb0f9a6e;hpb=88671986f4cd45ca71ee3865e4d72f2e0633ec4b;p=i3%2Fi3 diff --git a/testcases/t/187-commands-parser.t b/testcases/t/187-commands-parser.t index bbb89d93..5c0cc99f 100644 --- a/testcases/t/187-commands-parser.t +++ b/testcases/t/187-commands-parser.t @@ -131,11 +131,11 @@ is(parser_calls('[con_mark="yay"] focus'), # commands being parsed due to the configuration, people might send IPC # commands with leading or trailing newlines. is(parser_calls("workspace test\n"), - 'cmd_workspace_name(test)', + 'cmd_workspace_name(test, (null))', 'trailing whitespace stripped off ok'); is(parser_calls("\nworkspace test"), - 'cmd_workspace_name(test)', + 'cmd_workspace_name(test, (null))', 'trailing whitespace stripped off ok'); ################################################################################ @@ -144,31 +144,85 @@ is(parser_calls("\nworkspace test"), ################################################################################ is(parser_calls('unknown_literal'), - "ERROR: Expected one of these tokens: , '[', '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: Expected one of these tokens: , '[', " . + "'move', " . + "'exec', " . + "'exit', " . + "'restart', " . + "'reload', " . + "'shmlog', " . + "'debuglog', " . + "'border', " . + "'layout', " . + "'append_layout', " . + "'workspace', " . + "'focus', " . + "'kill', " . + "'open', " . + "'fullscreen', " . + "'sticky', " . + "'split', " . + "'floating', " . + "'mark', " . + "'unmark', " . + "'resize', " . + "'rename', " . + "'nop', " . + "'scratchpad', " . + "'title_format', " . + "'mode', " . + "'bar'\n" . "ERROR: Your command: unknown_literal\n" . "ERROR: ^^^^^^^^^^^^^^^", 'error for unknown literal ok'); is(parser_calls('move something to somewhere'), - "ERROR: Expected one of these tokens: 'window', 'container', 'to', 'workspace', 'output', 'scratchpad', 'left', 'right', 'up', 'down', 'position', 'absolute'\n" . + "ERROR: Expected one of these tokens: 'window', 'container', 'to', 'workspace', 'output', 'mark', 'scratchpad', 'left', 'right', 'up', 'down', 'position', 'absolute'\n" . "ERROR: Your command: move something to somewhere\n" . "ERROR: ^^^^^^^^^^^^^^^^^^^^^^", '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"'), - 'cmd_workspace_name(foo)', + 'cmd_workspace_name(foo, (null))', 'Command with simple double quotes ok'); is(parser_calls('workspace "foo'), - 'cmd_workspace_name(foo)', + 'cmd_workspace_name(foo, (null))', 'Command without ending double quotes ok'); is(parser_calls('workspace "foo \"bar"'), - 'cmd_workspace_name(foo "bar)', + 'cmd_workspace_name(foo "bar, (null))', 'Command with escaped double quotes ok'); +is(parser_calls('workspace "foo \\'), + 'cmd_workspace_name(foo \\, (null))', + 'Command with single backslash in the end ok'); + +is(parser_calls('workspace "foo\\\\bar"'), + 'cmd_workspace_name(foo\\bar, (null))', + 'Command with escaped backslashes ok'); + +is(parser_calls('workspace "foo\\\\\\"bar"'), + 'cmd_workspace_name(foo\\"bar, (null))', + '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: \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;