diff options
author | kotfu <kotfu@kotfu.net> | 2018-07-16 21:44:40 -0600 |
---|---|---|
committer | kotfu <kotfu@kotfu.net> | 2018-07-16 21:44:40 -0600 |
commit | 9df22b9305b918034217dee6721dc348a4610e65 (patch) | |
tree | 1447051f55f6d5308d7e0d9f065f1c8d6071f0c7 /tests/test_parsing.py | |
parent | 625aea03324119b0ed7c2e84afd5575ffc8fa72a (diff) | |
download | cmd2-git-9df22b9305b918034217dee6721dc348a4610e65.tar.gz |
Bug fix and unit tests for #474
Diffstat (limited to 'tests/test_parsing.py')
-rw-r--r-- | tests/test_parsing.py | 22 |
1 files changed, 18 insertions, 4 deletions
diff --git a/tests/test_parsing.py b/tests/test_parsing.py index 59f9a610..5dc78745 100644 --- a/tests/test_parsing.py +++ b/tests/test_parsing.py @@ -142,6 +142,20 @@ def test_parse_c_comment_empty(parser): assert not statement.pipe_to assert not statement.argv +def test_parse_c_comment_no_closing(parser): + statement = parser.parse('cat /tmp/*.txt') + assert statement.command == 'cat' + assert statement.args == '/tmp/*.txt' + assert not statement.pipe_to + assert statement.argv == ['cat', '/tmp/*.txt'] + +def test_parse_c_comment_multiple_opening(parser): + statement = parser.parse('cat /tmp/*.txt /tmp/*.cfg') + assert statement.command == 'cat' + assert statement.args == '/tmp/*.txt /tmp/*.cfg' + assert not statement.pipe_to + assert statement.argv == ['cat', '/tmp/*.txt', '/tmp/*.cfg'] + def test_parse_what_if_quoted_strings_seem_to_start_comments(parser): statement = parser.parse('what if "quoted strings /* seem to " start comments?') assert statement.command == 'what' @@ -292,13 +306,13 @@ def test_parse_multiline_command_ignores_redirectors_within_it(parser, line, ter def test_parse_multiline_with_incomplete_comment(parser): """A terminator within a comment will be ignored and won't terminate a multiline command. Un-closed comments effectively comment out everything after the start.""" - line = 'multiline command /* with comment in progress;' + line = 'multiline command /* with unclosed comment;' statement = parser.parse(line) assert statement.multiline_command == 'multiline' assert statement.command == 'multiline' - assert statement.args == 'command' - assert statement.argv == ['multiline', 'command'] - assert not statement.terminator + assert statement.args == 'command /* with unclosed comment' + assert statement.argv == ['multiline', 'command', '/*', 'with', 'unclosed', 'comment'] + assert statement.terminator == ';' def test_parse_multiline_with_complete_comment(parser): line = 'multiline command /* with comment complete */ is done;' |