<commit_before>describe('Game', function() {
  var Game;

  // Load modules
  beforeEach(module('ngGo.Game.Service'));

  // Get injectable functions
  beforeEach(inject(function(_Game_) {
    Game = _Game_;
  }));

  it('#clone', function() {
    var sgf = '(;SZ[9];B[cg];W[gc])';
    var game = new Game(sgf);
    var clonedGame = game.clone();
    expect(game).toEqual(clonedGame);
  });
});<commit_msg>Add failing game test for checking repeated moves.<commit_after>describe('Game', function() {
  var StoneColor;
  var InvalidPositionError;
  var Game;

  // Load modules
  beforeEach(module('ngGo'));
  beforeEach(module('ngGo.Errors.InvalidPositionError.Service'));
  beforeEach(module('ngGo.Game.Service'));

  // Get injectable functions
  beforeEach(inject(function(_StoneColor_, _InvalidPositionError_, _Game_) {
    StoneColor = _StoneColor_;
    InvalidPositionError = _InvalidPositionError_;
    Game = _Game_;
  }));

  // Specify SGF files
  beforeEach(function() {
    this.sgfSimple = '(;SZ[9];B[cg];W[gc])';
    this.sgfRepeatingKo = '(;SZ[9]' +
      ';B[db];W[cb];B[ec];W[dc];B[dd];W[bc];B[gc];W[cd];B[cc])';
    this.sgfRepeatingAll = '(;SZ[9]' +
      ';B[db];W[cb];B[ec];W[dc];B[dd];W[bc];B[gc];W[cd];B[cc];W[fc];B[hd];W[ed];B[ge];W[fe]' +
      ';B[fd];W[gd];B[df];W[cf];B[eg];W[bg];B[dh];W[ch];B[cg];W[dg];B[fd];W[dc];B[cg];W[gd])';
  });

  it('#clone', function() {
    var game = new Game(this.sgfSimple);
    var clonedGame = game.clone();
    expect(game).toEqual(clonedGame);
  });

  describe('#play', function() {
    function createGames() {
      this.gameSimple = new Game(this.sgfSimple, this.config);
      this.gameRepeatingKo = new Game(this.sgfRepeatingKo, this.config);
      this.gameRepeatingAll = new Game(this.sgfRepeatingAll, this.config);
    }

    function goToLastMove() {
      this.gameSimple.last();
      this.gameRepeatingKo.last();
      this.gameRepeatingAll.last();
    }

    it('with checking disabled', function() {
      // Set config
      this.config = {
        checkRepeat: null
      };
      // Create games
      createGames.call(this);
      // Go to last move
      goToLastMove.call(this);
      // Verify
      expect(this.gameSimple.play.bind(this.gameSimple, 2, 2, StoneColor.BLACK)).not.toThrow();
      expect(this.gameRepeatingKo.play.bind(this.gameRepeatingKo, 3, 2, StoneColor.BLACK)).not.toThrow();
      expect(this.gameRepeatingAll.play.bind(this.gameRepeatingAll, 2, 2, StoneColor.BLACK)).not.toThrow();
    });

    it('with Ko checking enabled', function() {
      // Set config
      this.config = {
        checkRepeat: 'KO'
      };
      // Create games
      createGames.call(this);
      // Go to last move
      goToLastMove.call(this);
      // Verify
      expect(this.gameSimple.play.bind(this.gameSimple, 2, 2, StoneColor.BLACK)).not.toThrow();
      expect(this.gameRepeatingKo.play.bind(this.gameRepeatingKo, 3, 2, StoneColor.BLACK))
        .toThrowError(InvalidPositionError);
      expect(this.gameRepeatingAll.play.bind(this.gameRepeatingAll, 2, 2, StoneColor.BLACK)).not.toThrow();
    });

    it('with all checking enabled', function() {
      // Set config
      this.config = {
        checkRepeat: 'ALL'
      };
      // Create games
      createGames.call(this);
      // Go to last move
      goToLastMove.call(this);
      // Verify
      expect(this.gameSimple.play.bind(this.gameSimple, 2, 2, StoneColor.BLACK)).not.toThrow();
      expect(this.gameRepeatingKo.play.bind(this.gameRepeatingKo, 3, 2, StoneColor.BLACK))
        .toThrowError(InvalidPositionError);
      expect(this.gameRepeatingAll.play.bind(this.gameRepeatingAll, 2, 2, StoneColor.BLACK))
        .toThrowError(InvalidPositionError);
    });
  });
});
{'fraction_non_alphanumeric': 0.17215528781793843, 'fraction_numerical': 0.005890227576974565, 'mean_word_length': 3.3543123543123543, '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': '1843262', 'n_tokens_mistral': 1349, 'n_tokens_neox': 1296, 'n_words': 197}