var assert = require('assert');
var stringify = require('../lib/stringify.js');

describe('lib/stringify.js', function(){
    describe('#stringify(obj, opts)', function(){
        
        describe('primitives', function(){
            var tests = [
                {type: 'null',      val: null,      output: 'null'},
                {type: 'undefined', val: undefined, output: 'undefined'},
                {type: 'string',    val: 'foo',     output: '\'foo\''},
                {type: 'number',    val: 0,         output: '0'},
                {type: 'number',    val: 3.14,      output: '3.14'},
                {type: 'boolean',   val: true,      output: 'true'},
                {type: 'boolean',   val: false,     output: 'false'},
                {type: 'RegExp',    val: /'/g,      output: '/\'/g'}
            ];
            tests.forEach(function(test) {
                it(`Correctly stringifies type ${test.type} (${test.val})`, function(){
                    assert.equal(test.output, stringify(test.val));
                });
            });
        });

        describe('Arrays', function(){
            var orig;
            var expected;
            it('Correctly stringifies simple arrays', function(){
                assert.equal('[ 1, \'foo\', null ]', stringify([ 1, 'foo', null ]));
            });
            
            it('Breaks long arrays onto multiple lines', function(){
                orig = [
                    'What a long string this is!  Especially if it keeps going...',
                    1234567890,
                    /^"[a-zA-Z_][a-zA-Z_0-9]*"$/
                ];
                expected = '[' +
                    `\n\t'What a long string this is!  Especially if it keeps going...',`+
                    `\n\t1234567890,`+
                    `\n\t/^"[a-zA-Z_][a-zA-Z_0-9]*"$/`+
                '\n]';
                assert.equal(stringify(orig), expected);
            });
        });
    });
});
@@ -74,16 +74,256 @@
 .js');%0A%0A
+%0Aconst regexEqual = function(x, y) %7B%0A    return (x instanceof RegExp) && (y instanceof RegExp) && %0A        (x.source === y.source) && (x.global === y.global) && %0A        (x.ignoreCase === y.ignoreCase) && (x.multiline === y.multiline);%0A%7D;%0A%0A
 describe
@@ -535,22 +535,24 @@
 l,      
-output
+expected
 : 'null'
@@ -606,22 +606,24 @@
 efined, 
-output
+expected
 : 'undef
@@ -682,22 +682,24 @@
 o',     
-output
+expected
 : '%5C'foo
@@ -756,22 +756,24 @@
         
-output
+expected
 : '0'%7D,%0A
@@ -824,22 +824,24 @@
 4,      
-output
+expected
 : '3.14'
@@ -895,22 +895,24 @@
 e,      
-output
+expected
 : 'true'
@@ -970,92 +970,24 @@
     
-output: 'false'%7D,%0A                %7Btype: 'RegExp',    val: /'/g,      output: '/%5C'/g
+expected: 'false
 '%7D%0A 
@@ -1039,24 +1039,74 @@
 ion(test) %7B%0A
+                let output = stringify(test.val);%0A
             
@@ -1223,55 +1223,1689 @@
 est.
-output, stringify(test.val));%0A                %7D
+expected, output);%0A                %7D);%0A                it(%60Stringified $%7Btest.type%7D $%7Btest.val%7D evals to the original input%60, function()%7B%0A                    assert.equal(test.val, eval(output));%0A                %7D);%0A            %7D);%0A        %7D);%0A%0A        describe('boxed primitives', function()%7B%0A            var tests = %5B%0A                %7Btype: 'String',    val: new String('foo'),  expected: '%5C'foo%5C''%7D,%0A                %7Btype: 'Number',    val: new Number(0),      expected: '0'%7D,%0A                %7Btype: 'Number',    val: new Number(3.14),   expected: '3.14'%7D,%0A                %7Btype: 'Boolean',   val: new Boolean(true),  expected: 'true'%7D,%0A                %7Btype: 'Boolean',   val: new Boolean(false), expected: 'false'%7D%0A            %5D;%0A            tests.forEach(function(test) %7B%0A                let output = stringify(test.val);%0A                it(%60Correctly stringifies wrapper $%7Btest.type%7D ($%7Btest.val%7D)%60, function()%7B%0A                    assert.equal(test.expected, output);%0A                %7D);%0A                it(%60Stringified $%7Btest.type%7D $%7Btest.val%7D evals to the original primitive%60, function()%7B%0A                    assert.equal(test.val.valueOf(), eval(output).valueOf());%0A                %7D);%0A            %7D);%0A        %7D);%0A%0A        describe('Regular Expressions', function()%7B%0A            let orig = /'/g;%0A            let expected = '/%5C'/g'%0A            let output = stringify(orig);%0A%0A            it(%60Correctly stringifies RegExp ($%7Borig%7D)%60, function()%7B%0A                assert.equal(expected, output);%0A            %7D);%0A            it(%60Stringified RegExp $%7Borig%7D evals to the original Regular Expression%60, function()%7B%0A                assert.equal(true, regexEqual(orig, eval(output))
 );%0A 

Add more stringify() tests