|
1 | 1 | package com.igormaznitsa.prologparser; |
2 | 2 |
|
| 3 | +import static com.igormaznitsa.prologparser.DefaultParserContext.of; |
| 4 | +import static com.igormaznitsa.prologparser.ParserContext.FLAG_BLOCK_COMMENTS; |
| 5 | +import static com.igormaznitsa.prologparser.ParserContext.FLAG_CURLY_BRACKETS; |
| 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_QUOTATION_CHARCODE; |
| 9 | +import static com.igormaznitsa.prologparser.ParserContext.FLAG_ZERO_STRUCT; |
| 10 | +import static com.igormaznitsa.prologparser.terms.OpContainer.make; |
| 11 | +import static com.igormaznitsa.prologparser.terms.Quotation.BACK_TICK; |
| 12 | +import static com.igormaznitsa.prologparser.terms.Quotation.DOUBLE; |
| 13 | +import static com.igormaznitsa.prologparser.terms.Quotation.NONE; |
| 14 | +import static com.igormaznitsa.prologparser.terms.Quotation.SINGLE; |
| 15 | +import static com.igormaznitsa.prologparser.terms.TermType.ATOM; |
| 16 | +import static com.igormaznitsa.prologparser.tokenizer.OpAssoc.FX; |
| 17 | +import static com.igormaznitsa.prologparser.tokenizer.OpAssoc.FY; |
| 18 | +import static com.igormaznitsa.prologparser.tokenizer.OpAssoc.XF; |
| 19 | +import static com.igormaznitsa.prologparser.tokenizer.OpAssoc.XFX; |
| 20 | +import static com.igormaznitsa.prologparser.tokenizer.OpAssoc.XFY; |
| 21 | +import static com.igormaznitsa.prologparser.tokenizer.OpAssoc.YFX; |
| 22 | +import static java.util.stream.Collectors.joining; |
| 23 | +import static org.junit.jupiter.api.Assertions.assertEquals; |
| 24 | +import static org.junit.jupiter.api.Assertions.assertFalse; |
| 25 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
| 26 | +import static org.junit.jupiter.api.Assertions.assertNotSame; |
| 27 | +import static org.junit.jupiter.api.Assertions.assertSame; |
| 28 | +import static org.junit.jupiter.api.Assertions.assertThrows; |
| 29 | +import static org.junit.jupiter.api.Assertions.assertTrue; |
| 30 | +import static org.junit.jupiter.api.Assertions.fail; |
| 31 | +import static org.mockito.Mockito.clearInvocations; |
| 32 | +import static org.mockito.Mockito.mock; |
| 33 | +import static org.mockito.Mockito.when; |
| 34 | + |
3 | 35 | import com.igormaznitsa.prologparser.exceptions.PrologParserException; |
4 | 36 | import com.igormaznitsa.prologparser.terms.OpContainer; |
5 | 37 | import com.igormaznitsa.prologparser.terms.PrologAtom; |
|
34 | 66 | import java.util.Set; |
35 | 67 | import java.util.concurrent.atomic.AtomicInteger; |
36 | 68 |
|
37 | | -import static com.igormaznitsa.prologparser.DefaultParserContext.of; |
38 | | -import static com.igormaznitsa.prologparser.ParserContext.*; |
39 | | -import static com.igormaznitsa.prologparser.terms.OpContainer.make; |
40 | | -import static com.igormaznitsa.prologparser.terms.Quotation.*; |
41 | | -import static com.igormaznitsa.prologparser.terms.TermType.ATOM; |
42 | | -import static com.igormaznitsa.prologparser.tokenizer.OpAssoc.*; |
43 | | -import static java.util.stream.Collectors.joining; |
44 | | -import static org.junit.jupiter.api.Assertions.*; |
45 | | -import static org.mockito.Mockito.*; |
46 | | - |
47 | 69 | public class IntegrationTest { |
48 | 70 |
|
49 | 71 | private static PrologParser parseCpl(final String str) { |
@@ -1197,6 +1219,18 @@ public void testStandardTermOrder() { |
1197 | 1219 | */ |
1198 | 1220 | @Test |
1199 | 1221 | public void testConformity() { |
| 1222 | + assertThrows(PrologParserException.class, () -> parseEd("{:- :- c} = {:-(:-,c)}.").next()); |
| 1223 | + assertThrows(PrologParserException.class, () -> parseEd("{1} = {}(1).").next()); |
| 1224 | + |
| 1225 | + assertEquals("writeq({- = xf1})", parseEd("writeq({- =xf1}).").next().toString()); |
| 1226 | + assertEquals("X = {,}", parseEd("X ={,}.").next().toString()); |
| 1227 | + assertEquals("{- = -1} = {(- =) - 1}", parseEd("{- = - 1}={(-(=)) - 1}.").next().toString()); |
| 1228 | + assertEquals("{- - c} = {- - c}", parseEd("{- - c}={-(-(c))}.").next().toString()); |
| 1229 | + |
| 1230 | + assertEquals("writeq([+ {a}, + []])", parseEd("writeq([+{a},+[]]).").next().toString()); |
| 1231 | + assertEquals("writeq(- {a})", parseEd("writeq(-{a}).").next().toString()); |
| 1232 | + assertEquals("writeq(- {})", parseEd("writeq(-{}).").next().toString()); |
| 1233 | + |
1200 | 1234 | assertEquals("writeq([a, b|','])", parseEd("writeq([a,b|',']).").next().toString()); |
1201 | 1235 | assertEquals("X = 1", parseEd("X = 2'1.").next().toString()); |
1202 | 1236 | assertEquals("writeq(- - 1)", parseEd("writeq(-(-(1))).").next().toString()); |
|
0 commit comments