<commit_before>describe 'Pawn', ->

	beforeEach ->
		@whitePawn = new Pawn true
		@blackPawn = new Pawn true
		@board = new Board

	it 'has a type', ->
		expect(@whitePawn.type()).toBe 'Pawn'
		expect(@blackPawn.type()).toBe 'Pawn'

	it 'has a point value', ->
		expect(typeof @whitePawn.pointValue()).toBe "number"
		expect(typeof @blackPawn.pointValue()).toBe "number"

	it "can only move forward one or two spaces if it hasn't moved yet", ->
		moves = @whitePawn.getMoves 1, 1, @board
		expect(moves).toContain [1, 2]
		expect(moves).toContain [1, 3]
		expect(moves.length).toBe 2
		expect(@whitePawn.hasMoved).toBe false

		moves = @blackPawn.getMoves 1, 1, @board
		expect(moves).toContain [1, 2]
		expect(moves).toContain [1, 3]
		expect(moves.length).toBe 2
		expect(@blackPawn.hasMoved).toBe false

	it "can only move forward one or two spaces if it has moved", ->
		@whitePawn.hasMoved = true
		moves = @whitePawn.getMoves 1, 1, @board
		expect(moves).toContain [1, 2]
		expect(moves.length).toBe 1

		@blackPawn.hasMoved = true
		moves = @blackPawn.getMoves 1, 1, @board
		expect(moves).toContain [1, 2]
		expect(moves.length).toBe 1

	it 'can have its movement blocked', ->
		# Block directly in front of it vertically
		@board.set 1, 2, @blackPawn
		moves = @whitePawn.getMoves 1, 1, @board
		expect(moves.length).toBe 0

		@board.set 1, 2, @whitePawn
		moves = @blackPawn.getMoves 1, 1, @board
		expect(moves.length).toBe 0

		# Blocker two spaces in front of it
		@board.set 1, 2, (new BlankPiece)
		@board.set 1, 3, @blackPawn
		moves = @whitePawn.getMoves 1, 1, @board
		expect(moves).toContain [1, 2]
		expect(moves.length).toBe 1

		@board.set 1, 3, @whitePawn
		moves = @blackPawn.getMoves 1, 1, @board
		expect(moves).toContain [1, 2]
		expect(moves.length).toBe 1<commit_msg>Add capture test for pawn<commit_after>describe 'Pawn', ->

	beforeEach ->
		@whitePawn = new Pawn true
		@whitePawn.hasMoved = true
		@blackPawn = new Pawn true
		@blackPawn.hasMoved = true
		@board = new Board

	it 'has a type', ->
		expect(@whitePawn.type()).toBe 'Pawn'
		expect(@blackPawn.type()).toBe 'Pawn'

	it 'has a point value', ->
		expect(typeof @whitePawn.pointValue()).toBe "number"
		expect(typeof @blackPawn.pointValue()).toBe "number"

	it "can only move forward one or two spaces if it hasn't moved yet", ->
		@whitePawn.hasMoved = false
		moves = @whitePawn.getMoves 1, 1, @board
		expect(moves).toContain [1, 2]
		expect(moves).toContain [1, 3]
		expect(moves.length).toBe 2
		expect(@whitePawn.hasMoved).toBe false

		@blackPawn.hasMoved = false
		moves = @blackPawn.getMoves 1, 1, @board
		expect(moves).toContain [1, 2]
		expect(moves).toContain [1, 3]
		expect(moves.length).toBe 2
		expect(@blackPawn.hasMoved).toBe false

	it "can only move forward one space if it has moved", ->
		moves = @whitePawn.getMoves 1, 1, @board
		expect(moves).toContain [1, 2]
		expect(moves.length).toBe 1

		moves = @blackPawn.getMoves 1, 1, @board
		expect(moves).toContain [1, 2]
		expect(moves.length).toBe 1

	it 'can have its movement blocked', ->
		# Block directly in front of it vertically
		@board.set 1, 2, @blackPawn
		moves = @whitePawn.getMoves 1, 1, @board
		expect(moves.length).toBe 0

		@board.set 1, 2, @whitePawn
		moves = @blackPawn.getMoves 1, 1, @board
		expect(moves.length).toBe 0

		# Blocker two spaces in front of it
		@board.set 1, 2, (new BlankPiece)
		@board.set 1, 3, @blackPawn
		moves = @whitePawn.getMoves 1, 1, @board
		expect(moves).toContain [1, 2]
		expect(moves.length).toBe 1

		@board.set 1, 3, @whitePawn
		moves = @blackPawn.getMoves 1, 1, @board
		expect(moves).toContain [1, 2]
		expect(moves.length).toBe 1

	it "can capture diagonally", ->
		# In front and to the left
		@board.set 1, 3, @blackPawn
		moves = @whitePawn.getMoves 2, 2, @board
		expect(moves).toContain([1,3])

		# In front and to the right
		@board.set 3, 3, @blackPawn
		moves = @whitePawn.getMoves 2, 2, @board
		expect(moves).toContain([3,3])

		# In front and to the left
		@board.set 1, 3, @whitePawn
		moves = @blackPawn.getMoves 2, 2, @board
		expect(moves).toContain([1,3])

		# In front and to the right
		@board.set 3, 3, @whitePawn
		moves = @blackPawn.getMoves 2, 2, @board
		expect(moves).toContain([3,3])
{'fraction_non_alphanumeric': 0.13955135773317592, 'fraction_numerical': 0.029279811097992915, 'mean_word_length': 3.8136363636363635, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 18, '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': '3855986', 'n_tokens_mistral': 1873, 'n_tokens_neox': 1635, 'n_words': 451}