Replace assert with Test.assert.

This commit is contained in:
ccd0 2019-07-25 19:20:53 -07:00
parent 51a6893fdd
commit 375c717dea
3 changed files with 8 additions and 5 deletions

View File

@ -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

View File

@ -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

View File

@ -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(/\.[^.]+$/, '');