• R/O
  • SSH

Commit

Tags
Keine Tags

Frequently used words (click to add to your profile)

javac++androidlinuxc#windowsobjective-ccocoa誰得qtpythonphprubygameguibathyscaphec計画中(planning stage)翻訳omegatframeworktwitterdomtestvb.netdirectxゲームエンジンbtronarduinopreviewer

Castle: The best Real-Time/Embedded/HighTech language EVER. Attempt 2


Commit MetaInfo

Revision8508bf239c70bf358d09dfa53e7b08dc75e748cd (tree)
Zeit2022-01-01 05:32:14
AutorAlbert Mietus < albert AT mietus DOT nl >
CommiterAlbert Mietus < albert AT mietus DOT nl >

Log Message

refactored test: added assert_ID()

Ändern Zusammenfassung

Diff

diff -r 5fa6eb3e3b43 -r 8508bf239c70 Arpeggio/pytst/d2_ast/test_3_rule.py
--- a/Arpeggio/pytst/d2_ast/test_3_rule.py Fri Dec 31 20:53:21 2021 +0100
+++ b/Arpeggio/pytst/d2_ast/test_3_rule.py Fri Dec 31 21:32:14 2021 +0100
@@ -7,18 +7,27 @@
77
88 from . import parse
99
10+def assert_ID(id, name:str=None, err_message="Not correct Name"):
11+ assert name is not None
12+ assert isinstance(id, peg.ID), "The id should be an ID"
13+ peg.ID.validate_or_raise(id) # with correct syntax
14+ assert id.name == name, err_message if err_message else f"Note correct name, expected {name}"
15+
16+
17+
18+
1019 def test_trivial_rule_with_2IDS():
1120 """The most simple rule has only two IDs"""
1221
1322 txt="trivial <- cross ;"
14-
1523 ast = parse(txt, grammar.rule)
16- assert isinstance(ast, peg.Rule), "It should be an ID"
1724
18- name, expr = ast.name, ast.expr;
19- assert isinstance(name, peg.ID)
25+ assert isinstance(ast, peg.Rule), "It should be an ID"
26+ assert_ID(ast.name, txt.split()[0], "The name of a rule is a ID with the left-side ID as name")
27+
28+ expr = ast.expr;
2029 assert isinstance(expr, peg.Expression), "The expression is an Expression ..."
2130 assert isinstance(expr, peg.Sequence), " .. and a Sequence .."
2231 assert len(expr) ==1, " .. of length==1"
23- assert name.name == txt.split()[0], "the name of the (ID of ) rule is the first ID"
24- assert expr[0].name == txt.split()[2], "The single element of the expression is the 2nnd ID, which name os the 3 part of the txt"
32+ assert_ID(expr[0], txt.split()[2], "The single element of the expression is an ID (the 2nd) -- which name is the 3 part of the txt")
33+