test driven synthesis
play

Test-Driven Synthesis Daniel Perelman 1 Sumit Gulwani 2 Dan Grossman - PowerPoint PPT Presentation

Test-Driven Synthesis Daniel Perelman 1 Sumit Gulwani 2 Dan Grossman 1 Peter Provost 3 1 University of Washington 2 Microsoft Research 3 Microsoft Corporation June 11, 2014 TDD example 1 Test cases: Program: wrap(string s, int len) { // do


  1. Test-Driven Synthesis Daniel Perelman 1 Sumit Gulwani 2 Dan Grossman 1 Peter Provost 3 1 University of Washington 2 Microsoft Research 3 Microsoft Corporation June 11, 2014

  2. TDD example 1 Test cases: Program: wrap(string s, int len) { // do nothing throw new NotImplementedException(); } 1 http://blog.8thlight.com/uncle-bob/2013/05/27/ TheTransformationPriorityPremise.html 2 / 49

  3. TDD example 1 Test cases: 1. wrap("word", 5) Program: == "word" wrap(string s, int len) { // return constant "word" return "word"; } 1 http://blog.8thlight.com/uncle-bob/2013/05/27/ TheTransformationPriorityPremise.html 3 / 49

  4. TDD example 1 Test cases: 1. wrap("word", 5) Program: == "word" wrap(string s, int len) { 2. wrap("foobar", 6) // return input string == "foobar" return s; } 1 http://blog.8thlight.com/uncle-bob/2013/05/27/ TheTransformationPriorityPremise.html 4 / 49

  5. TDD example 1 Test cases: 1. wrap("word", 5) Program: == "word" wrap(string s, int len) { 2. wrap("foobar", 6) // return input if short == "foobar" if(s.Len ≤ len) return s; 3. wrap("LongWord", 4) else == "Long \ nWord" return "Long \ nWord"; } 1 http://blog.8thlight.com/uncle-bob/2013/05/27/ TheTransformationPriorityPremise.html 5 / 49

  6. TDD example 1 Test cases: 1. wrap("word", 5) Program: == "word" wrap(string s, int len) { 2. wrap("foobar", 6) // split string at len == "foobar" if(s.Len ≤ len) return s; 3. wrap("LongWord", 4) else == "Long \ nWord" return s[0:len] + 4. wrap("LongerWord", 6) " \ n" + s[len:]; == "Longer \ nWord" } 1 http://blog.8thlight.com/uncle-bob/2013/05/27/ TheTransformationPriorityPremise.html 6 / 49

  7. TDD example 1 Test cases: 1. wrap("word", 5) Program: == "word" wrap(string s, int len) { 2. wrap("foobar", 6) // wrap word to length len == "foobar" if(s.Len ≤ len) return s; 3. wrap("LongWord", 4) else == "Long \ nWord" return s[0:len] + 4. wrap("LongerWord", 6) " \ n" + wrap(s[len:], len); == "Longer \ nWord" } 5. wrap("LongerWord", 2) == "Lo \ nng \ ner \ nWo \ nrd" 1 http://blog.8thlight.com/uncle-bob/2013/05/27/ TheTransformationPriorityPremise.html 7 / 49

  8. Google’s Real TDD 2 2 http://googletesting.blogspot.com/2014/04/ the-real-test-driven-development.html 8 / 49

  9. Google’s Real TDD 2 (April Fools’ Day joke) 2 http://googletesting.blogspot.com/2014/04/ the-real-test-driven-development.html 9 / 49

  10. Example domain: string transformations “Spreadsheet Data Manipulation using Examples, CACM 2012, Sumit Gulwani, William Harris, Rishabh Singh” ⇓ “Spreadsheet Data Manipulation using Examples \ n Gulwani, S.; Harris, W.; Singh, R. \ n Communications of the ACM, 2012” 10 / 49

  11. Example domain: table transformations Qual 1 Qual 2 Qual 3 Andrew 01.02.2003 27.06.2008 06.04.2007 Ben 31.08.2001 05.07.2004 Carl 18.04.2003 09.12.2009 ⇓ Andrew Qual 1 01.02.2003 Andrew Qual 2 27.06.2008 Andrew Qual 3 06.04.2007 Ben Qual 1 31.08.2001 Ben Qual 3 05.07.2004 Carl Qual 2 18.04.2003 Carl Qual 3 09.12.2009 11 / 49

  12. Example domain: XML transformations <doc> <doc> <p>1</p> <p>1</p> <p class= ✬ a ✬ >2</p> <p class= ✬ a ✬ >2</p> <p>3</p> <p class= ✬ a ✬ >3</p> ⇒ <p>4</p> <p class= ✬ a ✬ >4</p> <p class= ✬ b ✬ >5</p> <p class= ✬ b ✬ >5</p> <p>6</p> <p class= ✬ b ✬ >6</p> <p class= ✬ c ✬ >7</p> <p class= ✬ c ✬ >7</p> </doc> </doc> 12 / 49

  13. Workflow domain expert user generate test cases DSL new test (library+grammar) case synthesize program program P yes no output program done? 13 / 49

  14. Workflow domain expert user generate test cases DSL new test (library+grammar) case synthesize program program P yes no output program done? 14 / 49

  15. Workflow domain expert user generate test cases DSL new test sequence (library+grammar) case sythesize change program P yes no output program done? 15 / 49

  16. Contrast with genetic programming domain expert user generate DSL fitness new test (library+grammar) function f case sythesize change program P yes no output program f ( P ) ≥ α 16 / 49

  17. Workflow domain expert user generate test cases DSL new test sequence (library+grammar) case sythesize change program P yes no output program done? 17 / 49

  18. Workflow domain expert user generate test cases DSL new test sequence (library+grammar) case sythesize change program P yes no output program done? 18 / 49

  19. Modifying program ◮ Replace single subexpression on new test case’s path ◮ Where to modify program ◮ What to replace with 19 / 49

  20. Where to modify Test cases: 1. wrap("word", 5) Program: == "word" wrap(string s, int len) { 2. wrap("foobar", 6) // split string at len if(s.Len ≤ len) == "foobar" return s; 3. wrap("LongWord", 4) else == "Long \ nWord" return s[0:len] + 4. wrap("LongerWord", 6) " \ n" + s[len:]; == "Longer \ nWord" } 5. wrap("LongerWord", 2) == "Lo \ nng \ ner \ nWo \ nrd" 20 / 49

  21. Where to modify Test cases: 1. wrap("word", 5) Program: == "word" wrap(string s, int len) { 2. wrap("foobar", 6) // split string at len if(s.Len ≤ len) == "foobar" return s; 3. wrap("LongWord", 4) else == "Long \ nWord" return s[0:len] + 4. wrap("LongerWord", 6) " \ n" + s[len:]; == "Longer \ nWord" } 5. wrap("LongerWord", 2) == "Lo \ nng \ ner \ nWo \ nrd" 21 / 49

  22. Where to modify Test cases: 1. wrap("word", 5) Program: == "word" wrap(string s, int len) { 2. wrap("foobar", 6) // split string at len if(s.Len ≤ len) == "foobar" return s; 3. wrap("LongWord", 4) else == "Long \ nWord" return s[0:len] + 4. wrap("LongerWord", 6) " \ n" + s[len:]; == "Longer \ nWord" } 5. wrap("LongerWord", 2) == "Lo \ nng \ ner \ nWo \ nrd" 22 / 49

  23. Where to modify Test cases: 1. wrap("word", 5) Program: == "word" wrap(string s, int len) { 2. wrap("foobar", 6) // split string at len if(s.Len ≤ len) == "foobar" return s; 3. wrap("LongWord", 4) else == "Long \ nWord" return s[0:len] + 4. wrap("LongerWord", 6) " \ n" + s[len:]; == "Longer \ nWord" } 5. wrap("LongerWord", 2) == "Lo \ nng \ ner \ nWo \ nrd" 23 / 49

  24. Where to modify Test cases: 1. wrap("word", 5) Program: == "word" wrap(string s, int len) { 2. wrap("foobar", 6) // split string at len if(s.Len ≤ len) == "foobar" return s; 3. wrap("LongWord", 4) else == "Long \ nWord" return s[0:len] + 4. wrap("LongerWord", 6) " \ n" + s[len:]; == "Longer \ nWord" } 5. wrap("LongerWord", 2) == "Lo \ nng \ ner \ nWo \ nrd" 24 / 49

  25. Where to modify Test cases: 1. wrap("word", 5) Program: == "word" wrap(string s, int len) { 2. wrap("foobar", 6) // split string at len if(s.Len ≤ len) == "foobar" return s; 3. wrap("LongWord", 4) else == "Long \ nWord" return s[0:len] + 4. wrap("LongerWord", 6) " \ n" + s[len:]; == "Longer \ nWord" } 5. wrap("LongerWord", 2) == "Lo \ nng \ ner \ nWo \ nrd" 25 / 49

  26. Where to modify Test cases: 1. wrap("word", 5) Program: == "word" wrap(string s, int len) { 2. wrap("foobar", 6) // split string at len if(s.Len ≤ len) == "foobar" return s; 3. wrap("LongWord", 4) else == "Long \ nWord" return s[0:len] + 4. wrap("LongerWord", 6) " \ n" + s[len:]; == "Longer \ nWord" } 5. wrap("LongerWord", 2) == "Lo \ nng \ ner \ nWo \ nrd" 26 / 49

  27. Where to modify Test cases: 1. wrap("word", 5) Program: == "word" wrap(string s, int len) { 2. wrap("foobar", 6) // split string at len if(s.Len ≤ len) == "foobar" return s; 3. wrap("LongWord", 4) else == "Long \ nWord" return s[0:len] + 4. wrap("LongerWord", 6) " \ n" + s[len:]; == "Longer \ nWord" } 5. wrap("LongerWord", 2) == "Lo \ nng \ ner \ nWo \ nrd" 27 / 49

  28. Where to modify Test cases: 1. wrap("word", 5) Program: == "word" wrap(string s, int len) { 2. wrap("foobar", 6) // split string at len if(s.Len ≤ len) == "foobar" return s; 3. wrap("LongWord", 4) else == "Long \ nWord" return s[0:len] + 4. wrap("LongerWord", 6) " \ n" + s[len:]; == "Longer \ nWord" } 5. wrap("LongerWord", 2) == "Lo \ nng \ ner \ nWo \ nrd" 28 / 49

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend