Warning: Use of undefined constant Symbol - assumed 'Symbol' (this will throw an Error in a future version of PHP) in /mnt/new-ebs/workbench-106550/lib/dojo/util/docscripts/lib/parser2/dojo2.inc on line 215 Warning: Use of undefined constant JavaScriptSymbol - assumed 'JavaScriptSymbol' (this will throw an Error in a future version of PHP) in /mnt/new-ebs/workbench-106550/lib/dojo/util/docscripts/lib/parser2/dojo2.inc on line 215

dojox/testing/DocTest.js

  • Provides:

    • dojox.testing.DocTest
  • Requires:

    • dojo.string in common
  • dojox.testing.DocTest

    • type
      Function
    • summary
      This class executes doctests.
    • description
      DocTests are tests that are defined inside the comment.
      A doctest looks as if it was copied from the shell (which it mostly is).
      A doctest is executed when the following conditions match:
      1) all lines are comments
      2) the line always starts with spaces/tabs followed by "//"
      and at least one space
      3) the line(s) of the test to execute starts with ">>>"
      preceeded by what is described in 2)
      4) the first line after 3) starting without ">>>" is the exptected result.
      preceeded by what is described in 2)
      5) the test sequence is terminated by an empty line, or the next
      test in the following line, or a new line that does not start as described in 2)
      (simple said: is not a comment)
      preceeded by what is described in 2)
      
      I.e. the following is a simple doctest, that will actually also be run
      if you run this class against this file here:
      >>> 1+1 // A simple test case. Terminated by an empty line
      2
      
      >>> 1==2
      false
      >>> "a"+"b" // Also without the empty line before, this is a new test.
      "ab"
      
      >>> var anything = "anything" // Multiple commands for one test.
      >>> "something"==anything
      false
      
      DocTests are great for inline documenting a class or method, they also
      are very helpful in understanding what the class/method actually does.
      They don't make sense everywhere, but sometimes they are really handy.
  • dojox.testing.DocTest.errors

    • type
      Array
  • dojox.testing.DocTest.getTests

    • parameters:
      • moduleName: (typeof String)
    • summary
      Extract the tests from the given module or string.
      examples:
      >>> dojo.isArray(new dojox.testing.DocTest().getTests("dojox.testing.DocTest")) // Use the module name to extract the tests from.
      true
    • type
      Function
  • dojox.testing.DocTest.getTestsFromString

    • parameters:
      • data: (typeof String)
    • type
      Function
  • dojox.testing.DocTest._getTestsFromString

    • parameters:
      • data: (typeof String)
      • insideComments: (typeof Boolean)
        Boolean, if false "data" contains only the pure tests, comments already stripped.
    • summary
      Parse the given string for tests.
    • type
      Function
  • dojox.testing.DocTest.run

    • parameters:
      • moduleName
    • summary
      Run the doctests in the module given.
    • example
      doctest = new dojox.testing.DocTest();
      doctest.run("dojox.testing.DocTest");
      doctest.errors should finally be an empty array.
      // The above is not a doctest, because it just would
      //	execute itself in a never ending loop.
      
      >>> true==true // Test a new line terminating the test.
      true
      
      >>> true==true // Test a new test terminating the test.
      true
      >>> true==true // Test a "not a comment"-line, especially an empty line terminating the test.
      true
    • type
      Function
  • dojox.testing.DocTest._run

    • parameters:
      • tests: (typeof Array)
        Make sure that the types are compared properly. There used to be
        the bug that a return value false was compared to "false" which
        made the test fail. This is fixed and should be verified by the
        following tests.
        >>> false
        false
        
        >>> "false"
        "false"
        
        >>> true
        true
        
        >>> 1
        1
        
        >>> "s"
        "s"
        
        >>> dojo.toJson({one:1})
        "{"one":1}"
    • summary
      Each element in the array contains the test in the first element,
      and the expected result in the second element.
    • type
      Function
  • dojox.testing.DocTest.tests

  • dojox.testing.DocTest._run.tests

    • type
      Make
    • summary
      sure that the types are compared properly. There used to be
      the bug that a return value false was compared to "false" which
      made the test fail. This is fixed and should be verified by the
      following tests.
      >>> false
      false
      
      >>> "false"
      "false"
      
      >>> true
      true
      
      >>> 1
      1
      
      >>> "s"
      "s"
      
      >>> dojo.toJson({one:1})
      "{"one":1}"
  • dojox.testing.DocTest.runTest

    • parameters:
      • commands
      • expected
    • type
      Function
  • dojox.testing

    • type
      Object
  • dojox

    • type
      Object