From cb257c38cab1e94ac0b3d61c6b9e1478b9914fa6 Mon Sep 17 00:00:00 2001 From: Stanislav Lesnikov Date: Wed, 3 Feb 2016 10:02:24 +0100 Subject: [PATCH] Test for https://github.com/dcodeIO/Preprocessor.js/issues/10 --- tests/run.js | 1 + tests/samples/issue10_include.js | 4 ++++ tests/samples/issue10_main.js | 3 +++ tests/test_12.js | 14 ++++++++++++++ 4 files changed, 22 insertions(+) create mode 100644 tests/samples/issue10_include.js create mode 100644 tests/samples/issue10_main.js create mode 100644 tests/test_12.js diff --git a/tests/run.js b/tests/run.js index 6449ea6..f721d02 100644 --- a/tests/run.js +++ b/tests/run.js @@ -12,3 +12,4 @@ require('./test_07_02.js'); require('./test_08.js'); require('./test_09_01.js'); require('./test_09_02.js'); +require('./test_12.js'); diff --git a/tests/samples/issue10_include.js b/tests/samples/issue10_include.js new file mode 100644 index 0000000..eebf6db --- /dev/null +++ b/tests/samples/issue10_include.js @@ -0,0 +1,4 @@ +// #ifndef TEST +// #define var TEST=true +console.log('test'); +// #endif diff --git a/tests/samples/issue10_main.js b/tests/samples/issue10_main.js new file mode 100644 index 0000000..f55e549 --- /dev/null +++ b/tests/samples/issue10_main.js @@ -0,0 +1,3 @@ +// #include "issue10_include.js" +console.log('testing include'); +// #include "issue10_include.js" diff --git a/tests/test_12.js b/tests/test_12.js new file mode 100644 index 0000000..7d7b75b --- /dev/null +++ b/tests/test_12.js @@ -0,0 +1,14 @@ +/* eslint no-console: 0 */ + +var test = require('tape'); + +var Preprocessor = require(__dirname + '/../Preprocessor.js'); +var fs = require('fs'); + +test('test_12:issue10', function(t) { + var pp = new Preprocessor(fs.readFileSync(__dirname + '/samples/issue10_main.js'), __dirname + '/samples'); + var src = pp.process({}, console.log).replace(/\r/g, ''); + t.equal(src, "console.log('test');\nconsole.log('testing include');\n"); + + t.end(); +});