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.
- Cem Bassoy and Volker Schatz. 2018. Fast Higher-Order Functions for Tensor Calculus with Tensors and Subtensors. In Computational Science - ICCS 2018 - 18th International Conference, Wuxi, China, June 11-13, 2018, Proceedings, Part I. 639--652. https://doi.org/10.1007/978-3-319-93698-7_49Google Scholar
- Leo Breiman. 2001. Random Forests. Machine Learning 45, 1 (2001), 5--32. https://doi.org/10.1023/A:1010933404324Google ScholarDigital Library
- Franck Cassez and Anthony M. Sloane. 2017. ScalaSMT: satisfiability modulo theory in Scala. In Proceedings of the 8th ACM SIGPLAN International Symposium on Scala, SCALA@SPLASH 2017, Vancouver, BC, Canada, October 22-23, 2017. 51--55. https://doi.org/10.1145/3136000.3136004Google Scholar
- Nitesh V. Chawla, Kevin W. Bowyer, Lawrence O. Hall, and W. Philip Kegelmeyer. 2002. SMOTE: Synthetic Minority Over-sampling Technique. J. Artif. Intell. Res. 16 (2002), 321--357. https://doi.org/10.1613/jair.953Google ScholarCross Ref
- Zongzheng Chi, Jifeng Xuan, Zhilei Ren, Xiaoyuan Xie, and He Guo. 2017. Multi-Level Random Walk for Software Test Suite Reduction. IEEE Comp. Int. Mag. 12, 2 (2017), 24--33. https://doi.org/10.1109/MCI.2017.2670460Google ScholarDigital Library
- Corinna Cortes and Vladimir Vapnik. 1995. Support-Vector Networks. Machine Learning 20, 3 (1995), 273--297. https://doi.org/10.1007/BF00994018Google ScholarCross Ref
- Leo Egghe and Loet Leydesdorff. 2009. The relation between Pearson's correlation coefficient r and Salton's cosine measure. JASIST 60, 5 (2009), 1027--1036. https://doi.org/10.1002/asi.21009Google ScholarDigital Library
- Marius Eriksen. 2012. Effective Scala. http://twitter.github.io/effectivescala.Google Scholar
- Yongfeng Gu, Jifeng Xuan, Hongyu Zhang, Lanxin Zhang, Qingna Fan, Xiaoyuan Xie, and Tieyun Qian. 2019. Does the fault reside in a stack trace? Assisting crash localization by predicting crashing fault residence. Journal of Systems and Software 148 (2019), 88--104. https://doi.org/10.1016/j.jss.2018.11.004Google ScholarCross Ref
- Haibo He, Yang Bai, Edwardo A. Garcia, and Shutao Li. 2008. ADASYN: Adaptive synthetic sampling approach for imbalanced learning. In Proceedings of the International Joint Conference on Neural Networks, IJCNN 2008, part of the IEEE World Congress on Computational Intelligence, WCCI 2008, Hong Kong, China, June 1-6, 2008. 1322--1328. https://doi.org/10.1109/IJCNN.2008.4633969Google Scholar
- Haibo He and Edwardo A. Garcia. 2009. Learning from Imbalanced Data. IEEE Trans. Knowl. Data Eng. 21, 9 (2009), 1263--1284. https://doi.org/10.1109/TKDE.2008.239Google ScholarDigital Library
- Olof Karlsson and Philipp Haller. 2018. Extending Scala with records: design, implementation, and evaluation. In Proceedings of the 9th ACM SIGPLAN International Symposium on Scala, SCALA@ICFP 2018, St. Louis, MO, USA, September 28, 2018. 72--82. https://doi.org/10.1145/3241653.3241661Google ScholarDigital Library
- Pieter W. M. Koopman and Rinus Plasmeijer. 2006. Automatic Testing of Higher Order Functions. In Programming Languages and Systems, 4th Asian Symposium, APLAS 2006, Sydney, Australia, November 8-10, 2006, Proceedings. 148--164. https://doi.org/10.1007/11924661_9Google Scholar
- Lars Kroll, Paris Carbone, and Seif Haridi. 2017. Kompics Scala: narrowing the gap between algorithmic specification and executable code (short paper). In Proceedings of the 8th ACM SIGPLAN International Symposium on Scala, SCALA@SPLASH 2017, Vancouver, BC, Canada, October 22-23, 2017. 73--77. https://doi.org/10.1145/3136000.3136009Google ScholarDigital Library
- Daniel Lincke and Sibylle Schupp. 2012. From HOT to COOL: transforming higher-order typed languages to concept-constrained object-oriented languages. In International Workshop on Language Descriptions, Tools, and Applications, LDTA '12, Tallinn, Estonia, March 31-April 1, 2012. 3. https://doi.org/10.1145/2427048.2427051Google ScholarDigital Library
- Ping Ma, Danni Xu, Xin Zhang, and Jifeng Xuan. 2019. Changes Are Similar: Measuring Similarity of Pull Requests That Change the Same Code in GitHub. In Software Engineering and Methodology for Emerging Domains, Zheng Li, He Jiang, Ge Li, Minghui Zhou, and Ming Li (Eds.). Springer Singapore, Singapore, 115--128.Google Scholar
- Ravichandhran Madhavan, Sumith Kulal, and Viktor Kuncak. 2017. Contract-based resource verification for higher-order functions with memoization. In Proceedings of the 44th ACM SIGPLAN Symposium on Principles of Programming Languages, POPL 2017, Paris, France, January 18-20, 2017. 330--343. http://dl.acm.org/citation.cfm?id=3009874Google ScholarDigital Library
- Thomas J. McCabe. 1976. A Complexity Measure. IEEE Trans. Software Eng. 2, 4 (1976), 308--320. https://doi.org/10.1109/TSE.1976.233837Google ScholarDigital Library
- Takao Nakaguchi, Yohei Murakami, Donghui Lin, and Toru Ishida. 2016. Higher-Order Functions for Modeling Hierarchical Service Bindings. In IEEE International Conference on Services Computing, SCC 2016, San Francisco, CA, USA, June 27-July 2, 2016. 798--803. https://doi.org/10.1109/SCC.2016.110Google Scholar
- Nathaniel Nystrom. 2017. A Scala framework for supercompilation. In Proceedings of the 8th ACM SIGPLAN International Symposium on Scala, SCALA@SPLASH 2017, Vancouver, BC, Canada, October 22-23, 2017. 18--28. https://doi.org/10.1145/3136000.3136011Google ScholarDigital Library
- Martin Odersky, Philippe Altherr, Vincent Cremet, Burak Emir, Sebastian Maneth, Stéphane Micheloud, Nikolay Mihaylov, Michel Schinz, Erik Stenman, and Matthias Zenger. 2004. An overview of the Scala programming language. Technical Report. Technical Report IC/2004/64, EPFL Lausanne, Switzerland.Google Scholar
- Bob Reynders, Michael Greefs, Dominique Devriese, and Frank Piessens. 2018. Scalagna 0.1: towards multi-tier programming with Scala and Scala.js. In Conference Companion of the 2nd International Conference on Art, Science, and Engineering of Programming, Nice, France, April 09-12, 2018. 69--74. https://doi.org/10.1145/3191697.3191731Google ScholarDigital Library
- Vlad Rusu and Andrei Arusoaie. 2017. Executing and verifying higher-order functional-imperative programs in Maude. J. Log. Algebr. Meth. Program. 93 (2017), 68--91. https://doi.org/10.1016/j.jlamp.2017.09.002Google ScholarCross Ref
- Marija Selakovic, Michael Pradel, Rezwana Karim, and Frank Tip. 2018. Test generation for higher-order functions in dynamic languages. PACMPL 2, OOPSLA (2018), 161:1--161:27. https://doi.org/10.1145/3276531Google Scholar
- Tim van der Lippe, Thomas Smith, Daniël Pelsmaeker, and Eelco Visser. 2016. A scalable infrastructure for teaching concepts of programming languages in Scala with WebLab: an experience report. In Proceedings of the 7th ACM SIGPLAN Symposium on Scala, SCALA@SPLASH 2016, Amsterdam, Netherlands, October 30-November 4, 2016. 65--74. https://doi.org/10.1145/2998392.2998402Google ScholarDigital Library
- Nicolas Voirol, Etienne Kneuss, and Viktor Kuncak. 2015. Counter-example complete verification for higher-order functions. In Proceedings of the 6th ACM SIGPLAN Symposium on Scala, Scala@PLDI 2015, Portland, OR, USA, June 15-17, 2015. 18--29. https://doi.org/10.1145/2774975.2774978Google ScholarDigital Library
- Tao Wang, Yang Zhang, Gang Yin, Yue Yu, and Huaimin Wang. 2018. Who Will Become a Long-Term Contributor?: A Prediction Model based on the Early Phase Behaviors. In Proceedings of the Tenth Asia-Pacific Symposium on Internetware, Internetware 2018, Beijing, China, September 16-16, 2018. 9:1--9:10. https://doi.org/10.1145/3275219.3275223Google ScholarDigital Library
- Yisen Xu, Fan Wu, Xiangyang Jia, Lingbo Li, and Jifeng Xuan. 2019. Mining the Use of Higher-Order Functions: An Exploratory Study on Scala Programs. In Proceedings of the National Software Application Conference of China (NASAC 2019). to appear.Google Scholar
- Xin Zhang, Yang Chen, Yongfeng Gu, Weiqin Zou, Xiaoyuan Xie, Xiangyang Jia, and Jifeng Xuan. 2018. How do Multiple Pull Requests Change the Same Code: A Study of Competing Pull Requests in GitHub. In 2018 IEEE International Conference on Software Maintenance and Evolution, ICSME 2018, Madrid, Spain, September 23-29, 2018. 228--239. https://doi.org/10.1109/ICSME.2018.00032Google ScholarCross Ref
Index Terms
- Writing Tests for This Higher-Order Function First: Automatically Identifying Future Callings to Assist Testers
Recommendations
Test generation for higher-order functions in dynamic languages
Test generation has proven to provide an effective way of identifying programming errors. Unfortunately, current test generation techniques are challenged by higher-order functions in dynamic languages, such as JavaScript functions that receive ...
Mining the use of higher-order functions:: An exploratory study on Scala programs
AbstractA higher-order function takes one or more functions as inputs or outputs to support the generality of function definitions. In modern programming languages, higher-order functions are designed as a feature to enhance usability and scalability. ...
Local higher-order fixpoint iteration
AbstractLocal fixpoint iteration describes a technique that restricts fixpoint iteration in function spaces to needed arguments only. It has been studied well for first-order functions in abstract interpretation and also in model checking. ...
Comments