Skip to content

Commit

Permalink
Fence: Add test for code fence exponential backtracking
Browse files Browse the repository at this point in the history
  • Loading branch information
ariabuckles committed Aug 31, 2019
1 parent 31ca48a commit acbf1f6
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions __tests__/simple-markdown-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4280,5 +4280,19 @@ describe("simple markdown", function() {
duration = Date.now() - startTime;
assert.ok(duration < 10, "Expected parsing to finish in <10ms, but was " + duration + "ms.");
});

it("should parse long code fences quickly", function() {
var source = '~~~' + Array(1000).join(' ') + '\n' + Array(1000).join(' ') + '\n';
var startTime = Date.now();
var parsed = blockParse(source);
var duration = Date.now() - startTime;
assert.ok(duration < 10, "Expected parsing to finish in <10ms, but was " + duration + "ms.");

var source = '~~~' + Array(2000).join(' ') + '\n' + Array(10000).join(' ') + '\n';
var startTime = Date.now();
var parsed = blockParse(source);
var duration = Date.now() - startTime;
assert.ok(duration < 10, "Expected parsing to finish in <10ms, but was " + duration + "ms.");
});
});
});

0 comments on commit acbf1f6

Please sign in to comment.