Test-driven language development
Upcoming SlideShare
Loading in...5
×
 

Test-driven language development

on

  • 371 views

 

Statistics

Views

Total Views
371
Views on SlideShare
371
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Apple Keynote

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • \n
  • Language workbenches combine interactive definition and use of DSLs\n
  • Scenario: scoping rules!\n
  • Scenario: scoping rules!\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • not recording intentions, not avoiding regressions\n
  • \n
  • \n
  • \n
  • Other variations: nested functions, closures, methods, inheritance\n
  • Other variations: nested functions, closures, methods, inheritance\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Module system\n GUI Test Runner\n Avoids boilerplate\n Testing conditions for syntax, semantics, IDE\n
  • \n
  • \n
  • Generic language and infrastructure\nspecialized with embedding\n
  • Generic language and infrastructure\nspecialized with embedding\n- module system\n- parametrization\n- general format for specifying tests\n- and conditions\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Test will use parser and compare to expectation\n
  • Test will use parser and compare to expectation\n
  • Test will use parser and compare to expectation\n
  • Test will simulate reference resolve and compare to expectation\n
  • Test will simulate reference resolve and compare to expectation\n
  • Test will simulate reference resolve and compare to expectation\n
  • Test will simulate reference resolve and compare to expectation\n
  • Test will simulate reference resolve and compare to expectation\n
  • \n
  • \n
  • Next:\n\n
  • Next:\n\n
  • \n
  • 1. Parse testing language\n 2. Determine tested language\n 3. Parse tested language\n(might be syntax incorrect!)\n
  • 1. Parse testing language\n 2. Determine tested language\n 3. Parse tested language\n(might be syntax incorrect!)\n
  • 1. Parse testing language\n 2. Determine tested language\n 3. Parse tested language\n(might be syntax incorrect!)\n
  • 1. Parse testing language\n 2. Determine tested language\n 3. Parse tested language\n(might be syntax incorrect!)\n
  • 1. Parse testing language\n 2. Determine tested language\n 3. Parse tested language\n(might be syntax incorrect!)\n
  • 1. Parse testing language\n 2. Determine tested language\n 3. Parse tested language\n(might be syntax incorrect!)\n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • expressiveness + tool support\n
  • \n
  • does not \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Oracle: baseline compiler, specification, execution\n\n
  • \n

Test-driven language development Test-driven language development Presentation Transcript

  • Test-DrivenLanguage DevelopmentLennart Kats Delft University of TechnologyRob Vermaas LogicBloxEelco Visser Delft University of Technology
  • Language Workbenches
  • Testing“DOES THE TYPE CHECKER CATCH THIS?”
  • Testing“DOES THIS HYPERLINK POINT TO THE RIGHT PLACE?”
  • SyntaxSemantics IDE
  • parsing abstract syntax syntax error marking Syntax Semantics IDEtype checking errors/warningscompilation reference resolvinginterpretation content completionexecution refactoring views
  • How to testlanguage services?
  • IMPLEMENTFEATURE, TRY WITH DOESN’T WORK EXAMPLE DISCARD CLOSE ENOUGH. EXAMPLE
  • How can wesystematically testlanguage definitions?
  • General-Purpose Testing Tools?
  • A Test Inputmodule Examplefunction foo() { bar();}function bar() {}
  • Another Test Inputmodule Examplefunction foo() { foo();}function bar() {}
  • A Negative Test Casemodule Examplefunction foo() { notfoo();}function bar() {}
  • Automated Testing Infrastructure ParserTest Test Compilerinput script IDE
  • Automated Testing Infrastructure Parser Test Test Compiler input script IDE+ simple– language-specific script– limited expressiveness– boilerplate in tests– ...
  • Can we design a general, reusablesolution for language testing?
  • Yes We CanGeneric test specification language + Parametrization
  • Language-ParametricTesting Language (LPTL)module my-testslanguage mobltest Cannot assign an integer to a string [[ module Example module Example <test input> function test() { var s s : String = 1; var : String = 1; }}]] 1 error
  • LPTL Opportunities Expressiveness Tool support
  • LPTL Opportunities (1)Module system +GUI Test Runner
  • LPTL Opportunities (2) IDE support for testspecifications
  • LPTL Opportunities (3)Immediate testevaluation
  • LPTL Opportunities (4)IDE support for test inputs
  • LPTL Opportunities (5) setup [[ module Example imports stuff Reduced function test() { [[...]]boilerplate } ]] test Cannot assign ... [[ var s : String = 1; ]] 1 error
  • LPTL Opportunities (6) 1 error 2 warnings /expected here/ parse fails Wide set oftest conditions complete ... to ... resolve ... to ... refactor ... to ... build ... run ...
  • Testing Syntax (1) test Proper declaration [[ var s : String = "a"; ]] parse test Java-like declaration [[ String s = "a"; ]] parse fails
  • Testing Syntax (2) test Proper declaration [[ var s : String = "a"; ]] parse to VarDecl("s", _) test Precedence [[ 3+1*2 ]] parse to [[ 3 + (1 * 2) ]]
  • Testing Error Markers test Variable declaration [[ var s : String = "a"; ]] 0 errors test Bad variable declaration [[ var s : String = 25; ]] 1 error /wrong type/
  • Testing Referencestest [[ module Example function foo() { bar(); } function bar() { }]] resolve ... to ...
  • Testing Referencestest [[ module Example function foo() { bar(); [[bar]](); } function [[bar]]() { bar() { }]] resolve ... to ... #1 to #2
  • Testing CodeGeneration..?
  • Testing Code Generation..?test [[ function foo() { return 3; }]] build generate-javascript to [[ [[bar]](); function bar() { }]]
  • Testing Code Generation..?test [[ function foo() { return 3; } to [[]] build generate-javascript to [[ var foo = function() { [[bar]](); return 3; }; function bar() {]] }]]
  • Testing Executionsetup [[ application execution function main() : Num { // init [[...]] }]]test Arithmetic [[ return 1 + 1;]] run run-test to 2
  • Implementation Spoofax Testing Language (spoofax.org)
  • Implementation TechniquesLanguage embeddingDynamic instantiation of language services
  • Language Embedding: Syntax module tests language mobl test Java-like declaration [[ String s = "a"; ]] parse fails
  • Language Embedding: Syntax 1 module tests language mobl test Java-like declaration [[ String s = "a"; ]] parse fails
  • Language Embedding: Syntax 1 module tests 2 language mobl test Java-like declaration [[ String s = "a"; ]] parse fails
  • Language Embedding: Syntax 1 module tests 2 language mobl test Java-like declaration [[ 3 ]]String sfails parse = "a";
  • Language Embedding: Semantics & IDE (1) test A function call [[ function foo() { } fo| ]] Content complete
  • Language Embedding: Semantics & IDE (1) test A function call [[ function foo() { Mobl } fo| ]] Content complete
  • Language Embedding: Semantics & IDE (2) test A function call [[ function foo() { Mobl } notfoo(); ]] No condition; error not expected
  • Dynamic Language Service Instantiation Mobl
  • Dynamic Language Service Instantiation Language consists of separate services Services have functional interfaces
  • Reflection+ simple+ no scripting required+ IDE helps avoid errors+ little boilerplate code+ expressiveness
  • WRITE 1 TEST IMPLEMENT FEATURE TESTS FAIL TESTS SUCCEED!
  • ADDITIONAL SLIDES
  • Self-Applicationlanguage Spoofax-Testingtest Testing testing [[[ language mobl test Testing [[ module y ]]]]]
  • Dynamic Language Service Instantiation Test “mobl” input Language Mobl Parser registry language Completion service
  • Related:Automatic Test Generation• Generate tests from grammar• Requires oracle• Complementary to our approach
  • The Spoofax Language Workbench [OOPSLA 2010]• Integrated environment for language definition• Define syntax, semantics, IDE• Based on Eclipse www.spoofax.org