summaryrefslogtreecommitdiff
path: root/Examples/test-suite/python/cpp11_raw_string_literals_runme.py
blob: 6a587b86078f1a9fff8aec80525ee6610c3758f4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
from cpp11_raw_string_literals import *
import inspect

if cvar.L != 100:
    raise RuntimeError

if cvar.u8 != 100:
    raise RuntimeError

if cvar.u != 100:
    raise RuntimeError

if UStruct.U != 100:
    raise RuntimeError


if cvar.R != 100:
    raise RuntimeError

if cvar.LR != 100:
    raise RuntimeError

if cvar.u8R != 100:
    raise RuntimeError

if cvar.uR != 100:
    raise RuntimeError

if URStruct.UR != 100:
    raise RuntimeError


if cvar.aa != "Wide string":
    raise RuntimeError

if cvar.bb != "UTF-8 string":
    raise RuntimeError, cvar.wide

if cvar.xx != ")I'm an \"ascii\" \\ string.":
    raise RuntimeError, cvar.xx

if cvar.ee != ")I'm an \"ascii\" \\ string.":
    raise RuntimeError, cvar.ee

if cvar.ff != "I'm a \"raw wide\" \\ string.":
    raise RuntimeError, cvar.ff

if cvar.gg != "I'm a \"raw UTF-8\" \\ string.":
    raise RuntimeError, cvar.gg


def check(got, expected):
    expected_list = expected.split("\n")
    got_list = got.split("\n")

    if expected_list != got_list:
        raise RuntimeError("\n" + "Expected: " + str(expected_list) + "\n" + "Got     : " + str(got_list))

# When getting docstrings, use inspect.getdoc(x) instead of x.__doc__ otherwise the different options
# such as -O and -builtin may produce different initial indentation.
check(inspect.getdoc(RawStringDoc.WW), "Single line documentation comment")
check(inspect.getdoc(RawStringDoc.XX),
"""Multi-line
documentation
comment""")
check(inspect.getdoc(RawStringDoc.YY), """Single line "raw string" documentation comment""")
check(inspect.getdoc(RawStringDoc.ZZ),
"""Documentation comment

as a "raw string"
on multiple lines including a \ backslash""")

check(mm, """)I'm an "ascii" \ string constant with multiple

lines.""")