From 975e322d37afaca6e565b37282f2d9e6038124bc Mon Sep 17 00:00:00 2001 From: Brendan Taylor Date: Thu, 13 Jan 2011 12:11:19 -0700 Subject: add a variable @_ that expands to the result of the last sync command --- tests/test-command.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'tests') diff --git a/tests/test-command.c b/tests/test-command.c index 7b33405..20c6aa0 100644 --- a/tests/test-command.c +++ b/tests/test-command.c @@ -281,6 +281,21 @@ test_js (void) { g_string_free(result, TRUE); } +void +test_last_result (void) { + GString *result = g_string_new(""); + + /* the last result gets set */ + parse_cmd_line("js -1", result); + g_assert_cmpstr("-1", ==, uzbl.state.last_result); + + /* the last result can be used in a chain */ + parse_cmd_line("chain 'js 1' 'js \\@_ + 1'", result); + g_assert_cmpstr("2", ==, uzbl.state.last_result); + + g_string_free(result, TRUE); +} + void test_run_handler_arg_order (void) { run_handler("sync_spawn echo uvw xyz", "abc def"); @@ -320,6 +335,8 @@ main (int argc, char *argv[]) { g_test_add_func("/test-command/js", test_js); + g_test_add_func("/test-command/last-result", test_last_result); + /* the following aren't really "command" tests, but they're not worth * splitting into a separate file yet */ g_test_add_func("/test-command/run_handler/arg-order", test_run_handler_arg_order); -- cgit v1.2.3