Skip to content

Commit

Permalink
Update test case.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaywcjlove committed Jun 12, 2018
1 parent d53f063 commit ca2edb3
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 35 deletions.
7 changes: 6 additions & 1 deletion test/256.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
var Color = require('..').Colors;


console.log();
console.log();
console.log(' System colors');
Expand All @@ -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();
Expand Down Expand Up @@ -58,4 +61,6 @@ console.log();
function wordwrap(i) {
i = String(i)
return i + new Array(5 - i.length).join(' ');
}
}

console.log();
24 changes: 24 additions & 0 deletions test/group.test.js
Original file line number Diff line number Diff line change
@@ -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();
44 changes: 22 additions & 22 deletions test/safe.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"
// })
// })
24 changes: 12 additions & 12 deletions test/string.test.js → test/toxic.test.js
Original file line number Diff line number Diff line change
@@ -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 );
Expand All @@ -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("")
Expand All @@ -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("")
Expand All @@ -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"))
});


Expand All @@ -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"))
});


Expand All @@ -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();

0 comments on commit ca2edb3

Please sign in to comment.