<commit_before>/**
	 
 */
package nruth.fingar.domain.specs;


import java.util.LinkedList;

import org.junit.*;
import static org.junit.Assert.*;
import nruth.fingar.domain.music.NamedNote;

public class NamedNoteSpec {
	/**
	 * can compare notes for equality
	 */
	@Test
	public void test_named_notes_equality(){
		assertEquals(NamedNote.A, NamedNote.A);
		assertFalse(NamedNote.A.equals(NamedNote.B));
	}
	
	/**
	 * can state the degree of a note in the scale
	 */
	@Test
	public void can_state_the_degree_of_a_note_in_the_scale(){
		assertEquals(6, NamedNote.A.getDegree());
		assertEquals(7, NamedNote.Bb.getDegree());
		assertEquals(5, NamedNote.Ab.getDegree());
	}
	
	/**
	 * should be able to resolve the next note
	 */
	@Test
	public void able_to_resolve_the_next_note(){
		assertEquals("simple progression check",NamedNote.A.next(), NamedNote.Bb);
		assertEquals("new scale octave check",NamedNote.Ab.next(), NamedNote.A);
	}
	
	/**
	 * can advance by intervals
	 */
	@Test
	public void can_advance_by_intervals(){
		assertEquals("single interval increment", NamedNote.A.advance(1), NamedNote.Bb);
		assertEquals("3 interval increment", NamedNote.Db.advance(3), NamedNote.E);
		assertEquals("wrapping around failed", NamedNote.C.advance(NamedNote.values().length + 1), NamedNote.Db);
	}
	
	/**
	 * produces correct string representation of all notes
	 */
	@Test
	public void named_note_strings_correct(){
		LinkedList<String> notes =  new LinkedList<String>();
		String[] tmp_notes = {"A", "Bb", "B", "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab"};
		for(String note : tmp_notes){ notes.add(note); }
		
		NamedNote start = NamedNote.A;
		NamedNote note = start;
		do{
			assertTrue("failed to pop note "+note, note.toString().equals(notes.remove()));		
			note = note.advance(1);
		} while (!note.equals(start));
		
		assertTrue("a match failed", notes.size() == 0);
	}
	
	/**
	 * interval representation of octave length and looping is correct
	 */
	@Test
	public void intervals_in_octave(){
		assertEquals("number of notes named", NamedNote.values().length, 12);
		
		assertEquals("octave interval increment", NamedNote.A.advance(12), NamedNote.A);
		assertEquals("octave + single interval increment", NamedNote.A.advance(13), NamedNote.Bb);
	}
}
<commit_msg>trivially passing (enumeration implementation) namednote equality and hashcode tests<commit_after>/**
	 
 */
package nruth.fingar.domain.specs;


import java.util.LinkedList;

import org.junit.*;
import static org.junit.Assert.*;
import nruth.fingar.domain.music.NamedNote;

public class NamedNoteSpec {
	/**
	 * can compare notes for equality
	 */
	@Test
	public void test_named_notes_equality(){
		assertEquals(NamedNote.A, NamedNote.A);
		assertFalse(NamedNote.A.equals(NamedNote.B));
	}
	
	/**
	 * can state the degree of a note in the scale
	 */
	@Test
	public void can_state_the_degree_of_a_note_in_the_scale(){
		assertEquals(6, NamedNote.A.getDegree());
		assertEquals(7, NamedNote.Bb.getDegree());
		assertEquals(5, NamedNote.Ab.getDegree());
	}
	
	/**
	 * should be able to resolve the next note
	 */
	@Test
	public void able_to_resolve_the_next_note(){
		assertEquals("simple progression check",NamedNote.A.next(), NamedNote.Bb);
		assertEquals("new scale octave check",NamedNote.Ab.next(), NamedNote.A);
	}
	
	/**
	 * can advance by intervals
	 */
	@Test
	public void can_advance_by_intervals(){
		assertEquals("single interval increment", NamedNote.A.advance(1), NamedNote.Bb);
		assertEquals("3 interval increment", NamedNote.Db.advance(3), NamedNote.E);
		assertEquals("wrapping around failed", NamedNote.C.advance(NamedNote.values().length + 1), NamedNote.Db);
	}
	
	/**
	 * produces correct string representation of all notes
	 */
	@Test
	public void named_note_strings_correct(){
		LinkedList<String> notes =  new LinkedList<String>();
		String[] tmp_notes = {"A", "Bb", "B", "C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab"};
		for(String note : tmp_notes){ notes.add(note); }
		
		NamedNote start = NamedNote.A;
		NamedNote note = start;
		do{
			assertTrue("failed to pop note "+note, note.toString().equals(notes.remove()));		
			note = note.advance(1);
		} while (!note.equals(start));
		
		assertTrue("a match failed", notes.size() == 0);
	}
	
	/**
	 * interval representation of octave length and looping is correct
	 */
	@Test
	public void intervals_in_octave(){
		assertEquals("number of notes named", NamedNote.values().length, 12);
		
		assertEquals("octave interval increment", NamedNote.A.advance(12), NamedNote.A);
		assertEquals("octave + single interval increment", NamedNote.A.advance(13), NamedNote.Bb);
	}
	
	/**
	 * equality and hashcodes
	 * done after-the-fact and implementation is via enumeration so should pass trivially
	 */
	@Test
	public void equality_and_hashcodes(){
		assertEquals(NamedNote.A, NamedNote.A);
		assertFalse(NamedNote.A.equals(NamedNote.B));
		assertFalse(NamedNote.B.equals(NamedNote.A));
		
		assertEquals(NamedNote.A.hashCode(), NamedNote.A.hashCode());
		assertFalse(NamedNote.A.hashCode() == NamedNote.B.hashCode());
	}
}

{'fraction_non_alphanumeric': 0.14677992888186486, 'fraction_numerical': 0.005926511260371394, 'mean_word_length': 4.551535087719298, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6805747', 'n_tokens_mistral': 1810, 'n_tokens_neox': 1651, 'n_words': 388}