2016-05-11 08:05:29 +09:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var p2 = require('./preprocessor2.js');
|
|
|
|
var fs = require('fs');
|
2017-05-04 02:16:37 +09:00
|
|
|
var path = require('path');
|
2016-05-11 08:05:29 +09:00
|
|
|
|
|
|
|
var errors = 0;
|
|
|
|
|
2017-05-04 02:16:37 +09:00
|
|
|
var baseDir = path.join(__dirname, 'fixtures_esprima');
|
|
|
|
var files = fs.readdirSync(baseDir).filter(function (name) {
|
|
|
|
return /-expected\./.test(name);
|
|
|
|
}).map(function (name) {
|
|
|
|
return path.join(baseDir, name);
|
|
|
|
});
|
|
|
|
files.forEach(function(expectationFilename) {
|
2016-05-11 08:05:29 +09:00
|
|
|
var inFilename = expectationFilename.replace('-expected', '');
|
2017-05-04 02:16:37 +09:00
|
|
|
var expectation = fs.readFileSync(expectationFilename).toString().trim()
|
2016-05-11 08:05:29 +09:00
|
|
|
.replace(/__filename/g, fs.realpathSync(inFilename));
|
|
|
|
var input = fs.readFileSync(inFilename).toString();
|
|
|
|
|
|
|
|
var defines = {
|
|
|
|
TRUE: true,
|
|
|
|
FALSE: false,
|
Fix the remaining cases of inconsistent spacing and trailing commas in objects, and enable the `comma-dangle` and `object-curly-spacing` ESLint rules
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
*Please note:* This patch was created automatically, using the ESLint `--fix` command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/gulpfile.js b/gulpfile.js
index d18b9c58..7d47fd8d 100644
--- a/gulpfile.js
+++ b/gulpfile.js
@@ -1247,7 +1247,8 @@ gulp.task('gh-pages-git', ['gh-pages-prepare', 'wintersmith'], function () {
var reason = process.env['PDFJS_UPDATE_REASON'];
safeSpawnSync('git', ['init'], { cwd: GH_PAGES_DIR, });
- safeSpawnSync('git', ['remote', 'add', 'origin', REPO], { cwd: GH_PAGES_DIR, });
+ safeSpawnSync('git', ['remote', 'add', 'origin', REPO],
+ { cwd: GH_PAGES_DIR, });
safeSpawnSync('git', ['add', '-A'], { cwd: GH_PAGES_DIR, });
safeSpawnSync('git', [
'commit', '-am', 'gh-pages site created via gulpfile.js script',
```
2017-06-03 00:13:35 +09:00
|
|
|
OBJ: { obj: { i: 1, }, j: 2, },
|
|
|
|
TEXT: 'text',
|
2016-05-11 08:05:29 +09:00
|
|
|
};
|
2017-05-31 10:38:22 +09:00
|
|
|
var map = {
|
|
|
|
'import-alias': 'import-name',
|
|
|
|
};
|
2016-05-11 08:05:29 +09:00
|
|
|
var ctx = {
|
|
|
|
defines: defines,
|
2017-05-31 10:38:22 +09:00
|
|
|
map: map,
|
2016-05-11 08:05:29 +09:00
|
|
|
rootPath: __dirname + '/../..',
|
|
|
|
};
|
|
|
|
var out;
|
|
|
|
try {
|
|
|
|
out = p2.preprocessPDFJSCode(ctx, input);
|
|
|
|
} catch (e) {
|
|
|
|
out = ('Error: ' + e.message).replace(/^/gm, '//');
|
|
|
|
}
|
|
|
|
if (out !== expectation) {
|
2017-01-10 22:32:40 +09:00
|
|
|
errors++;
|
|
|
|
|
2017-05-04 02:16:37 +09:00
|
|
|
console.log('Assertion failed for ' + inFilename);
|
|
|
|
console.log('--------------------------------------------------');
|
|
|
|
console.log('EXPECTED:');
|
|
|
|
console.log(expectation);
|
|
|
|
console.log('--------------------------------------------------');
|
|
|
|
console.log('ACTUAL');
|
|
|
|
console.log(out);
|
|
|
|
console.log('--------------------------------------------------');
|
|
|
|
console.log();
|
2016-05-11 08:05:29 +09:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
if (errors) {
|
2017-05-04 02:16:37 +09:00
|
|
|
console.error('Found ' + errors + ' expectation failures.');
|
|
|
|
process.exit(1);
|
2016-05-11 08:05:29 +09:00
|
|
|
} else {
|
2017-05-04 02:16:37 +09:00
|
|
|
console.log('All tests completed without errors.');
|
|
|
|
process.exit(0);
|
2016-05-11 08:05:29 +09:00
|
|
|
}
|