1234567891011121314151617181920212223242526272829303132333435363738 |
- /**
- * Created by Tony on 2017/4/7.
- */
- var test = require('tape');
- test('some string test cases', function (t) {
- var reg = /^\s*$/;
- var foo = " ";
- t.equal(reg.test(foo), true);
- foo = null;
- t.equal(reg.test(foo), true);
- foo = undefined;
- t.equal(reg.test(foo), true);
- foo = "";
- t.equal(reg.test(foo), true);
- foo = 0;
- t.equal(reg.test(foo), true);
- t.end();
- });
- test('check if string type', function(t){
- var foo = "";
- t.equal(typeof foo, 'string');
- foo = " ";
- t.equal(typeof foo, 'string');
- foo = 0;
- t.equal(typeof foo, 'number');
- foo = true;
- t.equal(typeof foo, 'boolean');
- foo = {};
- t.equal(typeof foo, 'object');
- foo = function(){};
- t.equal(typeof foo, 'function');
- foo = [];
- t.equal(Array.isArray(foo), true);
- t.end();
- })
|