Skip to content

1.0.0 #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 71 commits into from
Jan 1, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
76aa80e
Merge pull request #44 from glayzzle/master
ichiriac Dec 27, 2016
37a17ae
implement nodes flags & add tests on classes
ichiriac Dec 27, 2016
b9b63cb
implement traits usage
ichiriac Dec 27, 2016
0249eb4
fix doc
ichiriac Dec 27, 2016
a90dd4f
start tests over trait & interface nodes
ichiriac Dec 27, 2016
1182236
rebuild nodes tree
ichiriac Dec 27, 2016
24f84ca
fix documentation nodes implementation
ichiriac Dec 27, 2016
7e2e192
fix documentation nodes implementation
ichiriac Dec 27, 2016
3fe2360
add interface node
ichiriac Dec 27, 2016
96d38f3
implement trait nodes
ichiriac Dec 27, 2016
170c7ee
rename documentation to doc
ichiriac Dec 27, 2016
9cfdf55
fix function & rename children as body
ichiriac Dec 27, 2016
9d14c69
fix trait insteadof -> identifier[]
ichiriac Dec 27, 2016
20860e3
add a new read_name_list helper
ichiriac Dec 27, 2016
deacdb4
https://github.com/glayzzle/php-parser/issues/11 change the expect re…
ichiriac Dec 27, 2016
59d2866
ignore plateform specific code
ichiriac Dec 28, 2016
7980c44
code array becomes code block nodes
ichiriac Dec 28, 2016
5ecbf5a
implement if node
ichiriac Dec 28, 2016
78f1132
fix coverage on if statements
ichiriac Dec 28, 2016
a40736e
isolate generic function into a utils.js file
ichiriac Dec 28, 2016
b99d1c8
fix doc, use block node instead []
ichiriac Dec 28, 2016
8e9ba7f
implement while & do nodes
ichiriac Dec 28, 2016
353ada4
implement for nodes
ichiriac Dec 28, 2016
1b38288
fix list node
ichiriac Dec 28, 2016
4ea9ac0
fix & byref for vars
ichiriac Dec 28, 2016
4005e58
add a list node
ichiriac Dec 28, 2016
ebae0aa
add coverage on list statements - wip
ichiriac Dec 28, 2016
136d2bf
add foreach node & rebuild docs
ichiriac Dec 28, 2016
fc06912
remove old tests installation requirements
ichiriac Dec 28, 2016
2c8a405
avoid including other docs into readme
ichiriac Dec 28, 2016
28d255d
https://github.com/glayzzle/php-parser-tests/issues/1
ichiriac Dec 28, 2016
89bb053
https://github.com/glayzzle/php-parser-tests/issues/1
ichiriac Dec 28, 2016
73efd7f
prepare release text
ichiriac Dec 28, 2016
c292bc6
fix tests
ichiriac Dec 28, 2016
eeff19c
remove unused references
ichiriac Dec 28, 2016
b748a0d
remove old dependencies
ichiriac Dec 28, 2016
3a59f39
fix coverage
ichiriac Dec 28, 2016
b952c64
update texts
ichiriac Dec 28, 2016
67c9d01
enable open/close tags on eval mode
ichiriac Dec 28, 2016
84ef031
implement switch, case, break nodes
ichiriac Dec 28, 2016
794d765
implement switch, case, break nodes
ichiriac Dec 28, 2016
d520b9f
add goto, label, post nodes
ichiriac Dec 28, 2016
b7f1483
cache node modules in order to speed up builds
ichiriac Dec 28, 2016
2fdd9fa
add try/catch and call nodes
ichiriac Dec 28, 2016
1721238
implement namespace & use nodes (fix https://github.com/glayzzle/php-…
ichiriac Dec 29, 2016
4585ca4
fix https://github.com/glayzzle/php-parser/issues/45 & add some tests
ichiriac Dec 29, 2016
daaf93e
add bin, cast & unary nodes
ichiriac Dec 29, 2016
f674b9f
add bin, cast & unary nodes
ichiriac Dec 29, 2016
aab775b
add bool & retif nodes
ichiriac Dec 30, 2016
88871e0
add silent node
ichiriac Dec 30, 2016
5747a93
add pre node
ichiriac Dec 30, 2016
0bdb379
add new node
ichiriac Dec 30, 2016
ae9fea9
cover ast.js
ichiriac Dec 30, 2016
d75ddd7
add closure node
ichiriac Dec 30, 2016
f74c40a
improve strings coverage on lexer
ichiriac Dec 30, 2016
59760a8
test here doc on lexer
ichiriac Dec 30, 2016
0206c33
rename var.identifier to var.name + enable array tests
ichiriac Dec 30, 2016
adb7f39
fix columns implementation
ichiriac Dec 30, 2016
4039451
fix positions retrieval
ichiriac Dec 30, 2016
91010c0
eat next token before result (fix positions)
ichiriac Dec 30, 2016
4c87f29
fix positions on assign nodes
ichiriac Dec 30, 2016
78ca985
fix var name location
ichiriac Dec 30, 2016
a874732
enable new tests
ichiriac Dec 30, 2016
cdb9f42
fix & test simple_variable parsing
ichiriac Dec 30, 2016
55c96a7
add new lookup nodes & migrate vars (wip)
ichiriac Dec 30, 2016
2143b98
add the static lookup node
ichiriac Dec 30, 2016
ad2b9ab
add global node
ichiriac Dec 31, 2016
0573362
start testing numbers
ichiriac Jan 1, 2017
1901702
cover tests on initial parser
ichiriac Jan 1, 2017
a64128b
fix comment lexing & add tests (wip)
ichiriac Jan 1, 2017
6fd68be
fix scalar endeless loop (edge) + cover strings lexer
ichiriac Jan 1, 2017
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
enable new tests
  • Loading branch information
ichiriac committed Dec 30, 2016
commit a874732eedc3748a377e790fa5f5e2b6f126292c
17 changes: 0 additions & 17 deletions test/astTests.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,23 +9,6 @@ describe('Test AST structure', function() {
ast.children.length.should.be.exactly(0);
});

it('test withSource options', function() {
var ast = parser.parseEval('$a = true;', {
ast: {
withSource: true
}
});
// @todo
});
it('test withPositions options', function() {
var ast = parser.parseEval('$a = true;', {
ast: {
withPositions: true
}
});
// @todo
});

it('test inline', function() {
var ast = parser.parseCode('Hello <?php echo "World"; ?> !');
ast.children[0].kind.should.be.exactly('inline');
Expand Down
31 changes: 18 additions & 13 deletions test/gracefulTests.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var should = require("should");
var parser = require('../src/index');

/*describe('Test graceful mode', function() {
describe('Test graceful mode', function() {

describe('to suppress errors', function() {

Expand All @@ -21,50 +21,55 @@ var parser = require('../src/index');
'}', // 4.
'}' // 5. <-- extra '}' token here
].join('\n'));
ast[2].length.should.be.exactly(2);
ast[1][0][2][5][0][2][0].should.be.exactly('error');
ast.errors.length.should.be.exactly(2);
// @todo ast[1][0][2][5][0][2][0].should.be.exactly('error');
});

it('test expr', function () {
var ast = test.parseEval('$a = $b -; $foo = $a;');

ast[2].length.should.be.exactly(2);
ast[1].length.should.be.exactly(2);
ast.errors.length.should.be.exactly(2);
ast.children.length.should.be.exactly(2);

/** @todo
ast[1][0][2][0].should.be.exactly('bin');
ast[1][0][2][1].should.be.exactly('-');
ast[1][0][2][3][0].should.be.exactly('error');

ast[1][1][0].should.be.exactly('set');
ast[1][1][1][0].should.be.exactly('var');
ast[1][1][1][1].should.be.exactly('$foo');
*/
});

it('test class', function () {
var ast = test.parseEval('class foo { foo const A = 1 ');

ast[2].length.should.be.exactly(3);
ast[1].length.should.be.exactly(1);
ast.errors.length.should.be.exactly(3);
ast.children.length.should.be.exactly(1);

/** @todo
ast[1][0][0].should.be.exactly('class');
ast[1][0][1].should.be.exactly('foo');
ast[1][0][5].length.should.be.exactly(2); // including the foo error
ast[1][0][5][0][0].should.be.exactly('error');
ast[1][0][5][1][0].should.be.exactly('const');
ast[1][0][5][1][1].should.be.exactly('A');
ast[1][0][5][1][2][1].should.be.exactly('1');
*/

});

it('test flags', function () {
var ast = test.parseEval('final final interface foo { abstract function func() ');
ast[2].length.should.be.exactly(4);
ast[1].length.should.be.exactly(2);
ast[1][0][0].should.be.exactly('error');
ast[1][1][0].should.be.exactly('interface');
var ast = test.parseEval([
'final final interface foo {',
' abstract function func() '
].join('\n'));
ast.errors.length.should.be.exactly(4);
ast.children.length.should.be.exactly(1);
ast.children[0].kind.should.be.exactly('interface');
});

});

});
*/
150 changes: 132 additions & 18 deletions test/locationTests.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,141 @@
var should = require("should");
var parser = require('../src/index');

/*describe('Test offsets', function() {
describe('Test offsets', function() {

describe('to check offsets', function() {
// init a new parser instance
var test = parser.create({
ast: {
withPositions: true,
withSource: true
},
parser: {
extractDoc: true,
debug: true
},
lexer: {
debug: true
}
});

var lines = [
'// a comment',
'echo "string";',
'$a = true;'
];
var text = lines.join('\r\n');
var ast = test.parseEval(text);

describe('to program node', function() {
it('test line', function() {
ast.loc.start.line.should.be.exactly(1);
ast.loc.end.line.should.be.exactly(lines.length);
});
it('test column', function() {
ast.loc.start.column.should.be.exactly(0);
ast.loc.end.column.should.be.exactly(
lines[lines.length - 1].length
);
});
it('test offsets', function() {
ast.loc.start.offset.should.be.exactly(0);
ast.loc.end.offset.should.be.exactly(text.length);
});
});

// init a new parser instance
var text = [
' // a comment ',
'echo "string";'
].join('\r\n');
var ast = parser.parseEval(
text,
{
parser: {
locations: true
}
}
);
/** @fixme should test & fix offsets **-/
// console.log(ast[1]);
describe('to comment node', function() {
it('test line', function() {
ast.children[0].loc.start.line.should.be.exactly(1);
ast.children[0].loc.end.line.should.be.exactly(2);
});
it('test column', function() {
ast.children[0].loc.start.column.should.be.exactly(0);
ast.children[0].loc.end.column.should.be.exactly(0);
});
it('test offsets', function() {
ast.children[0].loc.start.offset.should.be.exactly(0);
ast.children[0].loc.end.offset.should.be.exactly(
lines[0].length + 2 // first line + \r\n
);
ast.children[0].loc.source.should.be.exactly(lines[0] + '\r\n');
});
});

describe('on echo node', function() {
it('test line', function() {
ast.children[1].loc.start.line.should.be.exactly(2);
ast.children[1].loc.end.line.should.be.exactly(2);
});
it('test column', function() {
ast.children[1].loc.start.column.should.be.exactly(0);
ast.children[1].loc.end.column.should.be.exactly(14);
});
it('test offsets', function() {
ast.children[1].loc.start.offset.should.be.exactly(14);
ast.children[1].loc.end.offset.should.be.exactly(28);
ast.children[1].loc.source.should.be.exactly(lines[1]);
});
});

describe('on text node', function() {
var arg = ast.children[1].arguments[0];
it('test line', function() {
arg.loc.start.line.should.be.exactly(2);
arg.loc.end.line.should.be.exactly(2);
});
it('test column', function() {
arg.loc.start.column.should.be.exactly(5);
arg.loc.end.column.should.be.exactly(13);
});
it('test offsets', function() {
arg.loc.source.should.be.exactly('"string"');
});
});

describe('on assign node', function() {
it('test line', function() {
ast.children[2].loc.start.line.should.be.exactly(3);
ast.children[2].loc.end.line.should.be.exactly(3);
});
it('test column', function() {
ast.children[2].loc.start.column.should.be.exactly(0);
// ignored ';' because it was eaten by expr and assign
// was retrieved by expr_item without it
ast.children[2].loc.end.column.should.be.exactly(9);
});
it('test offsets', function() {
ast.children[2].loc.source.should.be.exactly(lines[2].substring(0, 9));
});
});

describe('on variable node', function() {
var node = ast.children[2].left;
it('test line', function() {
node.loc.start.line.should.be.exactly(3);
node.loc.end.line.should.be.exactly(3);
});
it('test column', function() {
node.loc.start.column.should.be.exactly(0);
node.loc.end.column.should.be.exactly(2);
});
it('test offsets', function() {
node.loc.source.should.be.exactly('$a');
});
});

describe('on boolean node', function() {
var node = ast.children[2].right;
it('test line', function() {
node.loc.start.line.should.be.exactly(3);
node.loc.end.line.should.be.exactly(3);
});
it('test column', function() {
node.loc.start.column.should.be.exactly(5);
node.loc.end.column.should.be.exactly(9);
});
it('test offsets', function() {
node.loc.source.should.be.exactly('true');
});
});

});
*/