Skip to content

Commit d690182

Browse files
committed
New pascal tests
1 parent b031219 commit d690182

File tree

3 files changed

+40808
-2
lines changed

3 files changed

+40808
-2
lines changed

Diff for: test/pascal-tests.js

+59-2
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,15 @@
2323
// POSSIBILITY OF SUCH DAMAGE.
2424

2525
const chai = require('chai');
26+
const chaiAsPromised = require("chai-as-promised");
2627
const PascalDemangler = require('../lib/pascal-support').demangler;
2728
const PascalCompiler = require('../lib/compilers/pascal');
28-
2929
const CompilationEnvironment = require('../lib/compilation-env');
30+
const fs = require('fs-extra');
31+
const utils = require('../lib/utils');
32+
const logger = require('../lib/logger').logger;
3033

34+
chai.use(chaiAsPromised);
3135
chai.should();
3236

3337
const props = function (key, deflt) {
@@ -49,7 +53,11 @@ describe('Basic compiler setup', function () {
4953

5054
const compiler = new PascalCompiler(info, ce);
5155

52-
compiler.getOutputFilename("/tmp/", "output.pas").should.equal("/tmp/output.s");
56+
if (process.platform == "win32") {
57+
compiler.getOutputFilename("/tmp/", "output.pas").should.equal("\\tmp\\output.s");
58+
} else {
59+
compiler.getOutputFilename("/tmp/", "output.pas").should.equal("/tmp/output.s");
60+
}
5361
});
5462

5563
describe('Pascal signature composer function', function () {
@@ -296,3 +304,52 @@ describe('Pascal Ignored Symbols', function () {
296304
demangler.shouldIgnoreSymbol("Rtti_Output_UserFunction").should.equal(false);
297305
});
298306
});
307+
308+
describe('Pascal ASM line number injection', function () {
309+
const ce = new CompilationEnvironment(props);
310+
const info = {
311+
"exe": null,
312+
"remote": true,
313+
"unitTestMode": true,
314+
"lang": "pascal"
315+
};
316+
317+
ce.compilerPropsL = function (lang, property, defaultValue) {
318+
return "";
319+
};
320+
321+
const compiler = new PascalCompiler(info, ce);
322+
323+
it('Should have line numbering', function() {
324+
return new Promise(function(resolve, reject) {
325+
fs.readFile("test/pascal/asm-example.s", function(err, buffer) {
326+
const asmLines = utils.splitLines(buffer.toString());
327+
compiler.preProcessLines(asmLines);
328+
329+
resolve(Promise.all([
330+
asmLines.should.include("# [output.pas]"),
331+
asmLines.should.include(" .file 1 \"<stdin>\""),
332+
asmLines.should.include("# [13] Square := num * num + 14;"),
333+
asmLines.should.include(" .loc 1 13 0"),
334+
asmLines.should.include(".Le0:"),
335+
asmLines.should.include(" .cfi_endproc")
336+
]));
337+
});
338+
});
339+
});
340+
});
341+
342+
describe('Pascal objdump filtering', function () {
343+
it('Should filter out most of the runtime', function() {
344+
return new Promise(function(resolve, reject) {
345+
fs.readFile("test/pascal/objdump-example.s", function(err, buffer) {
346+
const output = PascalCompiler.preProcessBinaryAsm(buffer.toString());
347+
resolve(Promise.all([
348+
utils.splitLines(output).length.should.be.below(500),
349+
output.should.not.include("fpc_zeromem():"),
350+
output.should.include("SQUARE():")
351+
]));
352+
});
353+
});
354+
});
355+
});

0 commit comments

Comments
 (0)