|
1 | 1 | package com.igormaznitsa.prologparser; |
2 | 2 |
|
3 | | -import static com.igormaznitsa.prologparser.DefaultParserContext.of; |
4 | | -import static com.igormaznitsa.prologparser.ParserContext.FLAG_ALLOW_ZERO_STRUCT; |
5 | | -import static com.igormaznitsa.prologparser.ParserContext.FLAG_BLOCK_COMMENTS; |
6 | | -import static com.igormaznitsa.prologparser.ParserContext.FLAG_NONE; |
7 | | -import static com.igormaznitsa.prologparser.ParserContext.FLAG_VAR_AS_FUNCTOR; |
8 | | -import static com.igormaznitsa.prologparser.ParserContext.FLAG_ZERO_SINGLE_QUOTATION_CHAR_CODE; |
9 | | -import static com.igormaznitsa.prologparser.terms.OpContainer.make; |
10 | | -import static com.igormaznitsa.prologparser.terms.PrologTerm.QuotingType.BACK_QUOTED; |
11 | | -import static com.igormaznitsa.prologparser.terms.PrologTerm.QuotingType.DOUBLE_QUOTED; |
12 | | -import static com.igormaznitsa.prologparser.terms.PrologTerm.QuotingType.NO_QUOTED; |
13 | | -import static com.igormaznitsa.prologparser.terms.PrologTerm.QuotingType.SINGLE_QUOTED; |
14 | | -import static com.igormaznitsa.prologparser.terms.TermType.ATOM; |
15 | | -import static com.igormaznitsa.prologparser.tokenizer.OpAssoc.FY; |
16 | | -import static com.igormaznitsa.prologparser.tokenizer.OpAssoc.XFX; |
17 | | -import static com.igormaznitsa.prologparser.tokenizer.OpAssoc.XFY; |
18 | | -import static java.util.stream.Collectors.joining; |
19 | | -import static org.junit.jupiter.api.Assertions.assertEquals; |
20 | | -import static org.junit.jupiter.api.Assertions.assertFalse; |
21 | | -import static org.junit.jupiter.api.Assertions.assertNotNull; |
22 | | -import static org.junit.jupiter.api.Assertions.assertNotSame; |
23 | | -import static org.junit.jupiter.api.Assertions.assertSame; |
24 | | -import static org.junit.jupiter.api.Assertions.assertThrows; |
25 | | -import static org.junit.jupiter.api.Assertions.assertTrue; |
26 | | -import static org.junit.jupiter.api.Assertions.fail; |
27 | | -import static org.mockito.Mockito.clearInvocations; |
28 | | -import static org.mockito.Mockito.mock; |
29 | | -import static org.mockito.Mockito.when; |
30 | | - |
31 | 3 | import com.igormaznitsa.prologparser.exceptions.PrologParserException; |
32 | 4 | import com.igormaznitsa.prologparser.terms.OpContainer; |
33 | 5 | import com.igormaznitsa.prologparser.terms.PrologAtom; |
|
60 | 32 | import java.util.Set; |
61 | 33 | import java.util.concurrent.atomic.AtomicInteger; |
62 | 34 |
|
| 35 | +import static com.igormaznitsa.prologparser.DefaultParserContext.of; |
| 36 | +import static com.igormaznitsa.prologparser.ParserContext.*; |
| 37 | +import static com.igormaznitsa.prologparser.terms.OpContainer.make; |
| 38 | +import static com.igormaznitsa.prologparser.terms.PrologTerm.QuotingType.*; |
| 39 | +import static com.igormaznitsa.prologparser.terms.TermType.ATOM; |
| 40 | +import static com.igormaznitsa.prologparser.tokenizer.OpAssoc.*; |
| 41 | +import static java.util.stream.Collectors.joining; |
| 42 | +import static org.junit.jupiter.api.Assertions.*; |
| 43 | +import static org.mockito.Mockito.*; |
| 44 | + |
63 | 45 | public class IntegrationTest { |
64 | 46 |
|
65 | 47 | private static PrologParser parseCpl(final String str) { |
@@ -747,7 +729,7 @@ public void testSingleOperatorAsAtom() { |
747 | 729 | public void testRecognizingUserOperatorsWhichSimilarMetaOperators() { |
748 | 730 | final Map<String, OpContainer> operators = new HashMap<>(); |
749 | 731 | operators.put("(((", make(Op.make(1, OpAssoc.FX, "((("))); |
750 | | - operators.put("...", make(Op.make(1200, OpAssoc.XF, "..."))); |
| 732 | + operators.put("...", make(Op.make(1200, XF, "..."))); |
751 | 733 | final StubContext stubContext = new StubContext(operators); |
752 | 734 |
|
753 | 735 | final PrologStruct structure = (PrologStruct) parseEd("(((hello....", stubContext).next(); |
@@ -995,11 +977,12 @@ public void testOperatorAsFunctor() throws Exception { |
995 | 977 |
|
996 | 978 | @Test |
997 | 979 | public void testPairOfOperatorsWithIncompatiblePrecedence() throws Exception { |
| 980 | + assertEquals("- (discontiguous)", parseEd("-discontiguous.").next().toString()); |
| 981 | + assertEquals("aab", parseEd("aab.", DefaultParserContext.of(FLAG_NONE, Op.make(400, XF, "aabc"))).next().toString()); |
998 | 982 | assertEquals("1 - - -1", parseEd("1---1.").next().toString()); |
999 | 983 | assertEquals("1 + 1 * a * a + a - 1", parseEd("1+1*a*a+a-1.").next().toString()); |
1000 | 984 | assertEquals("-1 + 2 ** (- 3 ** (-4))", parseEd("-1+2**-3**-4.").next().toString()); |
1001 | 985 | assertEquals("X = (discontiguous)", parseEd("X=discontiguous.").next().toString()); |
1002 | | - assertEquals("- (discontiguous)", parseEd("-discontiguous.").next().toString()); |
1003 | 986 | assertEquals("2 ** (-1)", parseEd("2**-1.").next().toString()); |
1004 | 987 | assertEquals("0.2 is 5 ** (-1)", parseEd("0.2 is 5** -1.").next().toString()); |
1005 | 988 | assertEquals("a : b :> c :> d", parseEd("a:b:>c:>d.", DefaultParserContext.of(ParserContext.FLAG_NONE, Op.make(500, XFY, ":>"))).next().toString()); |
|
0 commit comments