(t *testing.T)
| 17 | ) |
| 18 | |
| 19 | func TestSimpleFunction(t *testing.T) { |
| 20 | src := `<? function foo() {}` |
| 21 | |
| 22 | expected := &node.Root{ |
| 23 | Position: &position.Position{ |
| 24 | StartLine: 1, |
| 25 | EndLine: 1, |
| 26 | StartPos: 3, |
| 27 | EndPos: 20, |
| 28 | }, |
| 29 | Stmts: []node.Node{ |
| 30 | &stmt.Function{ |
| 31 | Position: &position.Position{ |
| 32 | StartLine: 1, |
| 33 | EndLine: 1, |
| 34 | StartPos: 3, |
| 35 | EndPos: 20, |
| 36 | }, |
| 37 | ReturnsRef: false, |
| 38 | PhpDocComment: "", |
| 39 | FunctionName: &node.Identifier{ |
| 40 | Position: &position.Position{ |
| 41 | StartLine: 1, |
| 42 | EndLine: 1, |
| 43 | StartPos: 12, |
| 44 | EndPos: 15, |
| 45 | }, |
| 46 | Value: "foo", |
| 47 | }, |
| 48 | Stmts: []node.Node{}, |
| 49 | }, |
| 50 | }, |
| 51 | } |
| 52 | |
| 53 | php7parser := php7.NewParser([]byte(src), "7.4") |
| 54 | php7parser.Parse() |
| 55 | actual := php7parser.GetRootNode() |
| 56 | assert.DeepEqual(t, expected, actual) |
| 57 | |
| 58 | php5parser := php5.NewParser([]byte(src), "5.6") |
| 59 | php5parser.Parse() |
| 60 | actual = php5parser.GetRootNode() |
| 61 | assert.DeepEqual(t, expected, actual) |
| 62 | } |
| 63 | |
| 64 | func TestFunctionReturn(t *testing.T) { |
| 65 | src := `<? function foo() {return;}` |
nothing calls this directly
no test coverage detected
searching dependent graphs…