pdf.js/external/builder/test-fixtures_esprima.js
Jonas Jenwald 4a906955c4 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 23:35:37 +02:00

63 lines
1.6 KiB
JavaScript

'use strict';
var p2 = require('./preprocessor2.js');
var fs = require('fs');
var path = require('path');
var errors = 0;
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) {
var inFilename = expectationFilename.replace('-expected', '');
var expectation = fs.readFileSync(expectationFilename).toString().trim()
.replace(/__filename/g, fs.realpathSync(inFilename));
var input = fs.readFileSync(inFilename).toString();
var defines = {
TRUE: true,
FALSE: false,
OBJ: { obj: { i: 1, }, j: 2, },
TEXT: 'text',
};
var map = {
'import-alias': 'import-name',
};
var ctx = {
defines: defines,
map: map,
rootPath: __dirname + '/../..',
};
var out;
try {
out = p2.preprocessPDFJSCode(ctx, input);
} catch (e) {
out = ('Error: ' + e.message).replace(/^/gm, '//');
}
if (out !== expectation) {
errors++;
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();
}
});
if (errors) {
console.error('Found ' + errors + ' expectation failures.');
process.exit(1);
} else {
console.log('All tests completed without errors.');
process.exit(0);
}