"use strict";

function simplePassing() {
  //
  // !!!! this is a new version !!!!
  // this runner below is mocha, with should and assert as assertion libs
  // for any problem, etc. please tweet to @tddbin
  //
  describe('test embedded mocha', function() {
    // doesnt work anymore since we use mocha from the CDN, which we have to do due to
    // browserify failing when bundling mocha :(
    //it('should run jasmine-style tests (using referee)', function() {
    //  var expected = 1;
    //  expect(expected)
    //    .toBe(expected);
    //});
    it('should run should-style tests', function() {
      var expected = 1;
      should(expected).ok;
    });
    it('should run assert-style tests', function() {
      var expected = 1;
      assert.equal(expected, 1);
    });
  });
}

function simpleFailing() {
  describe('test embedded mocha', function() {
    it('should fail', function() {
      expect(1)
        .toBe(2);
    });
  });
}

// Make sure the code block starts with no indentation.
function _replaceTrailingWhitespaces(lines) {
  var firstLineTrailingSpaces = lines[1].match(/^[\s\t]+/);
  if (firstLineTrailingSpaces) {
    lines = lines.map(function(line) {
      return line.replace(firstLineTrailingSpaces, '');
    });
  }
  return lines;
}

function getSourceFrom(func) {
  var lines = func.toString().split('\n');
  lines = _replaceTrailingWhitespaces(lines);
  return lines.slice(1, -1).join('\n');
}

export var simplePassingTestCode = getSourceFrom(simplePassing);
export var simpleFailingTestCode = getSourceFrom(simpleFailing);

@@ -8,24 +8,28 @@
 rict%22;%0A%0A
-function
+export const
  simpleP
@@ -38,20 +38,27 @@
 sing
-() %7B%0A  //%0A  
+TestCode = %5B%0A//',%0A'
 // !
@@ -87,19 +87,20 @@
 ion !!!!
-%0A  
+',%0A'
 // this 
@@ -162,19 +162,20 @@
 ion libs
-%0A  
+',%0A'
 // for a
@@ -218,16 +218,18 @@
 dbin
-%0A  //%0A  
+',%0A'//',%0A'
 desc
@@ -225,32 +225,33 @@
 '//',%0A'describe(
+%5C
 'test embedded m
@@ -246,32 +246,33 @@
 t embedded mocha
+%5C
 ', function() %7B%0A
@@ -266,27 +266,28 @@
 function() %7B
-%0A  
+',%0A'
   // doesnt 
@@ -358,19 +358,20 @@
 o due to
-%0A  
+',%0A'
   // bro
@@ -412,18 +412,20 @@
 a :(
-%0A  
+',%0A'
   //it(
+%5C
 'sho
@@ -467,16 +467,17 @@
 referee)
+%5C
 ', funct
@@ -483,19 +483,20 @@
 tion() %7B
-%0A  
+',%0A'
   //  va
@@ -510,19 +510,20 @@
 ted = 1;
-%0A  
+',%0A'
   //  ex
@@ -536,19 +536,20 @@
 xpected)
-%0A  
+',%0A'
   //    
@@ -568,26 +568,29 @@
 ed);
-%0A  
+',%0A'
   //%7D);
-%0A  
+',%0A'
   it(
+%5C
 'sho
@@ -607,32 +607,33 @@
 ould-style tests
+%5C
 ', function() %7B%0A
@@ -623,35 +623,36 @@
 %5C', function() %7B
-%0A  
+',%0A'
     var expected
@@ -652,27 +652,28 @@
 xpected = 1;
-%0A  
+',%0A'
     should(e
@@ -688,24 +688,27 @@
 .ok;
-%0A  
+',%0A'
   %7D);
-%0A  
+',%0A'
   it(
+%5C
 'sho
@@ -733,16 +733,17 @@
 le tests
+%5C
 ', funct
@@ -745,27 +745,28 @@
 function() %7B
-%0A  
+',%0A'
     var expe
@@ -774,19 +774,20 @@
 ted = 1;
-%0A  
+',%0A'
     asse
@@ -808,32 +808,219 @@
 ted, 1);
-%0A    %7D);%0A  %7D);%0A%7D
+',%0A'  %7D);',%0A'  it(%5C'ES6 class works?%5C', function() %7B',%0A'    assert.equal(new Es6Class().x, 42);',%0A'  %7D);',%0A'%7D);',%0A'',%0A'class Es6Class %7B',%0A'  constructor() %7B',%0A'    this.x = 42;',%0A'  %7D',%0A'%7D'%0A%5D.join('%5Cn');
 %0A%0Afuncti
@@ -1661,73 +1661,8 @@
 %0A%7D%0A%0A
-export var simplePassingTestCode = getSourceFrom(simplePassing);%0A
 expo

Add ES6 example, and to not have it transpiled we make the test code a string.