Skip to content

SuccessValue

Michael Baas edited this page May 19, 2022 · 1 revision

(available with DTest 1.70)

This setting (in a .dyalogtest file or as a switch when calling the UCMD) can be used to define the value that you want to use to indicate a test has been successfull. (By default we expect an empty string) NB: this is the value that is returned by your **test **function, not by the tested function. Generally that value is a personal preference, some people may not like to default and rather follow dfn-style and return a 0 to indicate "No problems!". Because of the rather static nature of this parameter, it is recommended to use it in .dyalogtest and not on the commandline.

The internal checking use , so it is essential to pass the value with the right shape. This can be tricky with values such as (scalar) 0 - since we can't discern it when doing ⎕VFI.

That's why we offer a new way of "encoding" the value: prefix it with the string "json!" and append the ⎕JSON-equivalent of that value, so use

  • -SuccessValue=json!0" for scalar 0
  • -SuccessValue=json![0]" for vector 0

String values can be passed verbatim - as long as they do not contain spaces! If you do want to use an indicator with spaces, use the b64! prefix and append the base64-encoded string! (To facilate that encoding, we now make fn base64encode available in the ⎕SE._cita namespace which you can load using ]GetTools4CITA (or ⎕SE.UCMD'GetTools4CITA` if you want to use it in a function)

In addition, there also is an apl! prefix which can be used to include APL-Statements. (NB: passing those via EnvVar or Commandline can be difficult, so you may need to base64encode them as we did in this example:

Step Code
Expected Value ',ZI4,<->,ZI2,<->,ZI2,< found no problems!>'⎕fmt 1 3⍴⎕TS
Computing the SuccessValue #.base64enc'apl!'',ZI4,<->,ZI2,<->,ZI2,< found no problems!>''⎕fmt 1 3⍴⎕TS'
Result YXBsISc8VGhlIHRlc3QgZXhlY3V0ZWQgb24gPixaSTQsPC0+LFpJMiw8LT4sWkkyLDwgZm91bmQgbm8gcHJvYmxlbXMhPifijpVmbXQgMSAz4o204o6VVFM=
Finally -SuccessValue=b64!YXBsISc8VGhlIHRlc3QgZXhlY3V0ZWQgb24gPixaSTQsPC0+LFpJMiw8LT4sWkkyLDwgZm91bmQgbm8gcHJvYmxlbXMhPifijpVmbXQgMSAz4o204o6VVFM=