99_bugs.py 952 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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. def g(x):
  26. return x
  27. def f(x):
  28. return x
  29. assert (g(1), 2) == (1, 2)
  30. assert (
  31. g(1),
  32. 2
  33. ) == (1, 2)
  34. assert f((
  35. g(1),
  36. 2
  37. )) == (1, 2)
  38. def f():
  39. for i in range(4):
  40. _ = 0
  41. while i: --i
  42. f()
  43. # class A: a=b=1
  44. # class A: a, b = 1, 2
  45. bmi = 0.0
  46. def test(a):
  47. if a:
  48. bmi = 1.4
  49. return f'{bmi:.2f}'
  50. assert test(1) == '1.40'
  51. try:
  52. assert test(0) == '0.00'
  53. exit(1)
  54. except UnboundLocalError:
  55. pass