ku-progsys / rbsyn

Program synthesis for Ruby
BSD 3-Clause "New" or "Revised" License
94 stars 4 forks source link

better DSL for tests #26

Open ngsankha opened 4 years ago

ngsankha commented 4 years ago

the specification is provided in a custom DSL that requires us to write pre and post blocks. There is a possible way to write more natural specifications that looks exactly like tests, without separate pre and post blocks.

wrapped_func1:
  call synthesized func
  raise an exception wrapping the return value

wrapped_func2:
  call wrapped_func1
  if need to run user provided post condition:
    catch the exception and return unwrapped return value
  else:
    forward the exception

eval_ast:
  set the flag to indicate if running user provided postcond or not
  define wrapped_func2 instead of synthesized func in the eval context
  eval the spec
  if exception:
    call the engine provided post cond
  else:
    we have run the user post cond

This is a tricky change to make, but will make the user specs look much nicer.