Skip to content

Commit

Permalink
Add test case
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharsadhwani committed Oct 15, 2023
1 parent 48348fa commit 78c1e9c
Showing 1 changed file with 157 additions and 0 deletions.
157 changes: 157 additions & 0 deletions tests/data/cases/pep_701.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
# flags: --minimum-version=3.12
x = f"foo"
x = f'foo'
x = f"""foo"""
x = f'''foo'''
x = f"foo {{ bar {{ baz"
x = f"foo {{ {2 + 2}bar {{ baz"
x = f'foo {{ {2 + 2}bar {{ baz'
x = f"""foo {{ {2 + 2}bar {{ baz"""
x = f'''foo {{ {2 + 2}bar {{ baz'''

# edge case: FSTRING_MIDDLE containing only whitespace should not be stripped
x = f"{a} {b}"

x = f"foo {
2 + 2
} bar baz"

x = f"foo {{ {"a {2 + 2} b"}bar {{ baz"
x = f"foo {{ {f'a {2 + 2} b'}bar {{ baz"
x = f"foo {{ {f"a {2 + 2} b"}bar {{ baz"

x = f"foo {{ {f'a {f"a {2 + 2} b"} b'}bar {{ baz"
x = f"foo {{ {f"a {f"a {2 + 2} b"} b"}bar {{ baz"

x = """foo {{ {2 + 2}bar
baz"""


x = f"""foo {{ {2 + 2}bar {{ baz"""

x = f"""foo {{ {
2 + 2
}bar {{ baz"""


x = f"""foo {{ {
2 + 2
}bar
baz"""

x = f"""foo {{ a
foo {2 + 2}bar {{ baz
x = f"foo {{ {
2 + 2 # comment
}bar"
{{ baz
}} buzz
{print("abc" + "def"
)}
abc"""

# edge case: end triple quotes at index zero
f"""foo {2+2} bar
"""

f' \' {f"'"} \' '
f" \" {f'"'} \" "

x = f"a{2+2:=^72}b"
x = f"a{2+2:x}b"

rf'foo'
rf'{foo}'

x = f"a{2+2:=^{x}}b"
x = f"a{2+2:=^{foo(x+y**2):something else}}b"
f'{(abc:=10)}'

f"This is a really long string, but just make sure that you reflow fstrings {
2+2:d
}"
f"This is a really long string, but just make sure that you reflow fstrings correctly {2+2:d}"

# output

x = f"foo"
x = f"foo"
x = f"""foo"""
x = f"""foo"""
x = f"foo {{ bar {{ baz"
x = f"foo {{ {2 + 2}bar {{ baz"
x = f"foo {{ {2 + 2}bar {{ baz"
x = f"""foo {{ {2 + 2}bar {{ baz"""
x = f"""foo {{ {2 + 2}bar {{ baz"""

# edge case: FSTRING_MIDDLE containing only whitespace should not be stripped
x = f"{a} {b}"

x = f"foo {2 + 2} bar baz"

x = f"foo {{ {"a {2 + 2} b"}bar {{ baz"
x = f"foo {{ {f"a {2 + 2} b"}bar {{ baz"
x = f"foo {{ {f"a {2 + 2} b"}bar {{ baz"

x = f"foo {{ {f"a {f"a {2 + 2} b"} b"}bar {{ baz"
x = f"foo {{ {f"a {f"a {2 + 2} b"} b"}bar {{ baz"

x = """foo {{ {2 + 2}bar
baz"""


x = f"""foo {{ {2 + 2}bar {{ baz"""

x = f"""foo {{ {2 + 2}bar {{ baz"""


x = f"""foo {{ {
2 + 2
}bar
baz"""

x = f"""foo {{ a
foo {
2 + 2
}bar {{ baz
x = f"foo {{ {
2 + 2 # comment
}bar"
{{ baz
}} buzz
{
print("abc" + "def")
}
abc"""

# edge case: end triple quotes at index zero
f"""foo {
2 + 2
} bar
"""

f" ' {f"'"} ' "
f' " {f'"'} " '

x = f"a{2 + 2:=^72}b"
x = f"a{2 + 2:x}b"

rf"foo"
rf"{foo}"

x = f"a{2 + 2:=^{x}}b"
x = f"a{2 + 2:=^{foo(x + y**2):something else}}b"
f"{(abc := 10)}"

f"This is a really long string, but just make sure that you reflow fstrings {2 + 2:d}"
f"This is a really long string, but just make sure that you reflow fstrings correctly {
2 + 2:d
}"

0 comments on commit 78c1e9c

Please sign in to comment.