"Fossies" - the Fresh Open Source Software Archive

Member "Atom/resources/app/apm/node_modules/colors/test.js" (7 Feb 2017, 2138 Bytes) of archive /windows/misc/atom-windows.zip:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Javascript source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 var assert = require('assert'),
    2     colors = require('./colors');
    3 
    4 var s = 'string';
    5 
    6 function a(s, code) {
    7   return '\x1B[' + code.toString() + 'm' + s + '\x1B[39m';
    8 }
    9 
   10 function aE(s, color, code) {
   11   assert.equal(s[color], a(s, code));
   12   assert.equal(colors[color](s), a(s, code));
   13   assert.equal(s[color], colors[color](s));
   14   assert.equal(s[color].stripColors, s);
   15   assert.equal(s[color].stripColors, colors.stripColors(s));
   16 }
   17 
   18 function h(s, color) {
   19   return '<span style="color:' + color + ';">' + s + '</span>';
   20 }
   21 
   22 var stylesColors = ['white', 'black', 'blue', 'cyan', 'green', 'magenta', 'red', 'yellow'];
   23 var stylesAll = stylesColors.concat(['bold', 'italic', 'underline', 'inverse', 'rainbow']);
   24 
   25 colors.mode = 'console';
   26 assert.equal(s.bold, '\x1B[1m' + s + '\x1B[22m');
   27 assert.equal(s.italic, '\x1B[3m' + s + '\x1B[23m');
   28 assert.equal(s.underline, '\x1B[4m' + s + '\x1B[24m');
   29 assert.equal(s.strikethrough, '\x1B[9m' + s + '\x1B[29m');
   30 assert.equal(s.inverse, '\x1B[7m' + s + '\x1B[27m');
   31 assert.ok(s.rainbow);
   32 aE(s, 'white', 37);
   33 aE(s, 'grey', 90);
   34 aE(s, 'black', 30);
   35 aE(s, 'blue', 34);
   36 aE(s, 'cyan', 36);
   37 aE(s, 'green', 32);
   38 aE(s, 'magenta', 35);
   39 aE(s, 'red', 31);
   40 aE(s, 'yellow', 33);
   41 assert.equal(s, 'string');
   42 
   43 colors.setTheme({error:'red'});
   44 
   45 assert.equal(typeof("astring".red),'string');
   46 assert.equal(typeof("astring".error),'string');
   47 
   48 colors.mode = 'browser';
   49 assert.equal(s.bold, '<b>' + s + '</b>');
   50 assert.equal(s.italic, '<i>' + s + '</i>');
   51 assert.equal(s.underline, '<u>' + s + '</u>');
   52 assert.equal(s.strikethrough, '<del>' + s + '</del>');
   53 assert.equal(s.inverse, '<span style="background-color:black;color:white;">' + s + '</span>');
   54 assert.ok(s.rainbow);
   55 stylesColors.forEach(function (color) {
   56   assert.equal(s[color], h(s, color));
   57   assert.equal(colors[color](s), h(s, color));
   58 });
   59 
   60 assert.equal(typeof("astring".red),'string');
   61 assert.equal(typeof("astring".error),'string');
   62 
   63 colors.mode = 'none';
   64 stylesAll.forEach(function (style) {
   65   assert.equal(s[style], s);
   66   assert.equal(colors[style](s), s);
   67 });
   68 
   69 assert.equal(typeof("astring".red),'string');
   70 assert.equal(typeof("astring".error),'string');