Update ChangeLog, AUTHORS.
[erlware-mode.git] / test.erl
blob91f35e822dd3e40d51b050e401190a39a4332baa
1 %% This file contains Erlang code for testing the
2 %% Erlware emacs mode. It contains functions that
3 %% use different corner cases to make sure the mode
4 %% does the right thing.
5 %%
6 %% <<If comment-multi-line is on, Press Return to get another %% line>>
8 -module(test).
9 -compile(export_all).
11 func1() ->
12 % This line should stay here after a tab.
13 % If the comment-multi-line variable is non-nil, then pressing
14 % Return at end of this line shouldto get another % line.
15 ok.
17 func2() ->
18 % Pressing tabs on all lines should not change indents.
19 {0, $q},
20 {1, $(},
21 {2, $)},
22 {3, $>},
23 {4, $<},
24 {5, $,},
25 {6, ${},
26 [$% | ["should not be highlighted as a comment"]],
27 ok.
29 func3() ->
30 % If you edit the font lock mode to underline function names,
31 % there should not be an underline character after the '->'.
32 fun() -> ok end.
34 func4() ->
35 try
36 module:somefun(monkey, horse)
37 catch
38 % both these clauses should maintain their indents after tab presses
39 error:something ->
40 error;
41 error:function_clause ->
42 error
43 end.
45 func5(Xyz)
46 when is_atom(Xyz) ->
47 % `is_atom' should be highlighted as a guard above
49 % All functions below should be highlighted as functions, not
50 % as guards or bifs. So each entire function name should be
51 % highlighted in the same way.
52 f:is_atom(),
53 g:registered(),
54 h:my_registered(),
55 func6(),
56 deregistered(),
58 % Xyz should be highlighted as a variabla
59 AppSpec = Xyz/2,
60 % atom_to_list and element should be highlighted as bifs
61 atom_to_list(element(1, AppSpec)),
63 % These should be highlighted as bifs.
64 erlang:registered(),
65 registered(),
66 hd(tl(tl(hd([a,b,c])))).
68 % `-spec' should be highlighted as an attribute, i.e. the same way as
69 % the `-define'
71 -define(foo,FOO).
72 -spec func6() -> any().
74 func6() ->
75 % These should be highlighted as atoms
76 'VaV',
77 'aVa',
78 '\'atom',
79 'atom\'',
80 'at\'om',
81 '#1',
82 % 3 lines below should be highlighted as literals
83 $a,
84 $A,
85 $1,
86 % in line below, V should be highlited as a var
87 V = fun() -> hello end,
88 V(),
89 Mo = yVy,
90 Vv = v,
91 % in line below, Mo and Vv should be highlited as vars
92 Mo:Vv(),
93 % in line below, Mo as var, bla as func call
94 Mo:bla(),
95 % the ':' should no be highlighted
96 ets:insert(bla,{'$1',{'$2','$3'}}).
98 func7() ->
99 % should keep indentation on tab
100 try func1()
101 after
102 func7()
103 end.
105 func8() ->
106 % anatom should be highlighted as an atom, not a string
108 "string\$", anatom,
110 % N.B. A '$' at the end of a string must be escaped, or the
111 % highlighting will not work. This is of course a bug, but I don't
112 % know how to fix it and the workaround is simple.
114 % this comment should be highlighted as a comment
115 % following should be highlighted as a string, should indent on tab
116 "some $a string".
118 func9(Term, [${|T]) ->
119 % above should be highlighted correctly
120 % all function body lines should not indent further on tab
123 deregistered() ->