Skip to content

Commit

Permalink
Replace assert with Test.assert.
Browse files Browse the repository at this point in the history
  • Loading branch information
ccd0 committed Jul 26, 2019
1 parent 51a6893 commit 375c717
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
4 changes: 4 additions & 0 deletions src/General/Test.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 4 additions & 1 deletion src/Linkification/Linkify.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 0 additions & 4 deletions tools/template.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(/\.[^.]+$/, '');
Expand Down

0 comments on commit 375c717

Please sign in to comment.