Type test scripts for TypeScript testing

被引:11
作者
Méller A. [1 ]
Kristensen E.K. [1 ]
机构
[1] Department of Computer Science, Aarhus University
基金
欧盟地平线“2020”;
关键词
Feedback-directed random testing; !text type='Java']Java[!/text]Script; Types;
D O I
10.1145/3133914
中图分类号
学科分类号
摘要
TypeScript applications often use untyped JavaScript libraries. To support static type checking of such applications, the typed APIs of the libraries are expressed as separate declaration files. This raises the challenge of checking that the declaration files are correct with respect to the library implementations. Previous work has shown that mismatches are frequent and cause TypeScript’s type checker to misguide the programmers by rejecting correct applications and accepting incorrect ones. This paper shows how feedback-directed random testing, which is an automated testing technique that has mostly been used for testing Java libraries, can be adapted to effectively detect such type mismatches. Given a JavaScript library with a TypeScript declaration file, our tool TStest generates a type test script, which is an application that interacts with the library and tests that it behaves according to the type declarations. Compared to alternative solutions that involve static analysis, this approach finds significantly more mismatches in a large collection of real-world JavaScript libraries with TypeScript declaration files, and with fewer false positives. It also has the advantage that reported mismatches are easily reproducible with concrete executions, which aids diagnosis and debugging. © 2017 Copyright held by the owner/author(s).
引用
收藏
相关论文
共 28 条
[1]  
Artzi S., Dolby J., Jensen S.H., Muller A., Tip F., A framework for automated testing of JavaScript web applications, Proceedings of The 33rd International Conference on Software Engineering, ICSE 2011, pp. 571-580, (2011)
[2]  
Bierman G.M., Abadi M., Torgersen M., Understanding typescript, ECOOP 2014 - Object-Oriented Programming - 28th European Conference, Uppsala, Sweden, July 28 - August 1, 2014. Proceedings (Lecture Notes in Computer Science), 8586, pp. 257-281, (2014)
[3]  
Claessen K., Hughes J., QuickCheck: A lightweight tool for random testing of haskell programs, Proceedings of The 5th ACM SIGPLAN International Conference on Functional Programming (ICFP’00), pp. 268-279, (2000)
[4]  
Dijkstra E.W., Notes on Structured Programming, (1970)
[5]  
Feldthaus A., Muller A., Checking correctness of TypeScript interfaces for JavaScript libraries, Proceedings of The 2014 ACM International Conference on Object Oriented Programming Systems Languages & Applications, OOPSLA 2014, Part of SPLASH 2014, pp. 1-16, (2014)
[6]  
Fraser G., Arcuri A., Automated test generation for Java generics, Software Quality. Model-Based Approaches for Advanced Software and Systems Engineering - 6th International Conference, SWQD 2014, 166, pp. 185-198, (2014)
[7]  
Godefroid P., Klarlund N., Sen K., DART: Directed automated random testing, Proceedings of The ACM SIGPLAN 2005 Conference on Programming Language Design and Implementation, pp. 213-223, (2005)
[8]  
Heidegger P., Thiemann P., Contract-driven testing of JavaScript code, Objects, Models, Components, Patterns, 48th International Conference, TOOLS 2010, Málaga, Spain, June 28 - July 2, 2010. Proceedings (Lecture Notes in Computer Science), 6141, pp. 154-172, (2010)
[9]  
Jensen S.H., Muller A., Thiemann P., Type analysis for JavaScript, Static Analysis, 16th International Symposium, SAS 2009, 5673, pp. 238-255, (2009)
[10]  
Keil M., Thiemann P., Blame assignment for higher-order contracts with intersection and union, Proceedings of The 20th ACM SIGPLAN International Conference on Functional Programming, ICFP 2015, pp. 375-386, (2015)