MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / test

Function test

examples/io/streams/wpt/resources/testharness.js:563–592  ·  view source on GitHub ↗

* Create a synchronous test * * @param {TestFunction} func - Test function. This is executed * immediately. If it returns without error, the test status is * set to ``PASS``. If it throws an :js:class:`AssertionError`, or * any other exception, the test status is set to ``FA

(func, name, properties)

Source from the content-addressed store, hash-verified

561 * given file and must be invariant between runs.
562 */
563 function test(func, name, properties)
564 {
565 if (tests.promise_setup_called) {
566 tests.status.status = tests.status.ERROR;
567 tests.status.message = '`test` invoked after `promise_setup`';
568 tests.complete();
569 }
570 var test_name = get_test_name(func, name);
571 var test_obj = new Test(test_name, properties);
572 var value = test_obj.step(func, test_obj, test_obj);
573
574 if (value !== undefined) {
575 var msg = 'Test named "' + test_name +
576 '" passed a function to `test` that returned a value.';
577
578 try {
579 if (value && typeof value.then === 'function') {
580 msg += ' Consider using `promise_test` instead when ' +
581 'using Promises or async/await.';
582 }
583 } catch (err) {}
584
585 tests.status.status = tests.status.ERROR;
586 tests.status.message = msg;
587 }
588
589 if (test_obj.phase === test_obj.phases.STARTED) {
590 test_obj.done();
591 }
592 }
593
594 /**
595 * Create an asynchronous test

Calls 4

get_test_nameFunction · 0.85
completeMethod · 0.65
stepMethod · 0.45
doneMethod · 0.45

Tested by

no test coverage detected