Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
122 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* PHP-To-AST - PHP parser | ||
* Copyright (c) Dan Phillimore (asmblah) | ||
* http://uniter.github.com/phptoast/ | ||
* | ||
* Released under the MIT license | ||
* https://github.com/uniter/phptoast/raw/master/MIT-LICENSE.txt | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var _ = require('microdash'), | ||
expect = require('chai').expect, | ||
tools = require('../../tools'); | ||
|
||
describe('PHP Parser grammar mixed type integration', function () { | ||
var parser; | ||
|
||
beforeEach(function () { | ||
parser = tools.createParser(); | ||
}); | ||
|
||
_.each({ | ||
'empty function definition with explicit mixed return type': { | ||
code: 'function myFunc() : mixed {}', | ||
expectedAST: { | ||
name: 'N_PROGRAM', | ||
statements: [{ | ||
name: 'N_FUNCTION_STATEMENT', | ||
func: { | ||
name: 'N_STRING', | ||
string: 'myFunc' | ||
}, | ||
args: [], | ||
body: { | ||
name: 'N_COMPOUND_STATEMENT', | ||
statements: [] | ||
}, | ||
returnType: { | ||
name: 'N_MIXED_TYPE' | ||
} | ||
}] | ||
} | ||
} | ||
}, function (scenario, description) { | ||
describe(description, function () { | ||
var code = '<?php ' + scenario.code; | ||
|
||
// Pretty-print the code strings so any non-printable characters are readable. | ||
describe('when the code is ' + JSON.stringify(code) + ' ?>', function () { | ||
it('should return the expected AST', function () { | ||
expect(parser.parse(code)).to.deep.equal(scenario.expectedAST); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
/* | ||
* PHP-To-AST - PHP parser | ||
* Copyright (c) Dan Phillimore (asmblah) | ||
* http://uniter.github.com/phptoast/ | ||
* | ||
* Released under the MIT license | ||
* https://github.com/uniter/phptoast/raw/master/MIT-LICENSE.txt | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var _ = require('microdash'), | ||
expect = require('chai').expect, | ||
tools = require('../../tools'); | ||
|
||
describe('PHP Parser grammar object type integration', function () { | ||
var parser; | ||
|
||
beforeEach(function () { | ||
parser = tools.createParser(); | ||
}); | ||
|
||
_.each({ | ||
'empty function definition with explicit object return type': { | ||
code: 'function myFunc() : object {}', | ||
expectedAST: { | ||
name: 'N_PROGRAM', | ||
statements: [{ | ||
name: 'N_FUNCTION_STATEMENT', | ||
func: { | ||
name: 'N_STRING', | ||
string: 'myFunc' | ||
}, | ||
args: [], | ||
body: { | ||
name: 'N_COMPOUND_STATEMENT', | ||
statements: [] | ||
}, | ||
returnType: { | ||
name: 'N_OBJECT_TYPE' | ||
} | ||
}] | ||
} | ||
} | ||
}, function (scenario, description) { | ||
describe(description, function () { | ||
var code = '<?php ' + scenario.code; | ||
|
||
// Pretty-print the code strings so any non-printable characters are readable. | ||
describe('when the code is ' + JSON.stringify(code) + ' ?>', function () { | ||
it('should return the expected AST', function () { | ||
expect(parser.parse(code)).to.deep.equal(scenario.expectedAST); | ||
}); | ||
}); | ||
}); | ||
}); | ||
}); |