main
Last change
on this file since d565449 was d565449, checked in by stefan toskovski <stefantoska84@…>, 4 weeks ago |
Update repo after prototype presentation
|
-
Property mode
set to
100644
|
File size:
878 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 |
|
---|
3 | var test = require('tape');
|
---|
4 | var v = require('es-value-fixtures');
|
---|
5 | var forEach = require('for-each');
|
---|
6 | var inspect = require('object-inspect');
|
---|
7 |
|
---|
8 | var regexTester = require('../');
|
---|
9 |
|
---|
10 | test('regex tester', function (t) {
|
---|
11 | t.equal(typeof regexTester, 'function', 'is a function');
|
---|
12 |
|
---|
13 | t.test('non-regexes', function (st) {
|
---|
14 | forEach(v.primitives.concat(v.objects), function (val) {
|
---|
15 | st['throws'](
|
---|
16 | function () { regexTester(val); },
|
---|
17 | TypeError,
|
---|
18 | inspect(val) + ' is not a regex'
|
---|
19 | );
|
---|
20 | });
|
---|
21 |
|
---|
22 | st.end();
|
---|
23 | });
|
---|
24 |
|
---|
25 | t.test('regexes', function (st) {
|
---|
26 | var tester = regexTester(/a/);
|
---|
27 |
|
---|
28 | st.equal(typeof tester, 'function', 'returns a function');
|
---|
29 | st.equal(tester('a'), true, 'returns true for a match');
|
---|
30 | st.equal(tester('b'), false, 'returns false for a non-match');
|
---|
31 | st.equal(tester('a'), true, 'returns true for a match again');
|
---|
32 |
|
---|
33 | st.end();
|
---|
34 | });
|
---|
35 |
|
---|
36 | t.end();
|
---|
37 | });
|
---|
Note:
See
TracBrowser
for help on using the repository browser.