Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2
Révision | e301e7991ae146cfa49c1c6fa5b02e775b7d22c5 (tree) |
---|---|
l'heure | 2021-12-21 05:51:08 |
Auteur | Albert Mietus < albert AT mietus DOT nl > |
Commiter | Albert Mietus < albert AT mietus DOT nl > |
refactored string-test
@@ -11,8 +11,9 @@ | ||
11 | 11 | def parse(txt, rule): |
12 | 12 | parser = arpeggio.ParserPython(rule) |
13 | 13 | pt = parser.parse(txt) |
14 | - assert pt.position_end == len(txt), "Did not parse all input"# JTBS | |
14 | + assert pt.position_end == len(txt), "Did not parse all input" # JTBS | |
15 | 15 | ast = arpeggio.visit_parse_tree(pt, visitor.PegVisitor()) |
16 | + assert ast.position == 0 and ast.position_end == len(txt), "Also the AST should include all input" | |
16 | 17 | return ast |
17 | 18 | |
18 | 19 | def test_simple_str(): |
@@ -21,14 +22,10 @@ | ||
21 | 22 | assert isinstance(ast, peg.Terminal), "It should be a term ..." |
22 | 23 | assert isinstance(ast, peg.StrTerm), "... and a str" |
23 | 24 | assert ast.value == "a string", "It's correct value should be without quotes" |
24 | - assert ast.position == 0, "The term's position includes the quotes ..." | |
25 | - assert ast.position_end == len(txt), " ... on both ends." | |
26 | 25 | |
27 | -def test_simple_str_2(): | |
28 | - txt='"""triple string"""' | |
26 | +def test_simple_str_d3(): | |
27 | + txt='"""triple string"""' # A triple double quotes in Castle is also a simple string | |
29 | 28 | ast = parse(txt, grammar.term) |
30 | 29 | assert isinstance(ast, peg.Terminal), "It should be a term ..." |
31 | 30 | assert isinstance(ast, peg.StrTerm), "... and a str" |
32 | 31 | assert ast.value == "triple string", "It's correct value should be without quotes" |
33 | - assert ast.position == 0, "The term's position includes the quotes ..." | |
34 | - assert ast.position_end == len(txt), " ... on both ends." |