From 9d2bf248ee3dd04a7c9f86706bb74c166016f66d Mon Sep 17 00:00:00 2001 From: Fabian Homborg Date: Sun, 7 Jun 2020 16:21:28 +0200 Subject: [PATCH] test: Add tests for error messages --- tests/checks/test.fish | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/tests/checks/test.fish b/tests/checks/test.fish index cce83f0cf..6d4c8aafd 100644 --- a/tests/checks/test.fish +++ b/tests/checks/test.fish @@ -15,3 +15,40 @@ test 5 -eq nan test -z nan || echo nan is fine # CHECK: nan is fine + +test 1 = +# CHECKERR: test: Missing argument at index 3 +# CHECKERR: 1 = +# CHECKERR: ^ +# CHECKERR: {{.*}}test.fish (line {{\d+}}): +# CHECKERR: test 1 = +# CHECKERR: ^ + +test 1 = 2 and echo true or echo false +# CHECKERR: test: Expected a combining operator like '-a' at index 4 +# CHECKERR: 1 = 2 and echo true or echo false +# CHECKERR: ^ +# CHECKERR: {{.*}}test.fish (line {{\d+}}): +# CHECKERR: test 1 = 2 and echo true or echo false +# CHECKERR: ^ + +function t + test $argv[1] -eq 5 +end + +t foo +# CHECKERR: Invalid argument: 'foo' +# CHECKERR: {{.*}}test.fish (line {{\d+}}): +# CHECKERR: test $argv[1] -eq 5 +# CHECKERR: ^ +# CHECKERR: in function 't' with arguments 'foo' +# CHECKERR: called on line {{\d+}} of file {{.*}}test.fish + +t 5,2 +# CHECKERR: Integer 5 in '5,2' followed by non-digit +# CHECKERR: {{.*}}test.fish (line {{\d+}}): +# CHECKERR: test $argv[1] -eq 5 +# CHECKERR: ^ +# CHECKERR: in function 't' with arguments '5,2' +# CHECKERR: called on line {{\d+}} of file {{.*}}test.fish +