Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/keenquotes.git

Fix unit test failure

AuthorDave Jarvis <email>
Date2022-10-05 23:26:49 GMT-0700
Commit8509d5e9f013307d5256ac85012607a31f2c2a31
Parent6396260
src/main/java/com/whitemagicsoftware/keenquotes/lex/LexemeGlyph.java
*/
public enum LexemeGlyph {
- LEX_NONE( (char) 0 ),
+ /**
+ * Any other character that's not a quotation mark.
+ */
+ LEX_OTHER( (char) 0 ),
LEX_SINGLE_QUOTE( '\'' ),
LexemeGlyph( final char glyph ) {
mGlyph = glyph;
- }
-
- public char glyph() {
- return mGlyph;
}
- public boolean equals( final char ch ) {
- return glyph() == ch;
+ /**
+ * Answers whether the given character matches the internal glyph.
+ *
+ * @param glyph The character to compare against the internal character.
+ * @return {@code true} iff the characters are equal.
+ */
+ public boolean equals( final char glyph ) {
+ return mGlyph == glyph;
}
}
src/main/java/com/whitemagicsoftware/keenquotes/lex/LexemeType.java
private LexemeGlyph mGlyph;
+ /**
+ * Constructs an instance of {@link LexemeType} using
+ * {@link LexemeGlyph#LEX_OTHER} to indicate that this type of lexeme isn't
+ * a quotation mark glyph.
+ */
public LexemeType() {
- this( LEX_NONE );
+ this( LEX_OTHER );
}
+ /**
+ * Constructs an instance of {@link LexemeType} using a particular glyph.
+ *
+ * @param glyph Typically represents an internationalized quotation mark
+ * character.
+ */
public LexemeType( final LexemeGlyph glyph ) {
setGlyph( glyph );
}
+ /**
+ * Changes the type of glyph associated with this type of lexeme. This
+ * is useful for passing along different glyphs represented by the same
+ * lexeme (such as different opening quotation marks).
+ *
+ * @param glyph The new {@link LexemeGlyph} to associate, often an
+ * internationalized quotation mark.
+ * @return {@code this} to allow chaining.
+ */
public LexemeType with( final LexemeGlyph glyph ) {
setGlyph( glyph );
return this;
}
+ /**
+ * Provides the glyph used to identify international quotation marks.
+ *
+ * @return The glyph set either at construction time or after calling
+ * {@link #with(LexemeGlyph)}.
+ */
public LexemeGlyph glyph() {
return mGlyph;
}
private void setGlyph( final LexemeGlyph glyph ) {
mGlyph = glyph;
+ }
+
+ /**
+ * Provides useful debugging information.
+ *
+ * @return The class name and encodable glyph.
+ */
+ @Override
+ public String toString() {
+ return getClass().getSimpleName() +
+ '[' + glyph() + ']';
}
}
src/main/java/com/whitemagicsoftware/keenquotes/parser/Curler.java
assert !replacements.isEmpty();
assert i18n != null;
- assert !i18n.isEmpty();
assert parserType != null;
src/main/java/com/whitemagicsoftware/keenquotes/parser/QuoteEmitter.java
}
}
+ // <'"Trouble>
+ else if( match( QUOTE_SINGLE, QUOTE_DOUBLE, WORD, ANY ) ) {
+ emit( QUOTE_OPENING_DOUBLE, lex2 );
+ }
else if( match( ANY, QUOTE_DOUBLE, ANY, ANY ) ) {
emit( QUOTE_AMBIGUOUS_DOUBLE, lex2 );
src/test/java/com/whitemagicsoftware/keenquotes/parser/AmbiguityResolverTest.java
}
- @Test
@Disabled
void test_Resolve_InvalidGrammar_AmbiguousRemain() throws IOException {
src/test/java/com/whitemagicsoftware/keenquotes/parser/QuoteEmitterTest.java
@Test
void test_Emit_MultipleInputs_QuotesEmitted() throws IOException {
- final var couplets = readPairs(
- "unambiguous-1-pass.txt" );
+ final var couplets = readPairs( "unambiguous-1-pass.txt" );
couplets.forEach( couplet -> {
src/test/resources/com/whitemagicsoftware/keenquotes/texts/invalid-grammar.txt
-# """wtf"""
-# &ldquo;&ldquo;&ldquo;wtf&rdquo;&rdquo;&rdquo;
+"""insane"""
+&ldquo;&rdquo;&ldquo;insane&rdquo;&ldquo;&rdquo;
-# '''wtf'''
-# &lsquo;&lsquo;&lsquo;wtf&rsquo;&rsquo;&rsquo;
+'''wtf'''
+&lsquo;&lsquo;&lsquo;wtf&rsquo;&rsquo;&rsquo;
Delta59 lines added, 16 lines removed, 43-line increase