(t *testing.T)
| 13 | ) |
| 14 | |
| 15 | func TestArrowFunction(t *testing.T) { |
| 16 | src := `<? fn() => $a;` |
| 17 | |
| 18 | expected := &node.Root{ |
| 19 | Position: &position.Position{ |
| 20 | StartLine: 1, |
| 21 | EndLine: 1, |
| 22 | StartPos: 3, |
| 23 | EndPos: 14, |
| 24 | }, |
| 25 | Stmts: []node.Node{ |
| 26 | &stmt.Expression{ |
| 27 | Position: &position.Position{ |
| 28 | StartLine: 1, |
| 29 | EndLine: 1, |
| 30 | StartPos: 3, |
| 31 | EndPos: 14, |
| 32 | }, |
| 33 | Expr: &expr.ArrowFunction{ |
| 34 | Position: &position.Position{ |
| 35 | StartLine: 1, |
| 36 | EndLine: 1, |
| 37 | StartPos: 3, |
| 38 | EndPos: 13, |
| 39 | }, |
| 40 | ReturnsRef: false, |
| 41 | Static: false, |
| 42 | PhpDocComment: "", |
| 43 | Expr: &expr.Variable{ |
| 44 | Position: &position.Position{ |
| 45 | StartLine: 1, |
| 46 | EndLine: 1, |
| 47 | StartPos: 11, |
| 48 | EndPos: 13, |
| 49 | }, |
| 50 | VarName: &node.Identifier{ |
| 51 | Position: &position.Position{ |
| 52 | StartLine: 1, |
| 53 | EndLine: 1, |
| 54 | StartPos: 11, |
| 55 | EndPos: 13, |
| 56 | }, |
| 57 | Value: "a", |
| 58 | }, |
| 59 | }, |
| 60 | }, |
| 61 | }, |
| 62 | }, |
| 63 | } |
| 64 | |
| 65 | php7parser := php7.NewParser([]byte(src), "7.4") |
| 66 | php7parser.Parse() |
| 67 | actual := php7parser.GetRootNode() |
| 68 | assert.DeepEqual(t, expected, actual) |
| 69 | } |
| 70 | |
| 71 | func TestArrowFunctionReturnType(t *testing.T) { |
| 72 | src := `<? fn & () : foo => $a;` |
nothing calls this directly
no test coverage detected
searching dependent graphs…