add tests for bools and make helper method private

This commit is contained in:
Alex Waygood
2025-07-11 13:43:35 +01:00
parent 59570beb57
commit 3aa91a853e
3 changed files with 60 additions and 45 deletions

View File

@@ -57,6 +57,25 @@ reveal_type(a ^ a) # revealed: Literal[False]
reveal_type(a ^ b) # revealed: Literal[True]
reveal_type(b ^ a) # revealed: Literal[True]
reveal_type(b ^ b) # revealed: Literal[False]
# left-shift
reveal_type(a << a) # revealed: Literal[2]
reveal_type(a << b) # revealed: Literal[1]
reveal_type(b << a) # revealed: Literal[0]
reveal_type(b << b) # revealed: Literal[0]
reveal_type(True << 100) # revealed: int
# error: [literal-math-error] "Cannot left shift object of type `Literal[True]` by a negative value"
reveal_type(True << -1) # revealed: int
# right-shift
reveal_type(a >> a) # revealed: Literal[0]
reveal_type(a >> b) # revealed: Literal[1]
reveal_type(b >> a) # revealed: Literal[0]
reveal_type(b >> b) # revealed: Literal[0]
# error: [literal-math-error] "Cannot right shift object of type `Literal[False]` by a negative value"
reveal_type(False >> -1) # revealed: int
```
## Arithmetic with a variable

View File

@@ -151,7 +151,7 @@ reveal_type(MyInt(3) / 0) # revealed: int | float
## Bit-shifting
Literal artithmetic is supported for bit-shifting operations on `int`s:
Literal arithmetic is supported for bit-shifting operations on `int`s:
```py
reveal_type(42 << 3) # revealed: Literal[336]