| [case testDictGet] |
| from typing import Dict |
| def f(d: Dict[int, bool]) -> bool: |
| return d[0] |
| [out] |
| def f(d): |
| d :: dict |
| r0 :: short_int |
| r1, r2 :: object |
| r3 :: bool |
| L0: |
| r0 = 0 |
| r1 = box(short_int, r0) |
| r2 = d[r1] :: dict |
| r3 = unbox(bool, r2) |
| return r3 |
| |
| [case testDictSet] |
| from typing import Dict |
| def f(d: Dict[int, bool]) -> None: |
| d[0] = False |
| [out] |
| def f(d): |
| d :: dict |
| r0 :: bool |
| r1 :: short_int |
| r2, r3 :: object |
| r4 :: bool |
| r5 :: None |
| L0: |
| r0 = False |
| r1 = 0 |
| r2 = box(short_int, r1) |
| r3 = box(bool, r0) |
| r4 = d.__setitem__(r2, r3) :: dict |
| r5 = None |
| return r5 |
| |
| [case testNewEmptyDict] |
| from typing import Dict |
| def f() -> None: |
| d = {} # type: Dict[bool, int] |
| [out] |
| def f(): |
| r0, d :: dict |
| r1 :: None |
| L0: |
| r0 = {} |
| d = r0 |
| r1 = None |
| return r1 |
| |
| [case testNewDictWithValues] |
| def f(x: object) -> None: |
| d = {1: 2, '': x} |
| [out] |
| def f(x): |
| x :: object |
| r0, r1 :: short_int |
| r2 :: str |
| r3, r4 :: object |
| r5, d :: dict |
| r6 :: None |
| L0: |
| r0 = 1 |
| r1 = 2 |
| r2 = unicode_1 :: static |
| r3 = box(short_int, r0) |
| r4 = box(short_int, r1) |
| r5 = {r3: r4, r2: x} |
| d = r5 |
| r6 = None |
| return r6 |
| |
| [case testInDict] |
| from typing import Dict |
| def f(d: Dict[int, int]) -> bool: |
| if 4 in d: |
| return True |
| else: |
| return False |
| [out] |
| def f(d): |
| d :: dict |
| r0 :: short_int |
| r1 :: object |
| r2, r3, r4 :: bool |
| L0: |
| r0 = 4 |
| r1 = box(short_int, r0) |
| r2 = r1 in d :: dict |
| if r2 goto L1 else goto L2 :: bool |
| L1: |
| r3 = True |
| return r3 |
| L2: |
| r4 = False |
| return r4 |
| L3: |
| unreachable |
| |
| [case testNotInDict] |
| from typing import Dict |
| def f(d: Dict[int, int]) -> bool: |
| if 4 not in d: |
| return True |
| else: |
| return False |
| [out] |
| def f(d): |
| d :: dict |
| r0 :: short_int |
| r1 :: object |
| r2, r3, r4, r5 :: bool |
| L0: |
| r0 = 4 |
| r1 = box(short_int, r0) |
| r2 = r1 in d :: dict |
| r3 = !r2 |
| if r3 goto L1 else goto L2 :: bool |
| L1: |
| r4 = True |
| return r4 |
| L2: |
| r5 = False |
| return r5 |
| L3: |
| unreachable |
| |
| [case testDictUpdate] |
| from typing import Dict |
| def f(a: Dict[int, int], b: Dict[int, int]) -> None: |
| a.update(b) |
| [out] |
| def f(a, b): |
| a, b :: dict |
| r0 :: bool |
| r1, r2 :: None |
| L0: |
| r0 = a.update(b) :: dict |
| r1 = None |
| r2 = None |
| return r2 |
| |
| [case testDictKeyLvalue] |
| from typing import Dict |
| def increment(d: Dict[str, int]) -> Dict[str, int]: |
| for k in d: |
| d[k] += 1 |
| return d |
| [out] |
| def increment(d): |
| d :: dict |
| r0, r1 :: object |
| r2, k :: str |
| r3 :: object |
| r4 :: short_int |
| r5, r6 :: object |
| r7, r8 :: bool |
| L0: |
| r0 = iter d :: object |
| L1: |
| r1 = next r0 :: object |
| if is_error(r1) goto L4 else goto L2 |
| L2: |
| r2 = cast(str, r1) |
| k = r2 |
| r3 = d[k] :: dict |
| r4 = 1 |
| r5 = box(short_int, r4) |
| r6 = r3 += r5 |
| r7 = d.__setitem__(k, r6) :: dict |
| L3: |
| goto L1 |
| L4: |
| r8 = no_err_occurred |
| L5: |
| return d |
| |
| [case testDictDisplay] |
| from typing import Dict |
| def f(x: str, y: Dict[str, int]) -> Dict[str, int]: |
| return {x: 2, **y, 'z': 3} |
| [out] |
| def f(x, y): |
| x :: str |
| y :: dict |
| r0 :: short_int |
| r1 :: str |
| r2 :: short_int |
| r3 :: object |
| r4 :: dict |
| r5 :: bool |
| r6 :: object |
| r7 :: bool |
| L0: |
| r0 = 2 |
| r1 = unicode_3 :: static ('z') |
| r2 = 3 |
| r3 = box(short_int, r0) |
| r4 = {x: r3} |
| r5 = r4.update(y) (display) :: dict |
| r6 = box(short_int, r2) |
| r7 = r4.__setitem__(r1, r6) :: dict |
| return r4 |
| |