examples.py 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. test_parse(Number, '+6.0223e23')
  2. test_parse(RollExpr, [
  3. '4d4',
  4. '2d20K',
  5. '8d6x1',
  6. '8d4!p<=1',
  7. '8d4r4',
  8. '8d6r1>3f<3',
  9. ])
  10. test_parse(Expression, [
  11. 'x+1',
  12. '4d4+4',
  13. '2*2',
  14. '(2*2)',
  15. '2d20K + d6 + (2 * 2 ^ 2)',
  16. ])
  17. test_parse(VarAssignment, [
  18. 'x= 5',
  19. 'int = d20 + 7',
  20. ])
  21. test_parse(InputParser, [
  22. '4d4',
  23. '2d20K',
  24. '8d6x1',
  25. '8d4!p<=1',
  26. '8d4r4',
  27. '8d6r1>3f<3',
  28. 'x+1',
  29. '4d4+4',
  30. '2*2',
  31. '(2*2)',
  32. '2d20K + d6 + (2 * 2 ^ 2)',
  33. 'x= 5',
  34. 'int = d20 + 7',
  35. 'del x',
  36. 'delete x',
  37. 'help',
  38. 'quit',
  39. 'v',
  40. ])
  41. # examples = [
  42. # '1+1',
  43. # '1 + 1 + x',
  44. # '3d8',
  45. # '2e3 * 4d6 + 2',
  46. # '2d20k',
  47. # '3d20x2',
  48. # '4d4rK3',
  49. # '4d4R4',
  50. # '4d4R>=3',
  51. # '4d4r>=3',
  52. # '4d4!1',
  53. # '4d4!<3',
  54. # '4d4!p',
  55. # '2D20K+10',
  56. # '2D20k+10',
  57. # '10d6X4',
  58. # '4d8r + 6',
  59. # '20d6R≤2',
  60. # '6d10!≥8+6',
  61. # '10d4!p',
  62. # '20d6≥6',
  63. # '8d12≥10f≤2',
  64. # ]
  65. # example_results = {}
  66. # for x in examples:
  67. # try:
  68. # example_results[x] = parse_roll(x)
  69. # except ParseException as ex:
  70. # example_results[x] = ex
  71. # example_results