test-utils

primitive assert-methods for unit-testing

目前為 2016-08-30 提交的版本,檢視 最新版本

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/22762/144806/test-utils.js

  1. // ==UserScript==
  2. // @name test-utils
  3. // @name:de test-utils
  4. // @namespace dannysaurus.camamba
  5. // @version 0.1
  6. // @license MIT License
  7. // @description primitive assert-methods for unit-testing
  8. // @description:de primitive assert-methods for unit-testing
  9. // ==/UserScript==
  10. var LIB = LIB || {};
  11. /**
  12. * @type {{assertTrue}}
  13. */
  14. LIB.testUtils = (function() {
  15. 'use strict';
  16. return {
  17. /**
  18. * Throws an error if assertion fails
  19. * @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)
  20. * @param {string} [message] - debug-message to display if the assertion fails
  21. */
  22. assertTrue: function(condition, message) {
  23. message = message || "Assertion failed";
  24. if (!condition) {
  25. throw new Error(message);
  26. }
  27. }
  28. };
  29. })();

QingJ © 2025

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