blob: 9685e6e06001b14ae38d0e84ee50a8f50c624c49 [file] [log] [blame] [raw]
const chai = require('chai'),
cfg = require('../lib/cfg'),
fs = require('fs');
const cases = fs.readdirSync(__dirname + '/cases/')
.filter(x => x.match(/cfg-\w*/))
.map(x => __dirname + '/cases/' + x);
const assert = chai.assert;
function common(cases, filterArg, cfgArg) {
cases.filter(x => x.includes(filterArg))
.forEach(filename => {
const file = fs.readFileSync(filename, 'utf-8');
if (file) {
const contents = JSON.parse(file);
assert.deepEqual(cfg.generateStructure(cfgArg, contents.asm), contents.cfg, `${filename}`);
}
});
}
describe('Cfg test cases', () => {
it('works for gcc', () => {
common(cases, "gcc", "g++");
});
it('works for clang', () => {
common(cases, "clang", "clang");
});
});