skip to main content
10.1145/3361242.3361256acmotherconferencesArticle/Chapter ViewAbstractPublication PagesinternetwareConference Proceedingsconference-collections
research-article

Writing Tests for This Higher-Order Function First: Automatically Identifying Future Callings to Assist Testers

Authors Info & Claims
Published:28 October 2019Publication History

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.

References

  1. 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 ScholarGoogle Scholar
  2. Leo Breiman. 2001. Random Forests. Machine Learning 45, 1 (2001), 5--32. https://doi.org/10.1023/A:1010933404324Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. 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 ScholarGoogle Scholar
  4. 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 ScholarGoogle ScholarCross RefCross Ref
  5. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  6. Corinna Cortes and Vladimir Vapnik. 1995. Support-Vector Networks. Machine Learning 20, 3 (1995), 273--297. https://doi.org/10.1007/BF00994018Google ScholarGoogle ScholarCross RefCross Ref
  7. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  8. Marius Eriksen. 2012. Effective Scala. http://twitter.github.io/effectivescala.Google ScholarGoogle Scholar
  9. 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 ScholarGoogle ScholarCross RefCross Ref
  10. 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 ScholarGoogle Scholar
  11. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  12. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  13. 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 ScholarGoogle Scholar
  14. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  15. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  16. 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 ScholarGoogle Scholar
  17. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  18. Thomas J. McCabe. 1976. A Complexity Measure. IEEE Trans. Software Eng. 2, 4 (1976), 308--320. https://doi.org/10.1109/TSE.1976.233837Google ScholarGoogle ScholarDigital LibraryDigital Library
  19. 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 ScholarGoogle Scholar
  20. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  21. 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 ScholarGoogle Scholar
  22. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  23. 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 ScholarGoogle ScholarCross RefCross Ref
  24. 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 ScholarGoogle Scholar
  25. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  26. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  27. 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 ScholarGoogle ScholarDigital LibraryDigital Library
  28. 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 ScholarGoogle Scholar
  29. 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 ScholarGoogle ScholarCross RefCross Ref

Index Terms

  1. Writing Tests for This Higher-Order Function First: Automatically Identifying Future Callings to Assist Testers

        Recommendations

        Comments

        Login options

        Check if you have access through your login credentials or your institution to get full access on this article.

        Sign in
        • Published in

          cover image ACM Other conferences
          Internetware '19: Proceedings of the 11th Asia-Pacific Symposium on Internetware
          October 2019
          179 pages
          ISBN:9781450377010
          DOI:10.1145/3361242

          Copyright © 2019 ACM

          Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

          Publisher

          Association for Computing Machinery

          New York, NY, United States

          Publication History

          • Published: 28 October 2019

          Permissions

          Request permissions about this article.

          Request Permissions

          Check for updates

          Qualifiers

          • research-article
          • Research
          • Refereed limited

          Acceptance Rates

          Internetware '19 Paper Acceptance Rate20of35submissions,57%Overall Acceptance Rate55of111submissions,50%

        PDF Format

        View or Download as a PDF file.

        PDF

        eReader

        View online with eReader.

        eReader