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