Source code

Revision control

Copy as Markdown

Other Tools

<!DOCTYPE HTML>
<html lang="en">
<meta charset="utf-8">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/resources/test/tests/unit/helpers.js"></script>
<title>assert_implements_optional unittests</title>
<script>
'use strict';
test(() => {
// All values in JS that are not falsy are truthy, so we just check some
// common cases here.
assert_implements_optional(true, 'true is a truthy value');
assert_implements_optional(5, 'positive integeter is a truthy value');
assert_implements_optional(-5, 'negative integeter is a truthy value');
assert_implements_optional('foo', 'non-empty string is a truthy value');
}, 'truthy values');
test_failure(() => {
assert_implements_optional(false);
}, 'false is a falsy value');
test_failure(() => {
assert_implements_optional(0);
}, '0 is a falsy value');
test_failure(() => {
assert_implements_optional('');
}, 'empty string is a falsy value');
test_failure(() => {
assert_implements_optional(null);
}, 'null is a falsy value');
test_failure(() => {
assert_implements_optional(undefined);
}, 'undefined is a falsy value');
test_failure(() => {
assert_implements_optional(NaN);
}, 'NaN is a falsy value');
</script>