diff options
Diffstat (limited to 'src/test')
| -rw-r--r-- | src/test/java/bjc/inflexion/InflectionMLTest.java | 153 |
1 files changed, 92 insertions, 61 deletions
diff --git a/src/test/java/bjc/inflexion/InflectionMLTest.java b/src/test/java/bjc/inflexion/InflectionMLTest.java index 109547a..54ee170 100644 --- a/src/test/java/bjc/inflexion/InflectionMLTest.java +++ b/src/test/java/bjc/inflexion/InflectionMLTest.java @@ -8,7 +8,7 @@ import org.junit.Test; /** * Tests for inflection markup. - * + * * @author bjculkin * */ @@ -19,52 +19,63 @@ public class InflectionMLTest { @Test public void testML() { ////////////////////// - // Check # command // + // Check # command // ////////////////////// // Check general inflection - assertInflects("<#:%s> <N:indexes> %s found", pair("0 indexes were found", 0, "were"), - pair("1 index was found", 1, "was"), pair("99 indexes were found", 99, "were")); + assertInflects("<#:%s> <N:indexes> %s found", + pair("0 indexes were found", 0, "were"), + pair("1 index was found", 1, "was"), + pair("99 indexes were found", 99, "were")); // Check fancier inflection - // - // There was a 'c' option attached to the '#' directive, but I have no recollection of what that should've done. - assertInflects("<#wn:%d> <Noun:indexes> %s found", pair("no indexes were found", 0, "were"), - pair("one index was found", 1, "was"), pair("99 indexes were found", 99, "were")); + // + // There was a 'c' option attached to the '#' directive, but I have no + // recollection of what that should've done. + assertInflects("<#wn:%d> <Noun:indexes> %s found", + pair("no indexes were found", 0, "were"), + pair("one index was found", 1, "was"), + pair("99 indexes were found", 99, "were")); // Check count inflection - assertInflects("<#w20:%d> <N:indexes> were found", pair("six indexes were found", 6), - pair("nineteen indexes were found", 19), pair("20 indexes were found", 20)); + assertInflects("<#w20:%d> <N:indexes> were found", + pair("six indexes were found", 6), + pair("nineteen indexes were found", 19), + pair("20 indexes were found", 20)); // Check 'n' option - assertInflects("<#n:%d> <N:results>", pair("no results", 0), pair("7 results", 7)); + assertInflects("<#n:%d> <N:results>", pair("no results", 0), + pair("7 results", 7)); // FIXME // // Adjust this to use <V> for were/was when it is implemented // Check general inflection - assertInflects("<#%s:%d> <N:item> %s found", pair("no items were found", "n", 0, "were"), + assertInflects("<#%s:%d> <N:item> %s found", + pair("no items were found", "n", 0, "were"), pair("no item was found", "s", 0, "was")); // Check article picking - assertInflects("<#a:%d> <N:%s>", pair("a result", 1, "results"), pair("3 results", 3, "results"), - pair("an outcome", 1, "outcomes"), pair("7 outcomes", 7, "outcomes")); + assertInflects("<#a:%d> <N:%s>", pair("a result", 1, "results"), + pair("3 results", 3, "results"), pair("an outcome", 1, "outcomes"), + pair("7 outcomes", 7, "outcomes")); // Check 'w' option - assertInflects("<#w:%d> <N:results>", pair("six results", 6), pair("ten results", 10), - pair("11 results", 11)); + assertInflects("<#w:%d> <N:results>", pair("six results", 6), + pair("ten results", 10), pair("11 results", 11)); // Check 'o' option - assertInflects("<#o:%d> <N:results>", pair("6th result", 6), pair("11th result", 11), - pair("22nd result", 22)); - assertInflects("<#ow:%d> <N:results>", pair("first result", 1), pair("sixth result", 6), - pair("22nd result", 22)); - assertInflects("<#o15:%d> <N:results>", pair("6th result", 6), pair("11th result", 11), - pair("22 results", 22)); + assertInflects("<#o:%d> <N:results>", pair("6th result", 6), + pair("11th result", 11), pair("22nd result", 22)); + assertInflects("<#ow:%d> <N:results>", pair("first result", 1), + pair("sixth result", 6), pair("22nd result", 22)); + assertInflects("<#o15:%d> <N:results>", pair("6th result", 6), + pair("11th result", 11), pair("22 results", 22)); // Check 'f' option - assertInflects("Found <#f:%d> <N:matches>", pair("Found no matches", 0), pair("Found one match", 1), - pair("Found a couple of matches", 2), pair("Found a few matches", 4), - pair("Found several matches", 8), pair("Found many matches", 11)); + assertInflects("Found <#f:%d> <N:matches>", pair("Found no matches", 0), + pair("Found one match", 1), pair("Found a couple of matches", 2), + pair("Found a few matches", 4), pair("Found several matches", 8), + pair("Found many matches", 11)); assertInflects("Searching for <Np:items>....found <#f1:%d>", pair("Searching for items....found none", 0), @@ -80,23 +91,27 @@ public class InflectionMLTest { pair("Found several matches", 7)); // Check 'e' option - assertInflects("Found <#e:%d> <N:matches>", pair("Found no match", 0), pair("Found a match", 1), - pair("Found ten matches", 10), pair("Found 12 matches", 12)); + assertInflects("Found <#e:%d> <N:matches>", pair("Found no match", 0), + pair("Found a match", 1), pair("Found ten matches", 10), + pair("Found 12 matches", 12)); // Check 'd' option - assertInflects("<#d:%d><N:Match> found", pair("Match found", 1), pair("Matches found", 2)); + assertInflects("<#d:%d><N:Match> found", pair("Match found", 1), + pair("Matches found", 2)); //////////////////////// - // Check N command // + // Check N command // /////////////////////// // Check 'c' option assertInflects("<#:%d> <N:%s> found", pair("7 maximums found", 7, "maximum"), - pair("7 formulas found", 7, "formula"), pair("7 corpuses found", 7, "corpuses"), + pair("7 formulas found", 7, "formula"), + pair("7 corpuses found", 7, "corpuses"), pair("7 brothers found", 7, "brothers")); assertInflects("<#:%d> <Nc:%s> found", pair("7 maxima found", 7, "maximum"), - pair("7 formulae found", 7, "formula"), pair("7 corpora found", 7, "corpus"), + pair("7 formulae found", 7, "formula"), + pair("7 corpora found", 7, "corpus"), pair("7 brethren found", 7, "brother")); } @@ -110,27 +125,35 @@ public class InflectionMLTest { assertCInflects("test $1 string", pair("test literal string", "literal"), pair("test variable string", "variable")); ////////////////////// - // Check # command // + // Check # command // ////////////////////// // Check general inflection - assertCInflects("<#:$1> <N:indexes> $2 found", pair("0 indexes were found", 0, "were"), - pair("1 index was found", 1, "was"), pair("99 indexes were found", 99, "were")); + assertCInflects("<#:$1> <N:indexes> $2 found", + pair("0 indexes were found", 0, "were"), + pair("1 index was found", 1, "was"), + pair("99 indexes were found", 99, "were")); // Check fancier inflection // - // There was a 'c' option attached to the '#' directive, but I have no recollection of what that should've done. + // There was a 'c' option attached to the '#' directive, but I have no + // recollection of what that should've done. // // As for the mixed-case options, the directive type can't be mixed case. - assertCInflects("<#wn:$1> <N:indexes> $2 found", pair("no indexes were found", 0, "were"), - pair("one index was found", 1, "was"), pair("99 indexes were found", 99, "were")); + assertCInflects("<#wn:$1> <N:indexes> $2 found", + pair("no indexes were found", 0, "were"), + pair("one index was found", 1, "was"), + pair("99 indexes were found", 99, "were")); // Check count inflection - assertCInflects("<#w20:$1> <N:indexes> were found", pair("six indexes were found", 6), - pair("nineteen indexes were found", 19), pair("20 indexes were found", 20)); + assertCInflects("<#w20:$1> <N:indexes> were found", + pair("six indexes were found", 6), + pair("nineteen indexes were found", 19), + pair("20 indexes were found", 20)); // Check 'n' option - assertCInflects("<#n:$1> <N:results>", pair("no results", 0), pair("7 results", 7)); + assertCInflects("<#n:$1> <N:results>", pair("no results", 0), + pair("7 results", 7)); // FIXME // @@ -138,28 +161,32 @@ public class InflectionMLTest { // Check general inflection // // For now, compiled inflection strings don't support variable options - assertCInflects("<#n:$1> <N:item> $2 found", pair("no items were found", 0, "were")); - assertCInflects("<#ns:$1> <N:item> $2 found", pair("no item was found", 0, "was")); + assertCInflects("<#n:$1> <N:item> $2 found", + pair("no items were found", 0, "were")); + assertCInflects("<#ns:$1> <N:item> $2 found", + pair("no item was found", 0, "was")); // Check article picking - assertCInflects("<#a:$1> <N:$2>", pair("a result", 1, "results"), pair("3 results", 3, "results"), - pair("an outcome", 1, "outcomes"), pair("7 outcomes", 7, "outcomes")); + assertCInflects("<#a:$1> <N:$2>", pair("a result", 1, "results"), + pair("3 results", 3, "results"), pair("an outcome", 1, "outcomes"), + pair("7 outcomes", 7, "outcomes")); // Check 'w' option - assertCInflects("<#w:$1> <N:results>", pair("six results", 6), pair("ten results", 10), - pair("11 results", 11)); + assertCInflects("<#w:$1> <N:results>", pair("six results", 6), + pair("ten results", 10), pair("11 results", 11)); // Check 'o' option - assertCInflects("<#o:$1> <N:results>", pair("6th result", 6), pair("11th result", 11), - pair("22nd result", 22)); - assertCInflects("<#ow:$1> <N:results>", pair("first result", 1), pair("sixth result", 6), - pair("22nd result", 22)); - assertCInflects("<#o15:$1> <N:results>", pair("6th result", 6), pair("11th result", 11), - pair("22 results", 22)); + assertCInflects("<#o:$1> <N:results>", pair("6th result", 6), + pair("11th result", 11), pair("22nd result", 22)); + assertCInflects("<#ow:$1> <N:results>", pair("first result", 1), + pair("sixth result", 6), pair("22nd result", 22)); + assertCInflects("<#o15:$1> <N:results>", pair("6th result", 6), + pair("11th result", 11), pair("22 results", 22)); // Check 'f' option - assertCInflects("Found <#f:$1> <N:matches>", pair("Found no matches", 0), pair("Found one match", 1), - pair("Found a couple of matches", 2), pair("Found a few matches", 4), - pair("Found several matches", 8), pair("Found many matches", 11)); + assertCInflects("Found <#f:$1> <N:matches>", pair("Found no matches", 0), + pair("Found one match", 1), pair("Found a couple of matches", 2), + pair("Found a few matches", 4), pair("Found several matches", 8), + pair("Found many matches", 11)); // FIXME Don't require spaces to mark out directives. // - Ben Culkin, 10/28/18 @@ -177,23 +204,27 @@ public class InflectionMLTest { pair("Found several matches", 7)); // Check 'e' option - assertCInflects("Found <#e:$1> <N:matches>", pair("Found no match", 0), pair("Found a match", 1), - pair("Found ten matches", 10), pair("Found 12 matches", 12)); + assertCInflects("Found <#e:$1> <N:matches>", pair("Found no match", 0), + pair("Found a match", 1), pair("Found ten matches", 10), + pair("Found 12 matches", 12)); // Check 'd' option - assertCInflects("<#d:$1> <N:Match> found", pair(" Match found", 1), pair(" Matches found", 2)); + assertCInflects("<#d:$1> <N:Match> found", pair(" Match found", 1), + pair(" Matches found", 2)); //////////////////////// - // Check N command // + // Check N command // /////////////////////// // Check 'c' option assertCInflects("<#:$1> <N:$2> found", pair("7 maximums found", 7, "maximum"), - pair("7 formulas found", 7, "formula"), pair("7 corpuses found", 7, "corpuses"), + pair("7 formulas found", 7, "formula"), + pair("7 corpuses found", 7, "corpuses"), pair("7 brothers found", 7, "brothers")); assertCInflects("<#:$1> <Nc:$2> found", pair("7 maxima found", 7, "maximum"), - pair("7 formulae found", 7, "formula"), pair("7 corpora found", 7, "corpus"), + pair("7 formulae found", 7, "formula"), + pair("7 corpora found", 7, "corpus"), pair("7 brethren found", 7, "brother")); } |
