Research portable Memory game | Исследовать портируемую игру Память
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ctx_test.py 1.7KB

5 months ago
5 months ago
5 months ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. from ctx import *
  2. from memory import *
  3. from memory_Context import *
  4. def ctx_test_Controller_executeFunctions_set(
  5. ) -> str:
  6. c = memory_createContext()
  7. ctrl = ctx_Controller(c)
  8. # Disable automatic invocation of executeFunctions.
  9. ctrl.isProcessingQueue = True
  10. ctrl.set("input", "123")
  11. ctrl.registerFunction(__processInput)
  12. # Apply 'input'.
  13. ctrl.executeFunctions()
  14. # Apply 'outputHelp'.
  15. ctrl.executeFunctions()
  16. if (
  17. c.input == "123" and
  18. c.outputHelp == "Checked"
  19. ):
  20. return "OK: ctx_Controller_executeFunctions_set"
  21. #}
  22. return "ERR: ctx_Controller_executeFunctions_set"
  23. #}
  24. def ctx_test_Controller_processQueue(
  25. ) -> str:
  26. c = memory_createContext()
  27. ctrl = ctx_Controller(c)
  28. ctrl.registerFunction(__processInput)
  29. ctrl.set("input", "abc");
  30. if (
  31. c.input == "abc" and
  32. c.outputHelp == "Checked"
  33. ):
  34. return "OK: ctx_Controller_processQueue"
  35. #}
  36. return "ERR: ctx_Controller_processQueue"
  37. #}
  38. def ctx_test_memoryContext_field(
  39. ) -> str:
  40. c = memory_createContext()
  41. c.input = "abc"
  42. if (
  43. c.field("input") == "abc"
  44. ):
  45. return "OK: ctx_memoryContext_field"
  46. #}
  47. return "ERR: ctx_memoryContext_field"
  48. #}
  49. def ctx_test_memoryContext_setField(
  50. ) -> str:
  51. c = memory_createContext()
  52. c.input = "abc"
  53. c.setField("input", "123")
  54. if (
  55. c.field("input") == "123"
  56. ):
  57. return "OK: ctx_memoryContext_setField"
  58. #}
  59. return "ERR: ctx_memoryContext_setField"
  60. #}
  61. # Auxiliary functions.
  62. @llm_by_value
  63. def __processInput(
  64. c: memory_Context
  65. ) -> memory_Context:
  66. if (
  67. c.recentField == "input"
  68. ):
  69. c.outputHelp = "Checked"
  70. c.recentField = "outputHelp"
  71. return c
  72. #}
  73. c.recentField = "none"
  74. return c
  75. #}