Files
Pierre-Marie de Rodat 147293a98f Testsuite: use "ascii" for non-ASCII test outputs
On Windows, the default encoding (not UTF-8) may not allow non-ASCII
test outputs. Use Python's "ascii" builtin where needed to ensure pure
ASCII test outputs.

TN: U720-016
2021-09-27 14:57:26 +02:00

21 lines
509 B
Python

"""
Test that StringLiteral.p_denoted_value properly decodes all valid Ada string
literals.
"""
import libadalang as lal
c = lal.AnalysisContext('utf-8')
u = c.get_from_file('foo.ads')
for decl in u.root.findall(lal.ObjectDecl):
name = decl.f_ids.text
expr = decl.f_default_expr
assert isinstance(expr, lal.StringLiteral)
try:
v = expr.p_denoted_value
except lal.PropertyError:
v = u'<PropertyError>'
print('{} ({}) -> {}'.format(name, ascii(expr.text), ascii(v)))