diff --git a/test/256.test.js b/test/256.test.js index face88b..79a642d 100644 --- a/test/256.test.js +++ b/test/256.test.js @@ -1,4 +1,6 @@ var Color = require('..').Colors; + + console.log(); console.log(); console.log(' System colors'); @@ -11,6 +13,7 @@ for (var i = 0; i < 16; i++) { if (i === 8) process.stdout.write(' '); process.stdout.write(c.valueOf()); } + console.log(); console.log(); console.log(); @@ -58,4 +61,6 @@ console.log(); function wordwrap(i) { i = String(i) return i + new Array(5 - i.length).join(' '); -} \ No newline at end of file +} + +console.log(); diff --git a/test/group.test.js b/test/group.test.js new file mode 100644 index 0000000..90ec092 --- /dev/null +++ b/test/group.test.js @@ -0,0 +1,24 @@ + +var color = require('../safe'); + +console.log() +console.log(" Group Color:") +console.log() +console.log(' =>', color.red.bold('Hello!' + color.yellow.bold('world!') + 'wcj!')) +console.log(' =>', color.red('red') + ' plain ' + color.blue('blue')); +console.log(' =>', color.red('red ' + color.underline.yellow('blue') + ' wcj!')); +console.log(' =>', color.red.magenta_bt.underline('hello')); + +// 背景色 +console.log(' =>', color.magenta_b('hello')); +console.log(' =>', color.magenta_bbt('hello')); +// 文字颜色 +console.log(' =>', color.magenta('hello')); +console.log(' =>', color.magenta_bt('hello')); +// 文字颜色 + 背景色 +console.log(' =>', color.magenta_bt.underline('hello ' + color.blue_bt('wo' + color.yellow_bt.magenta_bbt('r') + 'ld') + ' !!!!')); +console.log(' =>', color.magenta_bt.underline('hello ' + color.blue_bt('wo' + color.yellow_bt.magenta_bbt('r')))); +console.log(' =>', color.magenta_bt.underline('hello ' + color.blue_bt('world') + ' !!!!' + color.yellow('kenny') + ' wong' )); + + +console.log(); diff --git a/test/safe.test.js b/test/safe.test.js index 0e33bed..edc71a7 100644 --- a/test/safe.test.js +++ b/test/safe.test.js @@ -2,44 +2,44 @@ var color = require('../safe'); var _styles = require('../lib/styles-name') var colors = _styles.colors; -var styles = _styles.styles; +// var styles = _styles.styles; -console.log("") -console.log(" Font Bright Color:") -console.log(); +var str = '"\\n Font Bright Color:\\n\\n " + '; colors.forEach(function(key) { - process.stdout.write(" "+ eval('color.'+key+'("'+key+'")') ) + str += 'color.' + key + '("' + key + ' ") +'; }); -console.log(); -colors.forEach(function(key) { - process.stdout.write(" "+ eval('color.'+key+'_bt("'+key+'")') ) + +str += ' "\\n " + '; + +colors.forEach(function (key) { + str += 'color.' + key + '_bt("' + key + ' ") +'; }); +console.log(eval(str.replace(/\+$/, ''))) -console.log("") -console.log("") -console.log(" Background Bright Color:") -console.log("") +str = ' "\\n Background Bright Color:\\n\\n " +'; -colors.forEach(function(key) { - process.stdout.write(" "+ eval('color.'+key+'.'+key+'_b("'+key+' color")') ) +colors.forEach(function (key) { + str += 'color.' + key + '.' + key + '_b("' + key + ' color") +'; }); -console.log(); -colors.forEach(function(key) { - process.stdout.write(" "+ eval('color.'+key+'.'+key+'_bbt("'+key+' color")') ) +str += '"\\n " + '; +colors.forEach(function (key) { + str += 'color.' + key + '.' + key + '_bbt("' + key + ' color") +'; }); -console.log(); + +console.log(eval(str.replace(/\+$/, ''))) +console.log() // 计划实现 -// +// // clr.art('.........\n. Hello .\n' .........\n', { // ".":clr.red.bold('H') -// +// // }) -// +// // color('在以下示例中,@abc{Object.defineProperty} 函数向用户@ab2{定义}的对象添加访问器属性。',{ // "abc":"yellow,blue_bg", // "ab2":"underline,blink,red" -// }) \ No newline at end of file +// }) diff --git a/test/string.test.js b/test/toxic.test.js similarity index 60% rename from test/string.test.js rename to test/toxic.test.js index bfd3907..1a33aa6 100644 --- a/test/string.test.js +++ b/test/toxic.test.js @@ -1,6 +1,5 @@ var toxic = require('../toxic') -console.log("") // console.log(" ಠ_ಠ ") // console.log( "underline.red.bold.yellow_b string".underline.red.bold.yellow_b ); @@ -13,12 +12,12 @@ var styles = _styles.styles; console.log("") -console.log(" styles:") +console.log(" Styles:toxic.test.js") console.log("") styles.forEach(function(key) { - process.stdout.write(" "+key[key]) - // console.log(key[key].red) + process.stdout.write(" "+key[key]) + // console.log(key[key].red) }); console.log("") @@ -27,7 +26,7 @@ console.log(" colors:") console.log("") colors.forEach(function(key) { - process.stdout.write(" "+key[key]) + process.stdout.write(" "+key[key]) }); console.log("") @@ -36,8 +35,8 @@ console.log(" background colors:") console.log("") colors.forEach(function(key) { - // process.stdout.write(" "+key[key+'_b']) - process.stdout.write(" "+eval( '" ' +key+"_b"+ ' ".'+key+"_b")) + // process.stdout.write(" "+key[key+'_b']) + process.stdout.write(" "+eval( '" ' +key+"_b"+ ' ".'+key+"_b")) }); @@ -47,8 +46,8 @@ console.log(" Font Bright Color:") console.log("") colors.forEach(function(key) { - // process.stdout.write(" "+key[key+'_bt']) - process.stdout.write(" "+eval( '" ' +key+"_bt"+ ' ".'+key+"_bt")) + // process.stdout.write(" "+key[key+'_bt']) + process.stdout.write(" "+eval( '" ' +key+"_bt"+ ' ".'+key+"_bt")) }); @@ -57,7 +56,8 @@ console.log("") console.log(" Background Bright Color:") console.log("") -colors.forEach(function(key) { - // process.stdout.write(" "+key[key+'_bbt']) - process.stdout.write(" "+eval( '" ' +key+"_bbt"+ ' ".'+key+"_bbt")) +colors.forEach(function (key) { + process.stdout.write(" "+eval( '" ' +key+"_bbt"+ ' ".'+key+"_bbt")) }); + +console.log();