Mirror of CollapseOS
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

105 行
1.2KB

  1. jp test
  2. .inc "core.asm"
  3. .inc "str.asm"
  4. .inc "lib/util.asm"
  5. .inc "lib/ari.asm"
  6. .inc "lib/parse.asm"
  7. .equ EXPR_PARSE parseLiteral
  8. .inc "lib/expr.asm"
  9. .inc "basic/parse.asm"
  10. test:
  11. ld sp, 0xffff
  12. call testParseThruth
  13. ; success
  14. xor a
  15. halt
  16. testParseThruth:
  17. ld hl, .t1
  18. call .true
  19. ld hl, .t2
  20. call .true
  21. ld hl, .t3
  22. call .true
  23. ld hl, .t4
  24. call .true
  25. ld hl, .t5
  26. call .true
  27. ld hl, .t6
  28. call .true
  29. ld hl, .t7
  30. call .true
  31. ld hl, .t8
  32. call .true
  33. ld hl, .f1
  34. call .false
  35. ld hl, .f2
  36. call .false
  37. ld hl, .f3
  38. call .false
  39. ld hl, .f4
  40. call .false
  41. ld hl, .f5
  42. call .false
  43. ld hl, .f6
  44. call .false
  45. ld hl, .e1
  46. call .error
  47. ret
  48. .true:
  49. call parseTruth
  50. jp nz, fail
  51. or a
  52. jp z, fail
  53. jp nexttest
  54. .false:
  55. call parseTruth
  56. jp nz, fail
  57. or a
  58. jp nz, fail
  59. jp nexttest
  60. .error:
  61. call parseTruth
  62. jp z, fail
  63. jp nexttest
  64. .t1: .db "42", 0
  65. .t2: .db "42+4=50-4", 0
  66. .t3: .db "1<2", 0
  67. .t4: .db "2>1", 0
  68. .t5: .db "2>=1", 0
  69. .t6: .db "2>=2", 0
  70. .t7: .db "1<=2", 0
  71. .t8: .db "2<=2", 0
  72. .f1: .db "42-42", 0
  73. .f2: .db "42+4=33+2", 0
  74. .f3: .db "2<2", 0
  75. .f4: .db "1>2", 0
  76. .f5: .db "1>=2", 0
  77. .f6: .db "2<=1", 0
  78. .e1: .db "foo", 0
  79. testNum: .db 1
  80. nexttest:
  81. ld a, (testNum)
  82. inc a
  83. ld (testNum), a
  84. ret
  85. fail:
  86. ld a, (testNum)
  87. halt
  88. ; used as RAM
  89. sandbox: