@@ -19,42 +19,42 @@ describe('Erlang parser', () => {
1919 return extractErlangSymbols ( tree , 'test.erl' ) ;
2020 }
2121
22- it ( 'extracts module declarations' , ( ) => {
23- if ( ! erlangAvailable ) return ;
22+ it ( 'extracts module declarations' , ( ctx ) => {
23+ if ( ! erlangAvailable ) return ctx . skip ( ) ;
2424 const symbols = parseErlang ( `-module(mymodule).` ) ;
2525 expect ( symbols . definitions ) . toContainEqual (
2626 expect . objectContaining ( { name : 'mymodule' , kind : 'module' } ) ,
2727 ) ;
2828 } ) ;
2929
30- it ( 'extracts function definitions' , ( ) => {
31- if ( ! erlangAvailable ) return ;
30+ it ( 'extracts function definitions' , ( ctx ) => {
31+ if ( ! erlangAvailable ) return ctx . skip ( ) ;
3232 const symbols = parseErlang ( `greet(Name) ->
3333 io:format("Hello ~s~n", [Name]).` ) ;
3434 expect ( symbols . definitions ) . toContainEqual ( expect . objectContaining ( { kind : 'function' } ) ) ;
3535 } ) ;
3636
37- it ( 'extracts record definitions' , ( ) => {
38- if ( ! erlangAvailable ) return ;
37+ it ( 'extracts record definitions' , ( ctx ) => {
38+ if ( ! erlangAvailable ) return ctx . skip ( ) ;
3939 const symbols = parseErlang ( `-record(person, {name, age}).` ) ;
4040 expect ( symbols . definitions ) . toContainEqual ( expect . objectContaining ( { kind : 'record' } ) ) ;
4141 } ) ;
4242
43- it ( 'extracts import attributes' , ( ) => {
44- if ( ! erlangAvailable ) return ;
43+ it ( 'extracts import attributes' , ( ctx ) => {
44+ if ( ! erlangAvailable ) return ctx . skip ( ) ;
4545 const symbols = parseErlang ( `-import(lists, [map/2, filter/2]).` ) ;
4646 expect ( symbols . imports . length ) . toBeGreaterThanOrEqual ( 1 ) ;
4747 } ) ;
4848
49- it ( 'extracts function calls' , ( ) => {
50- if ( ! erlangAvailable ) return ;
49+ it ( 'extracts function calls' , ( ctx ) => {
50+ if ( ! erlangAvailable ) return ctx . skip ( ) ;
5151 const symbols = parseErlang ( `start() ->
5252 io:format("Hello~n").` ) ;
5353 expect ( symbols . calls . length ) . toBeGreaterThanOrEqual ( 1 ) ;
5454 } ) ;
5555
56- it ( 'keeps distinct arities for the same function name' , ( ) => {
57- if ( ! erlangAvailable ) return ;
56+ it ( 'keeps distinct arities for the same function name' , ( ctx ) => {
57+ if ( ! erlangAvailable ) return ctx . skip ( ) ;
5858 // Erlang overloads by arity; foo/1 and foo/2 are distinct definitions.
5959 const symbols = parseErlang ( `foo(X) -> X.
6060foo(X, Y) -> X + Y.
@@ -65,17 +65,17 @@ foo(X, Y, Z) -> X + Y + Z.`);
6565 expect ( arities ) . toEqual ( [ 1 , 2 , 3 ] ) ;
6666 } ) ;
6767
68- it ( 'counts complex pattern arguments as parameters' , ( ) => {
69- if ( ! erlangAvailable ) return ;
68+ it ( 'counts complex pattern arguments as parameters' , ( ctx ) => {
69+ if ( ! erlangAvailable ) return ctx . skip ( ) ;
7070 // Tuple, list, and binary pattern arguments must still count toward arity.
7171 const symbols = parseErlang ( `handle({ok, X}, [H | T]) -> {X, H, T}.` ) ;
7272 const f = symbols . definitions . find ( ( d ) => d . name === 'handle' && d . kind === 'function' ) ;
7373 expect ( f ) . toBeDefined ( ) ;
7474 expect ( f ?. children ?. length ) . toBe ( 2 ) ;
7575 } ) ;
7676
77- it ( 'extracts -type aliases' , ( ) => {
78- if ( ! erlangAvailable ) return ;
77+ it ( 'extracts -type aliases' , ( ctx ) => {
78+ if ( ! erlangAvailable ) return ctx . skip ( ) ;
7979 // Type-alias names are wrapped in a `type_name` node containing an atom in
8080 // the current grammar; the extractor handles both the wrapped form and a
8181 // direct atom fallback.
@@ -85,25 +85,25 @@ foo(X, Y, Z) -> X + Y + Z.`);
8585 ) ;
8686 } ) ;
8787
88- it ( 'extracts -opaque types' , ( ) => {
89- if ( ! erlangAvailable ) return ;
88+ it ( 'extracts -opaque types' , ( ctx ) => {
89+ if ( ! erlangAvailable ) return ctx . skip ( ) ;
9090 // -opaque uses the same `type_alias` node shape and must produce a type def.
9191 const symbols = parseErlang ( `-opaque handle() :: reference().` ) ;
9292 expect ( symbols . definitions ) . toContainEqual (
9393 expect . objectContaining ( { name : 'handle' , kind : 'type' } ) ,
9494 ) ;
9595 } ) ;
9696
97- it ( 'extracts -define macros as variables' , ( ) => {
98- if ( ! erlangAvailable ) return ;
97+ it ( 'extracts -define macros as variables' , ( ctx ) => {
98+ if ( ! erlangAvailable ) return ctx . skip ( ) ;
9999 const symbols = parseErlang ( `-define(MAX_SIZE, 1024).` ) ;
100100 expect ( symbols . definitions ) . toContainEqual (
101101 expect . objectContaining ( { name : 'MAX_SIZE' , kind : 'variable' } ) ,
102102 ) ;
103103 } ) ;
104104
105- it ( 'extracts uppercase parametric macro names' , ( ) => {
106- if ( ! erlangAvailable ) return ;
105+ it ( 'extracts uppercase parametric macro names' , ( ctx ) => {
106+ if ( ! erlangAvailable ) return ctx . skip ( ) ;
107107 // Parametric macros wrap the name in `macro_lhs(name, args)`; the leading
108108 // child is the name (var for uppercase).
109109 const symbols = parseErlang ( `-define(FOO(X), X + 1).` ) ;
@@ -112,8 +112,8 @@ foo(X, Y, Z) -> X + Y + Z.`);
112112 ) ;
113113 } ) ;
114114
115- it ( 'extracts lowercase parametric macro names without mislabeling on argument vars' , ( ) => {
116- if ( ! erlangAvailable ) return ;
115+ it ( 'extracts lowercase parametric macro names without mislabeling on argument vars' , ( ctx ) => {
116+ if ( ! erlangAvailable ) return ctx . skip ( ) ;
117117 // For lowercase parametric macros, macro_lhs children are
118118 // `atom("foo"), '(', var("X"), ')'`. The macro name must come from the
119119 // atom, not from `findChild(.., 'var')` which would land on the argument.
@@ -125,16 +125,16 @@ foo(X, Y, Z) -> X + Y + Z.`);
125125 expect ( symbols . definitions . some ( ( d ) => d . name === 'X' ) ) . toBe ( false ) ;
126126 } ) ;
127127
128- it ( 'records -include with kind "include" so consumers resolve locally' , ( ) => {
129- if ( ! erlangAvailable ) return ;
128+ it ( 'records -include with kind "include" so consumers resolve locally' , ( ctx ) => {
129+ if ( ! erlangAvailable ) return ctx . skip ( ) ;
130130 const symbols = parseErlang ( `-include("foo.hrl").` ) ;
131131 const imp = symbols . imports . find ( ( i ) => i . source === 'foo.hrl' ) ;
132132 expect ( imp ) . toBeDefined ( ) ;
133133 expect ( imp ?. names ) . toEqual ( [ 'include' ] ) ;
134134 } ) ;
135135
136- it ( 'records -include_lib with kind "include_lib" so consumers resolve against OTP paths' , ( ) => {
137- if ( ! erlangAvailable ) return ;
136+ it ( 'records -include_lib with kind "include_lib" so consumers resolve against OTP paths' , ( ctx ) => {
137+ if ( ! erlangAvailable ) return ctx . skip ( ) ;
138138 const symbols = parseErlang ( `-include_lib("kernel/include/file.hrl").` ) ;
139139 const imp = symbols . imports . find ( ( i ) => i . source === 'kernel/include/file.hrl' ) ;
140140 expect ( imp ) . toBeDefined ( ) ;
0 commit comments