()
| 19 | const sandbox = sinon.createSandbox(); |
| 20 | |
| 21 | function main() { |
| 22 | program |
| 23 | .version('0.0.1') |
| 24 | .option('-i, --input_dir <path>', 'DB directory.') |
| 25 | .parse(process.argv); |
| 26 | |
| 27 | if (!program.input_dir) { |
| 28 | console.log('Need to specify DB dir.'); |
| 29 | return; |
| 30 | } |
| 31 | |
| 32 | const mutateDb = new db.MutateDb(program.input_dir); |
| 33 | const mutator = new crossOverMutator.CrossOverMutator( |
| 34 | { MUTATE_CROSSOVER_INSERT: 1.0, testing: true }, mutateDb); |
| 35 | |
| 36 | let nPass = 0; |
| 37 | let nFail = 0; |
| 38 | // Iterate over all statements saved in the DB. |
| 39 | for (const statementPath of mutateDb.index.all) { |
| 40 | const expression = JSON.parse(fs.readFileSync( |
| 41 | fsPath.join(program.input_dir, statementPath)), 'utf-8'); |
| 42 | // Stub out choosing random variables in cross-over mutator. |
| 43 | sandbox.stub(random, 'single').callsFake((a) => { return a[0]; }); |
| 44 | // Ensure we are selecting the statement of the current iteration. |
| 45 | sandbox.stub(mutateDb, 'getRandomStatement').callsFake( |
| 46 | () => { return expression; }); |
| 47 | // Use a source that will try to insert one statement, allowing |
| 48 | // super. |
| 49 | const source = sourceHelpers.loadSource( |
| 50 | sourceHelpers.BASE_CORPUS, |
| 51 | 'test_data/cross_over_mutator_class_input.js'); |
| 52 | try { |
| 53 | mutator.mutate(source); |
| 54 | nPass++; |
| 55 | } catch (e) { |
| 56 | console.log('******************************************************') |
| 57 | console.log(expression); |
| 58 | console.log(e.message); |
| 59 | nFail++; |
| 60 | } |
| 61 | sandbox.restore(); |
| 62 | } |
| 63 | console.log(`Result: ${nPass} passed, ${nFail} failed.`) |
| 64 | } |
| 65 | |
| 66 | main(); |
no test coverage detected