diff options
author | Henrik Nord <[email protected]> | 2014-02-11 15:00:58 +0100 |
---|---|---|
committer | Henrik Nord <[email protected]> | 2014-02-11 15:01:01 +0100 |
commit | 2079ea9e1c41b2579bc08fa1bfc53179dab50ead (patch) | |
tree | 69868512b77b0e425af82dd101e34d701829faee /lib | |
parent | 264c63ecc5d6409e0498994b58eab84debbca00d (diff) | |
parent | dfb4ec804a099b539c91e5643090d8183885e71c (diff) | |
download | otp-2079ea9e1c41b2579bc08fa1bfc53179dab50ead.tar.gz otp-2079ea9e1c41b2579bc08fa1bfc53179dab50ead.tar.bz2 otp-2079ea9e1c41b2579bc08fa1bfc53179dab50ead.zip |
Merge branch 'fenollp/shell-expand-0arity-completely'
* fenollp/shell-expand-0arity-completely:
Shell: expand 0-arity functions all the way to closing parenthesis
OTP-11684
Diffstat (limited to 'lib')
-rw-r--r-- | lib/stdlib/src/edlin_expand.erl | 8 | ||||
-rw-r--r-- | lib/stdlib/test/edlin_expand_SUITE.erl | 11 | ||||
-rw-r--r-- | lib/stdlib/test/expand_test.erl | 6 | ||||
-rw-r--r-- | lib/stdlib/test/expand_test1.erl | 4 |
4 files changed, 21 insertions, 8 deletions
diff --git a/lib/stdlib/src/edlin_expand.erl b/lib/stdlib/src/edlin_expand.erl index 516c0aa30b..0033010dce 100644 --- a/lib/stdlib/src/edlin_expand.erl +++ b/lib/stdlib/src/edlin_expand.erl @@ -89,7 +89,13 @@ match(Prefix, Alts, Extra) -> {yes, Remain, []} end; {complete, Str} -> - {yes, nthtail(Len, Str) ++ Extra, []}; + {_, Arity} = lists:keyfind(Str, 1, Matches), + case {Arity, Extra} of + {0, "("} -> + {yes, nthtail(Len, Str) ++ "()", []}; + _ -> + {yes, nthtail(Len, Str) ++ Extra, []} + end; no -> {no, [], []} end. diff --git a/lib/stdlib/test/edlin_expand_SUITE.erl b/lib/stdlib/test/edlin_expand_SUITE.erl index 0cd2688e2e..2c1c5acf5a 100644 --- a/lib/stdlib/test/edlin_expand_SUITE.erl +++ b/lib/stdlib/test/edlin_expand_SUITE.erl @@ -76,11 +76,14 @@ normal(Config) when is_list(Config) -> [{"a_fun_name",1}, {"a_less_fun_name",1}, {"b_comes_after_a",1}, + {"expand0arity_entirely",0}, {"module_info",0}, {"module_info",1}]} = edlin_expand:expand(lists:reverse("expand_test:")), ?line {yes,[],[{"a_fun_name",1}, {"a_less_fun_name",1}]} = edlin_expand:expand( lists:reverse("expand_test:a_")), + ?line {yes,"arity_entirely()",[]} = edlin_expand:expand( + lists:reverse("expand_test:expand0")), ok. quoted_fun(doc) -> @@ -93,7 +96,7 @@ quoted_fun(Config) when is_list(Config) -> %% should be no colon after test this time ?line {yes, "test", []} = edlin_expand:expand(lists:reverse("expand_")), ?line {no, [], []} = edlin_expand:expand(lists:reverse("expandXX_")), - ?line {no,[],[{"'#weird-fun-name'",0}, + ?line {no,[],[{"'#weird-fun-name'",1}, {"'Quoted_fun_name'",0}, {"'Quoted_fun_too'",0}, {"a_fun_name",1}, @@ -108,7 +111,7 @@ quoted_fun(Config) when is_list(Config) -> {"a_less_fun_name",1}]} = edlin_expand:expand( lists:reverse("expand_test1:a_")), ?line {yes,[], - [{"'#weird-fun-name'",0}, + [{"'#weird-fun-name'",1}, {"'Quoted_fun_name'",0}, {"'Quoted_fun_too'",0}]} = edlin_expand:expand( lists:reverse("expand_test1:'")), @@ -172,6 +175,6 @@ quoted_both(Config) when is_list(Config) -> [{"'Quoted_fun_name'",0}, {"'Quoted_fun_too'",0}]} = edlin_expand:expand( lists:reverse("'ExpandTestCaps1':'Quoted_fun_")), - ?line {yes,"weird-fun-name'(",[]} = edlin_expand:expand( - lists:reverse("'ExpandTestCaps1':'#")), + ?line {yes,"weird-fun-name'()",[]} = edlin_expand:expand( + lists:reverse("'ExpandTestCaps1':'#")), ok. diff --git a/lib/stdlib/test/expand_test.erl b/lib/stdlib/test/expand_test.erl index 63e4bc3aa0..b9db32c352 100644 --- a/lib/stdlib/test/expand_test.erl +++ b/lib/stdlib/test/expand_test.erl @@ -20,7 +20,8 @@ -export([a_fun_name/1, a_less_fun_name/1, - b_comes_after_a/1]). + b_comes_after_a/1, + expand0arity_entirely/0]). a_fun_name(X) -> X. @@ -30,3 +31,6 @@ a_less_fun_name(X) -> b_comes_after_a(X) -> X. + +expand0arity_entirely () -> + ok. diff --git a/lib/stdlib/test/expand_test1.erl b/lib/stdlib/test/expand_test1.erl index 11b6fec0f3..1d375e5677 100644 --- a/lib/stdlib/test/expand_test1.erl +++ b/lib/stdlib/test/expand_test1.erl @@ -23,7 +23,7 @@ b_comes_after_a/1, 'Quoted_fun_name'/0, 'Quoted_fun_too'/0, - '#weird-fun-name'/0]). + '#weird-fun-name'/1]). a_fun_name(X) -> X. @@ -40,5 +40,5 @@ b_comes_after_a(X) -> 'Quoted_fun_too'() -> too. -'#weird-fun-name'() -> +'#weird-fun-name'(_) -> weird. |