Permalink
Browse files

L-Unit for Lasso 8.x

  • Loading branch information...
Ke- committed Apr 26, 2015
1 parent efe3a3d commit a0efefd4a54ff279249b27fec1aa69563b83be44
Showing with 11,708 additions and 0 deletions.
  1. +1,962 −0 __classes/assertions.ctyp
  2. +369 −0 __classes/classAnalyser.ctyp
  3. +4 −0 __classes/controller.ctyp
  4. +9 −0 __classes/debug/README.md
  5. +994 −0 __classes/debug/chili-L.js
  6. +456 −0 __classes/debug/debug.css
  7. +187 −0 __classes/debug/debug.js
  8. +1,141 −0 __classes/debug/debug.type.lasso
  9. +2 −0 __classes/revolver/README.md
  10. +17 −0 __classes/revolver/example.lasso
  11. +5 −0 __classes/revolver/revolver.ctyp
  12. +584 −0 __classes/testCase.ctyp
  13. +5 −0 __classes/testMetrics.ctyp
  14. +784 −0 __classes/testSuite.ctyp
  15. +1 −0 __functions/core/core.ctag
  16. +47 −0 __resources/changes.txt
  17. +5 −0 __resources/errors.txt
  18. +592 −0 _css/main.css
  19. +54 −0 _html/home.htm
  20. +44 −0 _html/metrics.htm
  21. +23 −0 _html/metricsTable.htm
  22. +19 −0 _html/suite.htm
  23. +33 −0 _html/suiteEditor.htm
  24. +15 −0 _html/suiteList.htm
  25. +35 −0 _html/testCase.htm
  26. BIN _img/L-Debug-Example.png
  27. BIN _img/L-Debug.jpg
  28. BIN _img/L-Revolver-Girl.png
  29. BIN _img/L-Revolver.jpg
  30. BIN _img/L-Unit_logo.png
  31. BIN _img/body_bg.png
  32. BIN _img/body_ftr.png
  33. BIN _img/btn_lrg.png
  34. BIN _img/btn_med.png
  35. BIN _img/btn_sml.png
  36. BIN _img/btn_sml_del.png
  37. BIN _img/btn_sml_edit.png
  38. BIN _img/btn_sml_run.png
  39. BIN _img/content_bg.png
  40. BIN _img/content_ftr.png
  41. BIN _img/content_hdr.png
  42. BIN _img/content_hdrB.png
  43. BIN _img/header_linkA.png
  44. BIN _img/header_linkB.png
  45. BIN _img/host_bg.png
  46. BIN _img/loaderA.gif
  47. BIN _img/loaderB.gif
  48. BIN _img/result_crashed.png
  49. BIN _img/result_failed.png
  50. BIN _img/result_ok.png
  51. BIN _img/result_queued.png
  52. BIN _img/suite_bg.png
  53. BIN _img/testMethod_bg.png
  54. BIN _img/testMethod_ftr.png
  55. BIN _img/testMethod_hdr.png
  56. BIN _img/testMethod_skipped.png
  57. +32 −0 _js/admin.js
  58. +2,113 −0 _js/jquery-plugins.js
  59. +32 −0 _js/jquery.js
  60. +1 −0 appClasses/customTags/customTags.lasso
  61. +1 −0 appClasses/customTags/test_customTags.lasso
  62. +85 −0 appClasses/example_shoppingBasket.ctyp
  63. +1,796 −0 appClasses/lp/lp_client_browser.lasso
  64. +1 −0 appClasses/lp/lp_client_isBot.lasso
  65. +1 −0 appClasses/lp/test_lp_client_browser.lasso
  66. +18 −0 error.lasso
  67. +1 −0 index.lasso
  68. +1 −0 testCases/test_assertions.ctyp
  69. +1 −0 testCases/test_asyncThreads.ctyp
  70. +202 −0 testCases/test_shoppingBasket.ctyp
  71. +13 −0 testCases/test_template.ctyp
  72. +4 −0 testSuites/Async Example.txt
  73. +4 −0 testSuites/Custom Tags Example.txt
  74. +3 −0 testSuites/Custom Type Example.txt
  75. +4 −0 testSuites/L-Debug.txt
  76. +4 −0 testSuites/L-Unit - Internal Tests.txt
  77. +4 −0 testSuites/LP Client Tags.txt
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -0,0 +1,369 @@
<?lassoscript
define_type:'classAnalyser';
local:
'sourceCode' = string,
'sourceStats' = map,
'sourceLineCount' = integer,
'methodStats' = array;
//=============================================================================
//
// ->getStats
//
define_tag:'getStats';
return: (self->'sourceStats');
/define_tag;
//=============================================================================
//
// ->getTestClassName
//
define_tag:'testClassName';
return: self->'sourceStats'->find('testClass')->find('className');
/define_tag;
define_tag:'className';
(local('name') := self->'sourceStats'->find('appClass')->find('className'))
? return: #name
| return: self->'sourceStats'->find('testClass')->find('className');
/define_tag;
define_tag:'getTestClassName';
return: (((self->'sourceStats')->find:'testClass')->find:'className');
/define_tag;
//============================================================================
//
// ->reset
//
//............................................................................
define_tag:'reset';
(self->'sourceCode') = string;
(self->'sourceLineCount') = integer;
(self->'methodStats') = array;
/define_tag;
//=============================================================================
//
// ->loadClass
//
define_tag:'loadClass',
-required = 'classFile', -type = 'string';
local(
'names' = map,
'sourceCode' = @self->'sourceCode'
);
! local_defined('clasName')
? local('className') = string;
inline:
-username = unit_filesUser,
-password = unit_filesPswd;
if:!#classFile;
// Missing file
// stay silent for now - let metrics deal with error
// unit_controller->error('->getClass empty - metrics may not be available');
return:map;
else:file_exists(#classFile);
#sourceCode = string(file_read(#classFile));
else;
unit_controller->error('Could not read source file '#classFile' - metrics may not be available');
return:map;
/if;
/inline;
#sourceCode->removeLeading(bom_utf8)
& trim
& replace('\r\n','\r')
& replace('\n', '\r');
#sourceCode = string_replaceRegExp(
#sourceCode,
-find = '\\/\\*[\\s\\S]+?\\*\\/',
-replace = '',
-ignoreCase
);
#names->insert('fileName' = #classFile->split('/')->last);
#names->insert('className' = string_findRegExp(
#sourceCode,
-find = 'define_type[:(]*\\s*\'(\\w+)',
-ignorecase)->last,
);
return: #names;
/define_tag;
//=============================================================================
//
// ->analyzeClass
//
define_tag:'analyzeClass',
-required = 'file', -type = 'string';
local:'classType' = string;
local_defined('forTestClass')
? #classType = 'testClass'
| #classType = 'appClass';
! local_defined('clasName')
? local('className') = string;
if:!(self->'sourceStats');
self->'sourceStats'->insert(
'appClass' = map(
'fileName' = string,
'className' = string,
'lineCount' = integer,
'methodStats' = array
)
);
self->'sourceStats'->insert(
'testClass' = map(
'fileName' = string,
'className' = string,
'lineCount' = integer,
'methodStats' = array
)
);
/if;
self->reset;
self->'sourceStats'->find(#classType)->insertFrom(self->loadClass(#file)->iterator);
#classType == 'testClass'
? self->parseConstructor(-forTestClass)
| self->parseConstructor(-forAppClass);
#classType == 'testClass'
? self->parseMethods(-forTestClass)
| self->parseMethods(-forAppClass);
self->'sourceStats'->find(#classType)->find('methodStats') = (self->'methodStats');
self->'sourceStats'->find(#classType)->find('lineCount') = (self->'sourceLineCount');
/define_tag;
//=============================================================================
//
// ->parseConstructor
//
define_tag:'parseConstructor';
local:
'constructor' = array,
'tagSource' = string,
'methodCount' = integer,
'appSourceLineCount' = integer,
'methodName' = string,
'methodLineCount' = integer;
#constructor = string(
string_findRegExp(
self->'sourceCode',
-find = 'define_type[:(]*\\s*\'\\w+[\\s\\S]+?define_tag;',
-ignorecase
)->last
);
#constructor = self->decomment(#constructor->split('\r'));
#methodLineCount = #constructor->size;
self->'sourceLineCount' += #methodLineCount;
/define_tag;
//=============================================================================
//
// ->parseMethods -forTestClass
//
define_tag:'parseMethods';
local:
'methods' = array,
'methodSource' = string,
'methodName' = string,
'regexpMatch' = string,
'methodStats' = map,
'methodAssertions' = array,
'methodOptParams' = array,
'methodReqParams' = array,
'methodLineCount' = integer;
// we only want to collect the test_ methods
// to count towards method coverage
// which should align to app class methods of the same name
if:local_defined('forTestClass');
#methods = string_findRegExp(
self->'sourceCode',
-find = 'define_tag[:(]*\\s*?\'test_\\w+[\\s\\S]+?/define_tag;',
-ignorecase
);
else;
#methods = string_findRegExp(
self->'sourceCode',
-find = 'define_tag[:(]*\\s*?\'\\w+[\\s\\S]+?/define_tag;',
-ignorecase
);
/if;
iterate: #methods, #methodSource;
#methodStats = map;
#methodAssertions = array;
#methodReqParams = array;
#methodOptParams = array;
#methodSource = self->decomment(#methodSource->split('\r'));
// Extract Assertions
iterate:string_findRegExp(
#methodSource->join('\r'),
-find = '(assert_\\w*)\\s*[\\(:]',
-ignorecase
),#regexpMatch;
! (loop_count % 2)
? #methodAssertions->insert(#regexpMatch);
/iterate;
// Extract Custom Assertions
iterate:string_findRegExp(
#methodSource->join('\r'),
-find = 'storeResult.*?\'name\'\\s*=\\s*\'(\\w+)\'',
-ignorecase
),#regexpMatch;
! (loop_count % 2)
? #methodAssertions->insert('custom_'#regexpMatch);
/iterate;
iterate:string_findRegExp(
#methodSource->join('\r'),
-find = '-required\\s*=\\s*\'(\\w+)\'',
-ignorecase
),#regexpMatch;
! (loop_count % 2)
? #methodReqParams->insert(#regexpMatch);
/iterate;
iterate:string_findRegExp(
#methodSource->join('\r'),
-find = '-optional\\s*=\\s*\'(\\w+)\'',
-ignorecase
),#regexpMatch;
! (loop_count % 2)
? #methodOptParams->insert(#regexpMatch);
/iterate;
#methodName = string_findRegExp(
#methodSource->get(1),
-find = 'define_tag[:(]*\\s*?\'(\\w+)',
-ignorecase
)->last;
debug:#methodName' Extract Stats',-open,-title;
handle_error;debug(error_msg,-error);/handle_error;
handle;debug(-close);/handle;
#methodOptParams->size
? debug:'-optional' = #methodOptParams;
#methodReqParams->size
? debug:'-required' = #methodReqParams;
#methodAssertions->size
? debug:'Assertions' = #methodAssertions;
#methodLineCount = #methodSource->size;
#methodStats = map(
'optional' = #methodOptParams,
'required' = #methodReqParams,
'assertions' = #methodAssertions,
'linecount' = #methodLineCount,
);
self->'sourceLineCount' += #methodLineCount;
self->'methodStats'->insert(#methodName = #methodStats);
/iterate;
/define_tag;
define_tag:'methodNames';
local('names') = array;
iterate:self->'methodStats',local('pair');
#names->insert(#pair->first);
/iterate;
return:#names;
/define_tag;
//============================================================================
//
// ->decomment
//
// removes comments and empty lines
//
//............................................................................
define_tag:'decomment',
-required = 'sourceText', -type = 'array';
loop: -loopfrom=#sourceText->size, -loopto=1, -loopincrement=(-1);
local:'sourceLine' = #sourceText->get(loop_count);
if: (#sourceLine == '')
|| ((string_findregexp:
#sourceLine,
-find='\\S+')->size == 0)
|| (#sourceLine->(beginswith:'#'))
|| (#sourceLine->(beginswith:'//'));
#sourceText->remove(loop_count);
/if;
/loop;
return: #sourceText;
/define_tag;
/define_type;
?>
@@ -0,0 +1,4 @@
<?LassoScript define_type:'controller',-prototype; local( 'var' = '_unit_controller', 'global' = '_unit_testSuites', 'output' = array, 'errors' = array, 'html' = code( 'home' = unit_htmlPath'home.htm', 'suiteList' = unit_htmlPath'suiteList.htm' ) ); define_tag:'onCreate'; // One controller per thread var_defined(self->var) ? return:@var(self->var) | var(self->var) = @self; // Determine current mode protect; select: client_getParams('unit_mode'); case:'unitTest'; case:'unitTagTest'; // Initialise Tag Test case:'unitThreads'; // case; // suiteManager self->output(unit_testSuite); /select; /protect; unit_isAjax ? return: self->content | return: process(self->html->home); /define_tag; define_tag:'error',-optional='error'; local('error') ? self->'errors'->insert(local('error')); /define_tag; define_tag:'output',-optional='content'; self->'output'->insert(@#content); /define_tag; define_tag:'content'; local('content') = string; iterate:self->'output',local('output'); #content += #output->invoke; /iterate; return:@#content; /define_tag; define_tag:'suiteList'; return:process(self->html->suiteList); /define_tag; define_tag:'suiteFiles'; local('suiteFiles') = array; inline: -username = unit_filesUser, -password = unit_filesPswd; iterate:file_listDirectory(unit_suitesPath),local('fileName'); ! string(#fileName)->beginsWith('.') ? #suiteFiles->insert(#filename); /iterate; /inline; return:#suiteFiles; /define_tag; /* Global TestSuite Controls
|___________________________________________________________________*/ define_tag:'global'; // Global for running testSuites ! global(self->'global')->isA('map') ? global(self->'global') = map; return:@global(self->'global'); /define_tag; define_tag:'start', -required = 'testSuite',-type='testSuite'; debug:'Controller > Start',-open,-title;
handle_error;debug(error_msg,-error);/handle_error;
handle;debug(-close);/handle; debug:#testSuite->suiteName; self->global->insert(#testSuite->suiteName=@#testSuite); /define_tag; define_tag:'reset', -optional = 'suiteName'; if:local('suiteName'); protect;self->get(#suiteName)->abort;/protect; self->remove(#suiteName); else; iterate:self->global->keys,local('suiteName'); protect;self->get(#suiteName)->abort;/protect; self->remove(#suiteName); /iterate; /if; /define_tag; define_tag:'get', -required = 'suiteName',-type='string'; return:@self->global->find(#suiteName); /define_tag; define_tag:'remove', -required = 'suiteName',-type='string'; return:@self->global->remove(#suiteName); /define_tag; define_tag:'exists', -required = 'suiteName',-type='string'; return:self->global >> #suiteName; /define_tag; define_tag:'isRunning', -required = 'suiteName',-type='string'; self->global >> #suiteName ? return:@self->global->find(#suiteName)->isRunning | return:false; /define_tag;/define_type; ?>
@@ -0,0 +1,9 @@
l-debug
=======
This is the Lasso 8.6 branch of L-Debug.
Documentation online here: http://goo.gl/GGbV9O
Please note this version is no longer supported — pull requests accepted.
The Lasso 9 version is available here: https://github.com/zeroloop/l-debug
Oops, something went wrong.

0 comments on commit a0efefd

Please sign in to comment.