promise prop resolution
This commit is contained in:
parent
7639444aa1
commit
6b62681da8
4 changed files with 168 additions and 76 deletions
|
|
@ -1,35 +1,40 @@
|
|||
function test(condition) {
|
||||
var duration = 0;
|
||||
var start = 0;
|
||||
var result = true;
|
||||
var duration = 0
|
||||
var start = 0
|
||||
var result = true
|
||||
test.total++
|
||||
|
||||
if (typeof performance != "undefined") {
|
||||
start = performance.now()
|
||||
}
|
||||
try {
|
||||
if (!condition()) throw new Error()
|
||||
}
|
||||
catch (e) {
|
||||
result = false
|
||||
console.error(e)
|
||||
test.failures.push(condition)
|
||||
}
|
||||
if (typeof performance != "undefined") {
|
||||
duration = performance.now() - start
|
||||
}
|
||||
|
||||
test_obj = {
|
||||
name: "" + test.total,
|
||||
result: result,
|
||||
duration: duration
|
||||
}
|
||||
|
||||
if (typeof window != "undefined") {
|
||||
if (typeof performance != "undefined") {
|
||||
start = performance.now();
|
||||
}
|
||||
try {if (!condition()) throw new Error}
|
||||
catch (e) {result = false;console.error(e);test.failures.push(condition)}
|
||||
if (typeof performance != "undefined") {
|
||||
duration = performance.now() - start;
|
||||
}
|
||||
|
||||
|
||||
test_obj = {
|
||||
name: "" + test.total,
|
||||
result: result,
|
||||
duration: duration
|
||||
}
|
||||
if (!result) {
|
||||
message: "failed: " + condition,
|
||||
window.global_test_results.tests.push(test_obj)
|
||||
}
|
||||
|
||||
window.global_test_results.duration += duration;
|
||||
window.global_test_results.duration += duration
|
||||
if (result) {
|
||||
window.global_test_results.passed++;
|
||||
window.global_test_results.passed++
|
||||
} else {
|
||||
window.global_test_results.failed++;
|
||||
window.global_test_results.failed++
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue