Skip to content

Commit

Permalink
Tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Jan 15, 2014
1 parent 3c9a8c0 commit b533f74
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
"use strict";

var test = require('tape');
var isRegex = require('./');

test('not regexes', function (t) {
t.notOk(isRegex(), 'undefined is not regex');
t.notOk(isRegex(null), 'null is not regex');
t.notOk(isRegex(false), 'false is not regex');
t.notOk(isRegex(true), 'true is not regex');
t.notOk(isRegex(42), 'number is not regex');
t.notOk(isRegex('foo'), 'string is not regex');
t.notOk(isRegex([]), 'array is not regex');
t.notOk(isRegex({}), 'object is not regex');
t.notOk(isRegex(function () {}), 'function is not regex');
t.end();
});

test('regexes', function (t) {
t.ok(isRegex(/a/g), 'regex literal is regex');
t.ok(isRegex(new RegExp('a', 'g')), 'regex object is regex');
t.end();
});

0 comments on commit b533f74

Please sign in to comment.