Lines Matching defs:check
14 # different import patterns to check that __annotations__ does not interfere
192 # Sanity check: no literal begins with an underscore
196 check = self.check_syntax_error
197 check("0b12", "invalid digit '2' in binary literal")
198 check("0b1_2", "invalid digit '2' in binary literal")
199 check("0b2", "invalid digit '2' in binary literal")
200 check("0b1_", "invalid binary literal")
201 check("0b", "invalid binary literal")
202 check("0o18", "invalid digit '8' in octal literal")
203 check("0o1_8", "invalid digit '8' in octal literal")
204 check("0o8", "invalid digit '8' in octal literal")
205 check("0o1_", "invalid octal literal")
206 check("0o", "invalid octal literal")
207 check("0x1_", "invalid hexadecimal literal")
208 check("0x", "invalid hexadecimal literal")
209 check("1_", "invalid decimal literal")
210 check("012",
213 check("1.2_", "invalid decimal literal")
214 check("1e2_", "invalid decimal literal")
215 check("1e+", "invalid decimal literal")
218 def check(test, error=False):
232 check(f"{num}and x", error=(num == "0xf"))
233 check(f"{num}or x", error=(num == "0"))
234 check(f"{num}in x")
235 check(f"{num}not in x")
236 check(f"{num}if x else y")
237 check(f"x if {num}else y", error=(num == "0xf"))
238 check(f"[{num}for x in ()]")
239 check(f"{num}spam", error=True)
252 check("[0x1ffor x in ()]")
253 check("[0x1for x in ()]")
254 check("[0xfor x in ()]")
458 # check that functions fail the same way when executed
794 # check that trailing commas are permitted
1192 check = self.check_syntax_error
1193 check("def g(): [(yield x) for x in ()]",
1195 check("def g(): [x for x in () if not (yield x)]",
1197 check("def g(): [y for x in () for y in [(yield x)]]",
1199 check("def g(): {(yield x) for x in ()}",
1201 check("def g(): {(yield x): x for x in ()}",
1203 check("def g(): {x: (yield x) for x in ()}",
1205 check("def g(): ((yield x) for x in ())",
1207 check("def g(): [(yield from x) for x in ()]",
1209 check("class C: [(yield x) for x in ()]",
1211 check("[(yield x) for x in ()]",
1266 # these tests fail if python is run with -O, so check __debug__
1472 def check(test, msg='"is" with a literal'):
1475 check('x is 1')
1476 check('x is "thing"')
1477 check('1 is x')
1478 check('x is y is 1')
1479 check('x is not 1', '"is not" with a literal')
1489 def check(test):
1493 check('[(1, 2) (3, 4)]')
1494 check('[(x, y) (3, 4)]')
1495 check('[[1, 2] (3, 4)]')
1496 check('[{1, 2} (3, 4)]')
1497 check('[{1: 2} (3, 4)]')
1498 check('[[i for i in range(5)] (3, 4)]')
1499 check('[{i for i in range(5)} (3, 4)]')
1500 check('[(i for i in range(5)) (3, 4)]')
1501 check('[{i: i for i in range(5)} (3, 4)]')
1502 check('[f"{x}" (3, 4)]')
1503 check('[f"x={x}" (3, 4)]')
1504 check('["abc" (3, 4)]')
1505 check('[b"abc" (3, 4)]')
1506 check('[123 (3, 4)]')
1507 check('[12.3 (3, 4)]')
1508 check('[12.3j (3, 4)]')
1509 check('[None (3, 4)]')
1510 check('[True (3, 4)]')
1511 check('[... (3, 4)]')
1514 check('[{1, 2} [i, j]]')
1515 check('[{i for i in range(5)} [i, j]]')
1516 check('[(i for i in range(5)) [i, j]]')
1517 check('[(lambda x, y: x) [i, j]]')
1518 check('[123 [i, j]]')
1519 check('[12.3 [i, j]]')
1520 check('[12.3j [i, j]]')
1521 check('[None [i, j]]')
1522 check('[True [i, j]]')
1523 check('[... [i, j]]')
1526 check('[(1, 2) [i, j]]')
1527 check('[(x, y) [i, j]]')
1528 check('[[1, 2] [i, j]]')
1529 check('[[i for i in range(5)] [i, j]]')
1530 check('[f"{x}" [i, j]]')
1531 check('[f"x={x}" [i, j]]')
1532 check('["abc" [i, j]]')
1533 check('[b"abc" [i, j]]')
1536 check('[[1, 2] [3, 4]]')
1538 check('[[1, 2] [[3, 4]]]')
1539 check('[[1, 2] [[i for i in range(5)]]]')
1541 check('[[1, 2] [{3, 4}]]')
1542 check('[[1, 2] [{i for i in range(5)}]]')
1544 check('[[1, 2] [{3: 4}]]')
1545 check('[[1, 2] [{i: i for i in range(5)}]]')
1547 check('[[1, 2] [(i for i in range(5))]]')
1549 check('[[1, 2] [(lambda x, y: x)]]')
1551 check('[[1, 2] [f"{x}"]]')
1552 check('[[1, 2] [f"x={x}"]]')
1553 check('[[1, 2] ["abc"]]')
1555 check('[[1, 2] [b"abc"]]')
1556 check('[[1, 2] [12.3]]')
1557 check('[[1, 2] [12.3j]]')
1558 check('[[1, 2] [None]]')
1559 check('[[1, 2] [...]]')
1892 "helper to check that evaluation of expressions is done correctly"
1900 self.assertEqual((5 if 1 else _checkeval("check 1", 0)), 5)
1901 self.assertEqual((_checkeval("check 2", 0) if 0 else 5), 5)
1905 self.assertEqual((0 or _checkeval("check 3", 2) if 0 else 3), 3)
1906 self.assertEqual((1 or _checkeval("check 4", 2) if 1 else _checkeval("check 5", 3)), 1)
1907 self.assertEqual((0 or 5 if 1 else _checkeval("check 6", 3)), 5)