Note that there are some explanatory texts on larger screens.

plurals
  1. POSyntax error: insert "enum Identifier", insert "EnumBody", inset "}"
    primarykey
    data
    text
    <p>I coded an enum type which brings up the following Syntax errors when I run my created JUnit test for it:</p> <pre><code>java.lang.Error: Unresolved compilation problems: Syntax error, insert "enum Identifier" to complete EnumHeaderName Syntax error, insert "EnumBody" to complete EnumDeclaration Syntax error, insert "}" to complete ClassBody </code></pre> <p>My enum type has static functions which for a particular String, returns an enum constant. Here is some of my code of the enum type:</p> <pre><code>public enum MusicType { ACCIDENTAL, LETTER, OCTAVE, REST, DUR, CHORD, TUPLET; public static MusicType is_accidental(String a){ if (a=="^" | a=="_"|a=="=") return ACCIDENTAL; else return null; } } </code></pre> <p>The rest of my static functions are very similar (i.e. <code>is_letter</code>, <code>is_octave</code>, etc.), although some use <code>input.matches(regex)</code> function instead of checking to see if an input it equals a particular string. </p> <p>Here is the beginning of the JUnit test which tests the function dealing with the accidental constant:</p> <pre><code>public class MusicTypeTest { @Test public void accidentalTest(){ String sharp = "^"; String flat = "_"; String natural = "="; assertEquals(MusicType.ACCIDENTAL, MusicType.is_accidental(sharp)); assertEquals(MusicType.ACCIDENTAL, MusicType.is_accidental(flat)); assertEquals(MusicType.ACCIDENTAL, MusicType.is_accidental(natural)); } } </code></pre> <p>The other functions in my JUnit test which test all the enum static functions are coded similarly. I cannot figure out why I have these syntax errors (this is my first time coding an enum type). I've been coding in Eclipse and have not found any missing "}"s as of yet. I don't know if this has anything to do with the way I've written the test or the way I've declared my variables. Does anyone know why I have these syntax errors?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload