elchemy icon indicating copy to clipboard operation
elchemy copied to clipboard

Implement purity tests for FFI based on property testing

Open wende opened this issue 8 years ago • 2 comments

Along with typetests which verify the spec of a function we want a property test that checks whether used FFI call is pure and total.

For example:

myDivision : Float -> Float -> Float
myDivision =
  ffi "Kernel" "/"

Should verify "all" possible incomes and outcomes:

  • Check the params for 0 and any possible random floats -2^128 - 2^128
  • Verify if there is a return value of type float. If not fail the test -> Function throws an error when second parameter is a 0. It has to be fixed by using different module like ffi "NativeBasics "safe_div"

Example 2

myMap : (Bool -> Int) -> List Bool -> List Int
  1. Generate a function verifying that it took a bool and returning a random int
  2. Generate a list of random length with random bools inside
  3. Check if function always returns a list of integers. If not throw

Etc

wende avatar Jul 26 '17 20:07 wende

You might be able to generate these with some of the elixir property testing libraries to save work.

OvermindDL1 avatar Jul 26 '17 21:07 OvermindDL1

Blocked by #202

wende avatar Oct 02 '17 20:10 wende