From 375c717dea3ff136d8ebea8b938e9d90bd474c64 Mon Sep 17 00:00:00 2001 From: ccd0 Date: Thu, 25 Jul 2019 19:20:53 -0700 Subject: [PATCH] Replace assert with Test.assert. --- src/General/Test.coffee | 4 ++++ src/Linkification/Linkify.coffee | 5 ++++- tools/template.js | 4 ---- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/General/Test.coffee b/src/General/Test.coffee index a60c14f3ae..acffd01463 100644 --- a/src/General/Test.coffee +++ b/src/General/Test.coffee @@ -18,6 +18,10 @@ Test = Header.menu.addEntry el: a2 + assert: (condition) -> + unless condition() + new Notice 'warning', "Assertion failed: #{condition}", 30 + normalize: (root) -> root2 = root.cloneNode true for el in $$ '.mobile', root2 diff --git a/src/Linkification/Linkify.coffee b/src/Linkification/Linkify.coffee index d1abed37ac..7a82bd1a71 100644 --- a/src/Linkification/Linkify.coffee +++ b/src/Linkification/Linkify.coffee @@ -71,7 +71,10 @@ Linkify = if Linkify.regString.test word links.push Linkify.makeRange node, endNode, index, length - <% if (readJSON('/.tests_enabled')) { %><%= assert('word is links[links.length-1].toString()') %><% } %> + <% if (readJSON('/.tests_enabled')) { %> + Test.assert -> + word is links[links.length-1].toString() + <% } %> break unless test.lastIndex and node is endNode diff --git a/tools/template.js b/tools/template.js index bdc74278db..b75cab4ccf 100644 --- a/tools/template.js +++ b/tools/template.js @@ -171,10 +171,6 @@ tools.html = function(template) { return `\`{innerHTML: ${output}}\``; }; -tools.assert = function(statement) { - return `throw new Error 'Assertion failed: ' + \`${constExpression(statement)}\` unless ${statement}`; -}; - function includesDir(templateName) { var dir = path.dirname(templateName); var subdir = path.basename(templateName).replace(/\.[^.]+$/, '');