summaryrefslogtreecommitdiff
path: root/testsuite
diff options
context:
space:
mode:
authorniksaz <nikitasazanovich@gmail.com>2016-05-01 13:34:45 +0200
committerBen Gamari <ben@smart-cactus.org>2016-05-01 23:29:49 +0200
commit533037cc58a7c50e1c014e27e8b971d53e7b47bd (patch)
tree6bdc053c60cc3b8d2254a0cc14569c2207c317f8 /testsuite
parent18676a4a0dfe79e2704e48be5c8716a656825efe (diff)
downloadhaskell-533037cc58a7c50e1c014e27e8b971d53e7b47bd.tar.gz
Greater customization of GHCi prompt
This patch is trying to redesign the :set prompt option to take not a String but a Haskell function, like [String] -> Int -> IO String, where [String] is the list of the names of the currently loaded modules and Int is the line number. Currently you may set prompt function with **:set promt-function [String] -> Int -> IO String** option and old version is also available - :set prompt String. So, it looks like I've almost completed this patch: 1) Now we have a lot of escape sequences - 13 to be exact. Most of them are similar to bash prompt escape sequences. Thus they are quite handy. 2) We may use the special escape sequence to call shell functions, for example "%call(ls -l -a)". 3) We may use :set prompt-function to set PFunction to handle prompt. It is just [String] -> Int -> IO String. Reviewers: erikd, austin, mpickering, bgamari Reviewed By: mpickering, bgamari Subscribers: mpickering, thomie Differential Revision: https://phabricator.haskell.org/D2084 GHC Trac Issues: #5850
Diffstat (limited to 'testsuite')
-rwxr-xr-xtestsuite/tests/ghci/scripts/all.T3
-rw-r--r--testsuite/tests/ghci/scripts/ghci060.script7
-rw-r--r--testsuite/tests/ghci/scripts/ghci060.stderr5
-rw-r--r--testsuite/tests/ghci/scripts/ghci061.hs5
-rw-r--r--testsuite/tests/ghci/scripts/ghci061.script5
-rw-r--r--testsuite/tests/ghci/scripts/ghci061.stderr16
6 files changed, 41 insertions, 0 deletions
diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T
index 2d21772434..6e9e91bec4 100755
--- a/testsuite/tests/ghci/scripts/all.T
+++ b/testsuite/tests/ghci/scripts/all.T
@@ -92,6 +92,9 @@ test('ghci056',
test('ghci057', extra_hc_opts('-fwarn-tabs'), ghci_script, ['ghci057.script'])
+test('ghci060', normal, ghci_script, ['ghci060.script'])
+test('ghci061', normal, ghci_script, ['ghci061.script'])
+
test('T2452', normal, ghci_script, ['T2452.script'])
test('T2766', normal, ghci_script, ['T2766.script'])
diff --git a/testsuite/tests/ghci/scripts/ghci060.script b/testsuite/tests/ghci/scripts/ghci060.script
new file mode 100644
index 0000000000..853512e1c7
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/ghci060.script
@@ -0,0 +1,7 @@
+:set prompt "%call()> "
+:set prompt "%call(pwd) %call()"
+:set prompt "%callasfasfasfsaf(pwd)"
+:set prompt "%call(pwd"
+:set prompt "%a> "
+:set prompt-cont "%call()| "
+:set prompt-cont "%t| "
diff --git a/testsuite/tests/ghci/scripts/ghci060.stderr b/testsuite/tests/ghci/scripts/ghci060.stderr
new file mode 100644
index 0000000000..8f77a033d4
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/ghci060.stderr
@@ -0,0 +1,5 @@
+Incorrect %call syntax. Should be %call(a command and arguments).
+Incorrect %call syntax. Should be %call(a command and arguments).
+Incorrect %call syntax. Should be %call(a command and arguments).
+Incorrect %call syntax. Should be %call(a command and arguments).
+Incorrect %call syntax. Should be %call(a command and arguments).
diff --git a/testsuite/tests/ghci/scripts/ghci061.hs b/testsuite/tests/ghci/scripts/ghci061.hs
new file mode 100644
index 0000000000..2779bb5d1f
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/ghci061.hs
@@ -0,0 +1,5 @@
+two_args :: [String] -> IO String
+two_args _ = return "two_args> "
+
+three_args :: [String] -> Int -> IO String
+three_args _ _ = return $ "three_args> "
diff --git a/testsuite/tests/ghci/scripts/ghci061.script b/testsuite/tests/ghci/scripts/ghci061.script
new file mode 100644
index 0000000000..2d96b16ba4
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/ghci061.script
@@ -0,0 +1,5 @@
+:l ghci061.hs
+:set prompt-function two_args
+:set prompt-function three_args
+:set prompt-cont-function two_args
+:set prompt-cont-function three_args
diff --git a/testsuite/tests/ghci/scripts/ghci061.stderr b/testsuite/tests/ghci/scripts/ghci061.stderr
new file mode 100644
index 0000000000..1ba00c5609
--- /dev/null
+++ b/testsuite/tests/ghci/scripts/ghci061.stderr
@@ -0,0 +1,16 @@
+
+<interactive>:1:2: error:
+ • Couldn't match type ‘IO String’ with ‘Int -> IO String’
+ Expected type: [String] -> Int -> IO String
+ Actual type: [String] -> IO String
+ • In the expression: (two_args) :: [String] -> Int -> IO String
+ In an equation for ‘_compileParsedExpr’:
+ _compileParsedExpr = (two_args) :: [String] -> Int -> IO String
+
+<interactive>:1:2: error:
+ • Couldn't match type ‘IO String’ with ‘Int -> IO String’
+ Expected type: [String] -> Int -> IO String
+ Actual type: [String] -> IO String
+ • In the expression: (two_args) :: [String] -> Int -> IO String
+ In an equation for ‘_compileParsedExpr’:
+ _compileParsedExpr = (two_args) :: [String] -> Int -> IO String