Add more tests for C++11 raw string literals

Test added to check fixes for:

- Issue #948 and issue #1019 and issue #1273 - raw string delimiters
  not being stripped off
- Issue #538 - Ruby support for "docstring" feature
This commit is contained in:
William S Fulton 2019-01-05 23:54:02 +00:00
commit 0c4491eaae
4 changed files with 140 additions and 0 deletions

View file

@ -1,4 +1,5 @@
from cpp11_raw_string_literals import *
import inspect
if cvar.L != 100:
raise RuntimeError
@ -46,3 +47,29 @@ if cvar.ff != "I'm a \"raw wide\" \\ string.":
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.""")