from ctx import *
from memory import *
from memory_Context import *

def ctx_test_Python_Controller_registerFieldCallback_match(
) -> str:
  c = memory_createContext()
  ctrl = ctx_Controller(c)
  c.input = "123"
  c.recentField = "input"
  globals()["__callbackInput"] = ""
  ctrl.registerFieldCallback("input", __setCallbackInput)
  ctrl.reportContext()
  val = globals()["__callbackInput"]
  if (
    c.input == globals()["__callbackInput"]
  ):
    return "OK: ctx_Python_Controller_registerFieldCallback_match"
  #}
  return f"ERR: ctx_Python_Controller_registerFieldCallback_match"
#}

def ctx_test_Python_Controller_registerFieldCallback_mismatch(
) -> str:
  c = memory_createContext()
  ctrl = ctx_Controller(c)
  c.input = "123"
  c.outputHelp = "you"
  c.recentField = "outputHelp"
  globals()["__callbackInput"] = ""
  ctrl.registerFieldCallback("input", __setCallbackInput)
  ctrl.reportContext()
  val = globals()["__callbackInput"]
  if (
    globals()["__callbackInput"] == ""
  ):
    return "OK: ctx_Python_Controller_registerFieldCallback_mismatch"
  #}
  return f"ERR: ctx_Python_Controller_registerFieldCallback_mismatch"
#}

# Auxiliary.

__callbackInput = ""

@llm_by_value
def __setCallbackInput(c):
  if (
    c.recentField == "input"
  ):
    globals()["__callbackInput"] = c.input
  #}
#}
