Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save jabedhasan21/abdae3737c0d71fc3e8d01abe56cb545 to your computer and use it in GitHub Desktop.
Save jabedhasan21/abdae3737c0d71fc3e8d01abe56cb545 to your computer and use it in GitHub Desktop.

Revisions

  1. @reneviering reneviering revised this gist Jun 11, 2016. 1 changed file with 5 additions and 5 deletions.
    10 changes: 5 additions & 5 deletions template-strings-String.raw.js
    Original file line number Diff line number Diff line change
    @@ -5,14 +5,14 @@ describe('on tagged template strings you can use the `raw` property like so `s.r

    it('the `raw` property accesses the string as it was entered', function() {
    function firstChar(strings) {
    return strings;
    return strings.raw;
    }
    assert.equal(firstChar`\n`, '\\n');
    });

    it('`raw` can access the backslash of a line-break', function() {
    function firstCharEntered(strings) {
    var lineBreak = strings.raw;
    var lineBreak = strings.raw.toString()[0];
    return lineBreak;
    }
    assert.equal(firstCharEntered`\n`, '\\');
    @@ -21,17 +21,17 @@ describe('on tagged template strings you can use the `raw` property like so `s.r
    describe('`String.raw` as a static function', function(){

    it('concats the raw strings', function() {
    var expected = '\n';
    var expected = '\\n';
    assert.equal(String.raw`\n`, expected);
    });

    it('two raw-templates-string-backslashes equal two escaped backslashes', function() {
    const TWO_BACKSLASHES = '\\';
    const TWO_BACKSLASHES = '\\\\';
    assert.equal(String.raw`\\`, TWO_BACKSLASHES);
    });

    it('works on unicodes too', function() {
    var smilie = '\u{1F600}';
    var smilie = '\\u{1F600}';
    var actual = String.raw`\u{1F600}`;
    assert.equal(actual, smilie);
    });
  2. @reneviering reneviering created this gist Jun 11, 2016.
    40 changes: 40 additions & 0 deletions template-strings-String.raw.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    // 4: template strings - String.raw
    // To do: make all tests pass, leave the asserts unchanged!

    describe('on tagged template strings you can use the `raw` property like so `s.raw`', function() {

    it('the `raw` property accesses the string as it was entered', function() {
    function firstChar(strings) {
    return strings;
    }
    assert.equal(firstChar`\n`, '\\n');
    });

    it('`raw` can access the backslash of a line-break', function() {
    function firstCharEntered(strings) {
    var lineBreak = strings.raw;
    return lineBreak;
    }
    assert.equal(firstCharEntered`\n`, '\\');
    });

    describe('`String.raw` as a static function', function(){

    it('concats the raw strings', function() {
    var expected = '\n';
    assert.equal(String.raw`\n`, expected);
    });

    it('two raw-templates-string-backslashes equal two escaped backslashes', function() {
    const TWO_BACKSLASHES = '\\';
    assert.equal(String.raw`\\`, TWO_BACKSLASHES);
    });

    it('works on unicodes too', function() {
    var smilie = '\u{1F600}';
    var actual = String.raw`\u{1F600}`;
    assert.equal(actual, smilie);
    });

    });
    });