test-utils

primitive assert-methods for unit-testing

当前为 2016-08-30 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.gf.qytechs.cn/scripts/22762/144806/test-utils.js

// ==UserScript==
// @name            test-utils
// @name:de         test-utils
// @namespace       dannysaurus.camamba
// @version         0.1
// @license         MIT License
// @description     primitive assert-methods for unit-testing
// @description:de  primitive assert-methods for unit-testing
// ==/UserScript==
var LIB = LIB || {};
/**
 * @type {{assertTrue}}
 */
LIB.testUtils = (function() {
    'use strict';
    return {
        /**
         * Throws an error if assertion fails
         * @param {boolean} condition - condition to be checked</br><code>true</code> has the assertion succeed </br>false has the assertion fail (and throws an Error)
         * @param {string} [message] - debug-message to display if the assertion fails
         */
        assertTrue: function(condition, message) {
            message = message || "Assertion failed";
            if (!condition) {
                throw new Error(message);
            }
        }
    };
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址