Abstract

In functional programming languages, such as Scala and Haskell, a higher-order function is a function that takes one or more functions as parameters or returns a function. Using higher-order functions in programs can increase the generality and reduce the redundancy of source code. To test a higher-order function, a tester needs to check the requirements and write another function as the test input. However, due to the complexity of higher-order functions, testing higher-order functions is a time-consuming and labor-intensive task. Testers have to spend an amount of manual effort in testing all higher-order functions. Such testing is infeasible if the time budget is limited, such as a period before a project release. In this paper, we propose an automatic approach, namely PHOF, which predicts whether a higher-order function will be called in the future. Higherorder functions that are most likely to be called should be tested first. Our approach can assist developers to reduce the number of higherorder functions under test. In PHOF, we extracted 24 features from source code and logs to train a predictive model based on known higher-order functions calls. We empirically evaluated our approach on 2854 higher-order functions from six real-world Scala projects. Experimental results show that PHOF based on the random forest algorithm and the SMOTE strategy performs well in the prediction of calls of higher-order functions. Our work can be used to support the scheduling of limited test resources.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call