diff options
author | Takenobu Tani <takenobu.hs@gmail.com> | 2019-10-12 08:41:16 +0900 |
---|---|---|
committer | Marge Bot <ben+marge-bot@smart-cactus.org> | 2019-10-16 07:05:41 -0400 |
commit | 1964195776d83c621817a75744bc7fe3f46961c9 (patch) | |
tree | df903197866b4dacbf46c6fc7d9d590168099d09 | |
parent | cc2bda505893a65fdc118cb4ccb1c6325dfcc633 (diff) | |
download | haskell-1964195776d83c621817a75744bc7fe3f46961c9.tar.gz |
testsuite: Add test for #8305
This is a test for the current algorithm of GHCi command name resolution.
I add this test in preparation for updating GHCi command name resolution.
For the current algorithm, see https://downloads.haskell.org/ghc/latest/docs/html/users_guide/ghci.html#the-ghci-files
-rw-r--r-- | testsuite/tests/ghci/scripts/T8305.script | 39 | ||||
-rw-r--r-- | testsuite/tests/ghci/scripts/T8305.stdout | 5 | ||||
-rwxr-xr-x | testsuite/tests/ghci/scripts/all.T | 1 |
3 files changed, 45 insertions, 0 deletions
diff --git a/testsuite/tests/ghci/scripts/T8305.script b/testsuite/tests/ghci/scripts/T8305.script new file mode 100644 index 0000000000..2b5bc80006 --- /dev/null +++ b/testsuite/tests/ghci/scripts/T8305.script @@ -0,0 +1,39 @@ +-- Testing the current algorithm of command name resolution + +-- The current algorithm of command name resolution is: +-- 1. First, look up an exact match on the name from the defined macros. +-- 2. Look for the exact match on the name in the built-in command list. +-- 3. Do a prefix lookup on the list of built-in commands +-- - if a built-in command matches, but a macro is defined +-- with the same name as the built-in defined, pick the macro. +-- 4. Do a prefix lookup on the list of built-in commands. +-- 5. Do a prefix lookup on the list of defined macros. +-- +-- For the current algorithm, see https://downloads.haskell.org/ghc/latest/docs/html/users_guide/ghci.html#the-ghci-files + + +----- Defineing macros for test +:def! ty (\e -> putStrLn "called :ty macro" >> return "") +:def! type (\e -> putStrLn "called :type macro" >> return "") +:def type2 (\e -> putStrLn "called :type2 macro" >> return "") +:def time (\e -> putStrLn "called :time macro" >> return "") + +:def! ki (\e -> putStrLn "called :ki macro" >> return "") +:def kind2 (\e -> putStrLn "called :kind2 macro" >> return "") + + +----- Testing +-- 1. +:type () + +-- 2. +:kind () + +-- 3. +:t () + +-- 4. +:k () + +-- 5. +:ti () diff --git a/testsuite/tests/ghci/scripts/T8305.stdout b/testsuite/tests/ghci/scripts/T8305.stdout new file mode 100644 index 0000000000..691ed95c73 --- /dev/null +++ b/testsuite/tests/ghci/scripts/T8305.stdout @@ -0,0 +1,5 @@ +called :type macro +() :: * +called :type macro +() :: * +called :time macro diff --git a/testsuite/tests/ghci/scripts/all.T b/testsuite/tests/ghci/scripts/all.T index dedca954f2..aaefca532e 100755 --- a/testsuite/tests/ghci/scripts/all.T +++ b/testsuite/tests/ghci/scripts/all.T @@ -178,6 +178,7 @@ test('T8113', normal, ghci_script, ['T8113.script']) test('T8172', when(opsys('mingw32'), normalise_drive_letter), ghci_script, ['T8172.script']) test('T8215', normal, ghci_script, ['T8215.script']) +test('T8305', normal, ghci_script, ['T8305.script']) test('T8353', extra_files(['Defer03.hs']), ghci_script, ['T8353.script']) test('T8357', normal, ghci_script, ['T8357.script']) test('T8383', normal, ghci_script, ['T8383.script']) |