File tree Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Expand file tree Collapse file tree 1 file changed +36
-0
lines changed Original file line number Diff line number Diff line change
1
+ var should = require ( "should" ) ;
2
+ var parser = require ( '../../main' ) ;
3
+
4
+ describe ( 'Function tests' , function ( ) {
5
+
6
+ it ( 'test variadic' , function ( ) {
7
+ // Get result from parser
8
+ var ast = parser . parseEval ( 'function &foo($a = 1, array &...$params) {}' ) ;
9
+ var fn = ast [ 1 ] [ 0 ] ;
10
+ fn [ 0 ] . should . be . exactly ( 'function' ) ;
11
+ fn [ 1 ] . should . be . exactly ( 'foo' ) ;
12
+
13
+ var args = fn [ 2 ] ;
14
+ args . length . should . be . exactly ( 2 ) ;
15
+
16
+ // 1st param
17
+ var arg1 = args [ 0 ] ;
18
+ arg1 [ 0 ] . should . be . exactly ( 'param' ) ;
19
+ arg1 [ 1 ] . should . be . exactly ( '$a' ) ;
20
+ should . equal ( arg1 [ 2 ] , null ) ;
21
+ arg1 [ 3 ] [ 0 ] . should . be . exactly ( 'number' ) ;
22
+ arg1 [ 3 ] [ 1 ] . should . be . exactly ( '1' ) ;
23
+ arg1 [ 4 ] . should . be . exactly ( false , 'not byref' ) ;
24
+ arg1 [ 5 ] . should . be . exactly ( false , 'not variadic' ) ;
25
+
26
+ // 2nd param
27
+ var arg2 = args [ 1 ] ;
28
+ arg2 [ 0 ] . should . be . exactly ( 'param' ) ;
29
+ arg2 [ 1 ] . should . be . exactly ( '$params' ) ;
30
+ arg2 [ 2 ] [ 0 ] . should . be . exactly ( 'array' ) ;
31
+ should . equal ( arg2 [ 3 ] , null ) ;
32
+ arg2 [ 4 ] . should . be . exactly ( true , 'byref' ) ;
33
+ arg2 [ 5 ] . should . be . exactly ( true , 'variadic' ) ;
34
+ } ) ;
35
+
36
+ } ) ;
You can’t perform that action at this time.
0 commit comments