Research portable Memory game | Исследовать портируемую игру Память
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

ctx_test2.py 3.0KB

5 달 전
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. from ctx import *
  2. from memory import *
  3. from memory_Context import *
  4. def ctx_test_Controller_executeFunctions_registerFunction_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. @llm_by_value
  12. def processInput(c):
  13. if (
  14. c.recentField == "input"
  15. ):
  16. c.outputHelp = "Checked"
  17. c.recentField = "outputHelp"
  18. return c
  19. #}
  20. c.recentField = "none"
  21. return c
  22. #}
  23. ctrl.registerFunction(processInput)
  24. # Apply 'input'.
  25. ctrl.executeFunctions()
  26. # Apply 'outputHelp'.
  27. ctrl.executeFunctions()
  28. if (
  29. c.input == "123" and
  30. c.outputHelp == "Checked"
  31. ):
  32. return "OK: ctx_Controller_executeFunctions_set"
  33. #}
  34. return "ERR: ctx_Controller_executeFunctions_set"
  35. #}
  36. def ctx_test_Controller_processQueue(
  37. ) -> str:
  38. c = memory_createContext()
  39. ctrl = ctx_Controller(c)
  40. @llm_by_value
  41. def processInput(c):
  42. if (
  43. c.recentField == "input"
  44. ):
  45. c.outputHelp = "Checked"
  46. c.recentField = "outputHelp"
  47. return c
  48. #}
  49. c.recentField = "none"
  50. return c
  51. #}
  52. ctrl.registerFunction(processInput)
  53. ctrl.set("input", "abc");
  54. if (
  55. c.input == "abc" and
  56. c.outputHelp == "Checked"
  57. ):
  58. return "OK: ctx_Controller_processQueue"
  59. #}
  60. return "ERR: ctx_Controller_processQueue"
  61. #}
  62. def ctx_test_Controller_registerFieldCallback_match(
  63. ) -> str:
  64. c = memory_createContext()
  65. ctrl = ctx_Controller(c)
  66. c.input = "123"
  67. c.recentField = "input"
  68. globals()["callbackInput"] = ""
  69. def setCallbackInput(c):
  70. if (
  71. c.recentField == "input"
  72. ):
  73. globals()["callbackInput"] = c.input
  74. ctrl.registerFieldCallback("input", setCallbackInput)
  75. ctrl.reportContext()
  76. if (
  77. c.input == globals()["callbackInput"]
  78. ):
  79. return "OK: ctx_Controller_registerFieldCallback_match"
  80. #}
  81. return "ERR: ctx_Controller_registerFieldCallback_match"
  82. #}
  83. def ctx_test_Controller_registerFieldCallback_mismatch(
  84. ) -> str:
  85. c = memory_createContext()
  86. ctrl = ctx_Controller(c)
  87. c.input = "123"
  88. c.outputHelp = "you"
  89. # A field other than 'input' is marked recent.
  90. c.recentField = "outputHelp"
  91. globals()["callbackInput"] = ""
  92. def setCallbackInput(c):
  93. if (
  94. c.recentField == "input"
  95. ):
  96. globals()["callbackInput"] = c.input
  97. ctrl.registerFieldCallback("input", setCallbackInput)
  98. ctrl.reportContext()
  99. if (
  100. globals()["callbackInput"] == ""
  101. ):
  102. return "OK: ctx_Controller_registerFieldCallback_mismatch"
  103. #}
  104. return "ERR: ctx_Controller_registerFieldCallback_mismatch"
  105. #}
  106. def ctx_test_memoryContext_field(
  107. ) -> str:
  108. c = memory_createContext()
  109. c.input = "abc"
  110. if (
  111. c.field("input") == "abc"
  112. ):
  113. return "OK: ctx_memoryContext_field"
  114. #}
  115. return "ERR: ctx_memoryContext_field"
  116. #}
  117. def ctx_test_memoryContext_setField(
  118. ) -> str:
  119. c = memory_createContext()
  120. c.input = "abc"
  121. c.setField("input", "123")
  122. if (
  123. c.input == "123"
  124. ):
  125. return "OK: ctx_memoryContext_setField"
  126. #}
  127. return "ERR: ctx_memoryContext_setField"
  128. #}