<commit_before>package org.ringingmaster.engine.parser.assignparse;

import org.junit.Test;
import org.ringingmaster.engine.NumberOfBells;
import org.ringingmaster.engine.notation.NotationBody;
import org.ringingmaster.engine.notation.impl.NotationBuilder;
import org.ringingmaster.engine.parser.Parse;
import org.ringingmaster.engine.touch.newcontainer.ObservableTouch;
import org.ringingmaster.engine.touch.newcontainer.checkingtype.CheckingType;

import static org.junit.Assert.assertEquals;
import static org.ringingmaster.engine.parser.AssertParse.assertParse;
import static org.ringingmaster.engine.parser.AssertParse.valid;
import static org.ringingmaster.engine.parser.ParseType.CALL;
import static org.ringingmaster.engine.parser.ParseType.CALL_MULTIPLIER;
import static org.ringingmaster.engine.touch.newcontainer.TableType.TOUCH_TABLE;
import static org.ringingmaster.engine.touch.newcontainer.checkingtype.CheckingType.COURSE_BASED;

/**
 * TODO comments???
 *
 * @author stevelake
 */
public class AssignMultiplierTest {

    @Test
    public void parsingEmptyParseReturnsEmptyParse() {
        ObservableTouch touch = buildSingleCellTouch(buildPlainBobMinor(), null);
        Parse parse = new AssignParseType().apply(touch.get());
        Parse result = new AssignMultiplier().apply(parse);

        assertEquals(0, result.allTouchCells().getRowSize());
        assertEquals(0, result.allTouchCells().getColumnSize());
    }

    @Test
    public void parsingAllCellTypesReturnsOriginals() {
        ObservableTouch touch = buildSingleCellTouch(buildPlainBobMinor(), null);
        touch.setTouchCheckingType(COURSE_BASED);

        touch.addCharacters(TOUCH_TABLE, 0,0, "CALL_POSITION");
        touch.addCharacters(TOUCH_TABLE, 1,0, "MAIN_BODY");
        touch.addCharacters(TOUCH_TABLE, 1,1, "SPLICE");
        touch.addCharacters(TOUCH_TABLE, 2,0, "CALL");// To force the Parse to be replaced
        touch.addCharacters(TOUCH_TABLE, 2,1, "CALL");// To force the Parse to be replaced

        Parse parse = new AssignParseType().apply(touch.get());
        Parse result = new AssignMultiplier().apply(parse);

        assertEquals(3, result.allTouchCells().getRowSize());
        assertEquals(2, result.allTouchCells().getColumnSize());
        assertEquals("CALL_POSITION", result.allTouchCells().get(0,0).getCharacters());
        assertEquals("MAIN_BODY", result.allTouchCells().get(1,0).getCharacters());
        assertEquals("SPLICE", result.allTouchCells().get(1,1).getCharacters());
    }


    @Test
	public void correctlyParseSingleDefaultCallMultiplier() {
        ObservableTouch touch = buildSingleCellTouch(buildPlainBobMinor(), "-2");
        Parse parse = new AssignParseType().apply(touch.get());
        assertParse(parse.allTouchCells().get(0,0), valid(CALL), valid(CALL_MULTIPLIER));
	}

//	@Test
//	public void correctlyParseMultiDefaultCallMultiplier() {
//		DefaultTouch touch = buildAndParseSingleCellTouch(buildPlainBobMinor(), "s22");
//		assertParseType(touch.getCell_FOR_TEST_ONLY(0, 0), ParseType.CALL, ParseType.DEFAULT_CALL_MULTIPLIER, ParseType.DEFAULT_CALL_MULTIPLIER);
//	}
//
//	@Test
//	public void correctlyParseDefaultCallMultiplierBeforeWhitespace() {
//		DefaultTouch touch = buildAndParseSingleCellTouch(buildPlainBobMinor(), "2 ");
//		assertParseType(touch.getCell_FOR_TEST_ONLY(0, 0), ParseType.DEFAULT_CALL_MULTIPLIER, ParseType.WHITESPACE);<commit_msg>fixup tests<commit_after>package org.ringingmaster.engine.parser.assignparse;

import org.junit.Test;
import org.ringingmaster.engine.NumberOfBells;
import org.ringingmaster.engine.notation.NotationBody;
import org.ringingmaster.engine.notation.impl.NotationBuilder;
import org.ringingmaster.engine.parser.Parse;
import org.ringingmaster.engine.touch.newcontainer.ObservableTouch;
import org.ringingmaster.engine.touch.newcontainer.checkingtype.CheckingType;

import static org.junit.Assert.assertEquals;
import static org.ringingmaster.engine.parser.AssertParse.assertParse;
import static org.ringingmaster.engine.parser.AssertParse.valid;
import static org.ringingmaster.engine.parser.ParseType.CALL;
import static org.ringingmaster.engine.parser.ParseType.CALL_MULTIPLIER;
import static org.ringingmaster.engine.touch.newcontainer.TableType.TOUCH_TABLE;
import static org.ringingmaster.engine.touch.newcontainer.checkingtype.CheckingType.COURSE_BASED;

/**
 * TODO comments???
 *
 * @author stevelake
 */
public class AssignMultiplierTest {

    @Test
    public void parsingEmptyParseReturnsEmptyParse() {
        ObservableTouch touch = buildSingleCellTouch(buildPlainBobMinor(), null);
        Parse parse = new AssignParseType().apply(touch.get());
        Parse result = new AssignMultiplier().apply(parse);

        assertEquals(0, result.allTouchCells().getRowSize());
        assertEquals(0, result.allTouchCells().getColumnSize());
    }

    @Test
    public void parsingAllCellTypesReturnsOriginals() {
        ObservableTouch touch = buildSingleCellTouch(buildPlainBobMinor(), null);
        touch.setTouchCheckingType(COURSE_BASED);

        touch.addCharacters(TOUCH_TABLE, 0,0, "CALL_POSITION");
        touch.addCharacters(TOUCH_TABLE, 1,0, "MAIN_BODY");
        touch.addCharacters(TOUCH_TABLE, 1,1, "SPLICE");
        touch.addCharacters(TOUCH_TABLE, 2,0, "CALL");// To force the Parse to be replaced
        touch.addCharacters(TOUCH_TABLE, 2,1, "CALL");// To force the Parse to be replaced

        Parse parse = new AssignParseType().apply(touch.get());
        Parse result = new AssignMultiplier().apply(parse);

        assertEquals(3, result.allTouchCells().getRowSize());
        assertEquals(2, result.allTouchCells().getColumnSize());
        assertEquals("CALL_POSITION", result.allTouchCells().get(0,0).getCharacters());
        assertEquals("MAIN_BODY", result.allTouchCells().get(1,0).getCharacters());
        assertEquals("SPLICE", result.allTouchCells().get(1,1).getCharacters());
    }


    @Test
	public void correctlyParseSingleDefaultCallMultiplier() {
        ObservableTouch touch = buildSingleCellTouch(buildPlainBobMinor(), "-2");
        Parse parse = new AssignParseType().apply(touch.get());
        assertParse(parse.allTouchCells().get(0,0), valid(CALL), valid(CALL_MULTIPLIER));
	}
//TODO
//	@Test
//	public void correctlyParseMultiDefaultCallMultiplier() {
//		DefaultTouch touch = buildAndParseSingleCellTouch(buildPlainBobMinor(), "s22");
//		assertParseType(touch.getCell_FOR_TEST_ONLY(0, 0), ParseType.CALL, ParseType.DEFAULT_CALL_MULTIPLIER, ParseType.DEFAULT_CALL_MULTIPLIER);
//	}
//
//	@Test
//	public void correctlyParseDefaultCallMultiplierBeforeWhitespace() {
//		DefaultTouch touch = buildAndParseSingleCellTouch(buildPlainBobMinor(), "2 ");
//		assertParseType(touch.getCell_FOR_TEST_ONLY(0, 0), ParseType.DEFAULT_CALL_MULTIPLIER, ParseType.WHITESPACE);
{'fraction_non_alphanumeric': 0.12053832650672908, 'fraction_numerical': 0.008777062609713282, 'mean_word_length': 5.115384615384615, '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': '4267847', 'n_tokens_mistral': 2124, 'n_tokens_neox': 2059, 'n_words': 321}