99_bugs.py 999 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. # https://github.com/blueloveTH/pocketpy/issues/37
  2. mp = map(lambda x: x**2, [1, 2, 3, 4, 5] )
  3. assert list(mp) == [1, 4, 9, 16, 25]
  4. assert not 3>4
  5. def f(x):
  6. if x>1:
  7. return 1
  8. assert f(2) == 1
  9. assert f(0) == None
  10. a = [1, 2]
  11. b = [3, 4]
  12. assert a.append == a.append
  13. assert a.append is not a.append
  14. assert a.append is not b.append
  15. assert a.append != b.append
  16. inq = 0
  17. if not inq:
  18. assert True
  19. else:
  20. assert False
  21. if inq is not 1:
  22. assert True
  23. if inq is not 0:
  24. assert False
  25. # assert pow(2,5000,2**59-1) == 17592186044416
  26. def g(x):
  27. return x
  28. def f(x):
  29. return x
  30. assert (g(1), 2) == (1, 2)
  31. assert (
  32. g(1),
  33. 2
  34. ) == (1, 2)
  35. assert f((
  36. g(1),
  37. 2
  38. )) == (1, 2)
  39. def f():
  40. for i in range(4):
  41. _ = 0
  42. while i: --i
  43. f()
  44. # class A: a=b=1
  45. # class A: a, b = 1, 2
  46. bmi = 0.0
  47. def test(a):
  48. if a:
  49. bmi = 1.4
  50. return f'{bmi:.2f}'
  51. assert test(1) == '1.40'
  52. try:
  53. assert test(0) == '0.00'
  54. exit(1)
  55. except UnboundLocalError:
  56. pass