testFun: Call a function and compare the result

Description Usage Arguments Value Author(s) See Also Examples

Description

This function and its methods uses the inputs from an observed call to a function to compare the behaviour of a new version of that function to determine if it produces the same result. This uses the arguments and any global variables to recreate the call and compares the new result to the one obtained in the original call.

Usage

1
testFunCall(x, fun, compare = identical, ...)

Arguments

x

the FunctionCallResults or CallResultInfo objects from collectCallResults.

fun

the definition of the function with which to compare the calls and results in x to the results from this function.

compare

a function used to compare the results from the original call to the result from each of these calls.

...

additional arguments passed to the compare function.

Value

Since this is a generic function, the resulting value will be different according to the inputs. For FunctionCallResults, this returns a list of values. For CallResultInfo, this returns the value from the compare function.

Author(s)

Duncan Temple Lang

See Also

collectCallResults

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
global1 = 10
global2 = 3.1415
f3 = function(x, y)
        x + y + global1 + global2
e3 = collectCallResults("f3")

f3(10, 11)
f3(999, 777)
k = e3()

testFunCall(k, f3)

rm(global1, global2)
testFunCall(k, f3)

testFunCall(k, function(x, y) x + y + global1 + global2)

duncantl/CallCounter documentation built on Jan. 20, 2020, 5:16 a.m.