(parents, test)
| 109 | // Run test / subtests, recursively. Report results, indicate data files |
| 110 | // which are out of date. |
| 111 | function runTest(parents, test) { |
| 112 | if (!testName || (test.name.indexOf(testName) !== -1 || parents.some(function (p) { return p.indexOf(testName) !== -1; }))) { |
| 113 | var testPath = parents.join(' -> ') + ' -> ' + test.name; |
| 114 | |
| 115 | var evalcode = testCode(test.exec); |
| 116 | |
| 117 | var actual; |
| 118 | if (evalcode) { |
| 119 | var script = ''; |
| 120 | if (/\blacksGlobal\b/.test(evalcode)) { |
| 121 | script += 'this.lacksGlobal = typeof global === "undefined";\n'; |
| 122 | } |
| 123 | if (/\bglobal\b/.test(evalcode)) { |
| 124 | script += 'if (typeof global === "undefined") {\n' + |
| 125 | ' global = this;\n' + |
| 126 | '}\n'; |
| 127 | } |
| 128 | if (/\blacksGlobalThis\b/.test(evalcode)) { |
| 129 | script += 'this.lacksGlobalThis = typeof globalThis === "undefined";\n'; |
| 130 | } |
| 131 | if (/\bglobalThis\b/.test(evalcode)) { |
| 132 | script += 'if (typeof globalThis === "undefined") {\n' + |
| 133 | ' globalThis = this;\n' + |
| 134 | '}\n'; |
| 135 | } |
| 136 | if (/\b__script_executed\b/.test(evalcode)) { |
| 137 | script += 'var __script_executed = {};\n' + |
| 138 | 'global.__script_executed = __script_executed;\n' + |
| 139 | 'if (typeof global !== "undefined") {\n' + |
| 140 | ' global.__script_executed = __script_executed;\n' + |
| 141 | '}\n'; |
| 142 | } |
| 143 | if (/\b__createIterableObject\b/.test(evalcode)) { |
| 144 | script += createIterableHelper; |
| 145 | } |
| 146 | |
| 147 | script += `var testCode = ${JSON.stringify(evalcode)};`; |
| 148 | |
| 149 | if (/\basyncTestPassed\b/.test(evalcode)) { |
| 150 | script += ` |
| 151 | try { |
| 152 | ${asyncTestHelperHead} |
| 153 | eval(testCode); |
| 154 | ${asyncTestHelperTail} |
| 155 | } catch (e) {};`; |
| 156 | } else if (/\bglobal\.test\b/.test(evalcode)) { |
| 157 | script += ` |
| 158 | global.test = function (expression) { |
| 159 | if (expression) { |
| 160 | ${logCommand}("[SUCCESS]"); |
| 161 | } |
| 162 | } |
| 163 | try { |
| 164 | eval(testCode); |
| 165 | } catch (e) {} |
| 166 | `; |
| 167 | } else { |
| 168 | script += ` |
no test coverage detected