@@ -149,3 +149,64 @@ def test_top_level_unbound_rule_has_no_parent_binding() -> None:
149149 parsed_template = template ("IfcWall" , "Status" , (top_level ,))
150150
151151 assert parsed_template .binding_for (top_level ) is None
152+
153+
154+ @pytest .mark .parametrize (
155+ "value,expected" ,
156+ [
157+ ("Model" , "Model" ), # ContextType[Value]=Model
158+ ("IfcLocalPlacement" , "IfcLocalPlacement" ), # entity name as a parameter
159+ ("EPSG:5555" , "EPSG:5555" ), # not valid Python syntax either
160+ (" QTO_OCCURRENCEDRIVEN " , "QTO_OCCURRENCEDRIVEN" ),
161+ ("'IfcLabel'" , "IfcLabel" ), # quoted literals keep working
162+ ("TRUE" , True ),
163+ ("42" , 42 ),
164+ ],
165+ )
166+ def test_parse_mvdxml_token_falls_back_to_the_raw_string (
167+ value : str , expected : object
168+ ) -> None :
169+ assert model ._parse_mvdxml_token (value ) == expected
170+
171+
172+ def test_empty_template_rules_group_is_skipped () -> None :
173+ status = rule ("AttributeRule" , "Status" , bind = "Status" )
174+ concept = concept_or_applicability (
175+ "status" ,
176+ template ("IfcWall" , "Status" , (status ,)),
177+ ((), "and" , (parse_expression ("Status='complete'" ),)),
178+ )
179+
180+ valid , _ = concept .validate ([{status : "complete" }])
181+
182+ assert valid
183+
184+
185+ def test_every_template_rule_expression_is_evaluated () -> None :
186+ status = rule ("AttributeRule" , "Status" , bind = "Status" )
187+ concept = concept_or_applicability (
188+ "status" ,
189+ template ("IfcWall" , "Status" , (status ,)),
190+ (parse_expression ("Status='complete'; Status='draft'" ),),
191+ )
192+
193+ valid , _ = concept .validate ([{status : "complete" }])
194+
195+ assert not valid
196+
197+
198+ def test_official_reference_view_expressions_all_parse () -> None :
199+ roots = parse (EXAMPLES / "officials" / "ReferenceView_V1-2.mvdxml" )
200+
201+ tokens = [
202+ token
203+ for root in roots
204+ for concept in root .concepts ()
205+ for expression in model ._iter_expressions (concept .rules ())
206+ for token in expression
207+ if not isinstance (token , str )
208+ ]
209+
210+ assert len (tokens ) > 400
211+ for token in tokens :
212+ model ._parse_mvdxml_token (token .c )
0 commit comments