Skip to content

Commit

Permalink
test for continuous but non-overlapping replacements
Browse files Browse the repository at this point in the history
  • Loading branch information
Rich-Harris committed Dec 23, 2015
1 parent 0a2e607 commit 0dea7ba
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,22 @@ describe( 'MagicString', function () {
assert.equal( s.toString(), 'abcdefyes' );
});

it( 'should allow contiguous but non-overlapping replacements', function () {
var s = new MagicString( 'abcdefghijkl' );

s.overwrite( 3, 6, 'DEF' );
assert.equal( s.toString(), 'abcDEFghijkl' );

s.overwrite( 6, 9, 'GHI' );
assert.equal( s.toString(), 'abcDEFGHIjkl' );

s.overwrite( 0, 3, 'ABC' );
assert.equal( s.toString(), 'ABCDEFGHIjkl' );

s.overwrite( 9, 12, 'JKL' );
assert.equal( s.toString(), 'ABCDEFGHIJKL' );
});

it( 'should replace characters at the end of the original string', function () {
var s = new MagicString( 'abcdefghijkl' );

Expand Down

0 comments on commit 0dea7ba

Please sign in to comment.