test: add union type tests

This commit is contained in:
Shunsuke Shibayama 2024-08-20 02:20:06 +09:00
parent 94221a6419
commit d448aaf974
2 changed files with 14 additions and 0 deletions

View File

@ -142,6 +142,11 @@ fn exec_typevar() -> Result<(), String> {
expect("tests/typevar.py", 0, 3)
}
#[test]
fn exec_union() -> Result<(), String> {
expect("tests/union.py", 0, 0)
}
#[test]
fn exec_widening() -> Result<(), String> {
expect("tests/widening.py", 0, 1)

9
tests/union.py Normal file
View File

@ -0,0 +1,9 @@
s: str | bytes = ""
s2 = s.capitalize()
s3 = s2.center(1)
s4: str | bytes | bytearray = ""
_ = s4.__len__()
def f(x: str | bytes):
return x.isalnum()