<commit_before>'use strict';

var expect = require('chai').expect;
import BaseOperatorMutation from '../../../src/mutations/BaseOperatorMutation';
import Mutant from '../../../src/Mutant';
import ParserUtils from '../../../src/utils/ParserUtils';
require('mocha-sinon');

describe('BaseOperatorMutation', function() {
  describe('should recognize', function() {
    it('one of its own mutation operators as a part of its mutation', function() {
      var node = {
        type: 'SomeType',
        operator: '+'
      };
      //TODO: Change the creation of a new BaseOperatorMutation to the creation of a locally defined implementation of BaseOperatorMutation
      var baseOperatorMutation = new BaseOperatorMutation('name', ['SomeOtherType', node.type], {
        '+': '-'
      });

      var recognized = baseOperatorMutation.canMutate(node);

      expect(recognized).to.equal(true);
    });
  });

  describe('should not recognize', function() {
    it('an unknown mutation operator', function() {
      var node = {
        type: 'SomeType',
        operator: 'some operator which should not be known to the BaseOperatorMutation'
      };
      //TODO: Change the creation of a new BaseOperatorMutation to the creation of a locally defined implementation of BaseOperatorMutation
      var baseOperatorMutation = new BaseOperatorMutation('name', [node.type], {
        '+': '-'
      });

      var recognized = baseOperatorMutation.canMutate(node);

      expect(recognized).to.equal(false);
    });

    it('a node with a different type', function() {
      var node = {
        type: 'SomeDifferentType',
        operator: '+'
      };
      //TODO: Change the creation of a new BaseOperatorMutation to the creation of a locally defined implementation of BaseOperatorMutation
      var baseOperatorMutation = new BaseOperatorMutation('name', ['SomeType'], {
        '+': '-'
      });

      var recognized = baseOperatorMutation.canMutate(node);

      expect(recognized).to.equal(false);
    });
  });

  it('should set the correct column number', function() {
    this.sinon.stub(Mutant.prototype, 'save');
    var code = 'var i = 5 * 3;';
    var column = 11;
    //TODO: Change the creation of a new BaseOperatorMutation to the creation of a locally defined implementation of BaseOperatorMutation
    var baseOperatorMutation = new BaseOperatorMutation('name', ['SomeType'], {
      '*': '/'
    });
    var parserUtils = new ParserUtils();
    var ast = parserUtils.parse(code);
    var node = ast.body[0].declarations[0].init;
    var mutants = baseOperatorMutation.applyMutation('hello.js', code, node, ast);
    var actualColumn = mutants[0].getColumnNumber();<commit_msg>Fixed BaseOperatorMutaitonSpec creating an instance of BaseOperatorMutation instead of creating a mock class<commit_after>'use strict';

var expect = require('chai').expect;
import BaseOperatorMutation from '../../../src/mutations/BaseOperatorMutation';
import Mutant from '../../../src/Mutant';
import ParserUtils from '../../../src/utils/ParserUtils';
require('mocha-sinon');

describe('BaseOperatorMutation', function() {
  class MockBaseOperatorMutation extends BaseOperatorMutation {
    constructor(){super('Mock', ['SomeType', 'SomeOtherType'], {
      '+': '-',
      '*': '/'
    });
    }
  }
  describe('should recognize', function() {
    it('one of its own mockMutation operators as a part of its mockMutation', function() {
      var node = {
        type: 'SomeType',
        operator: '+'
      };
      
      var mockMutation = new MockBaseOperatorMutation();

      var recognized = mockMutation.canMutate(node);

      expect(recognized).to.equal(true);
    });
  });

  describe('should not recognize', function() {
    it('an unknown mockMutation operator', function() {
      var node = {
        type: 'SomeType',
        operator: 'some operator which should not be known to the BaseOperatorMutation'
      };
      
      var mockMutation = new MockBaseOperatorMutation();

      var recognized = mockMutation.canMutate(node);

      expect(recognized).to.equal(false);
    });

    it('a node with a different type', function() {
      var node = {
        type: 'SomeDifferentType',
        operator: '+'
      };
      
      var mockMutation = new MockBaseOperatorMutation();

      var recognized = mockMutation.canMutate(node);

      expect(recognized).to.equal(false);
    });
  });

  it('should set the correct column number', function() {
    this.sinon.stub(Mutant.prototype, 'save');
    var code = 'var i = 5 * 3;';
    var column = 11;
    var mockMutation = new MockBaseOperatorMutation();
    var parserUtils = new ParserUtils();
    var ast = parserUtils.parse(code);
    var node = ast.body[0].declarations[0].init;
    
    var mutants = mockMutation.applyMutation('hello.js', code, node, ast);
    var actualColumn = mutants[0].getColumnNumber();
{'fraction_non_alphanumeric': 0.13267813267813267, 'fraction_numerical': 0.0028665028665028664, 'mean_word_length': 3.1680887372013653, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1362691', 'n_tokens_mistral': 1375, 'n_tokens_neox': 1333, 'n_words': 379}