|
@ -300,6 +300,21 @@ function wrapAssertions(callbacks) { |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
regex(string, regex, message) { |
|
|
regex(string, regex, message) { |
|
|
|
|
|
if (typeof string !== 'string') { |
|
|
|
|
|
throw new AssertionError({ |
|
|
|
|
|
assertion: 'regex', |
|
|
|
|
|
message: '`t.regex()` must be called with a string', |
|
|
|
|
|
values: [formatAssertError.formatWithLabel('Called with:', string)] |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
if (!(regex instanceof RegExp)) { |
|
|
|
|
|
throw new AssertionError({ |
|
|
|
|
|
assertion: 'regex', |
|
|
|
|
|
message: '`t.regex()` must be called with a regular expression', |
|
|
|
|
|
values: [formatAssertError.formatWithLabel('Called with:', regex)] |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (!regex.test(string)) { |
|
|
if (!regex.test(string)) { |
|
|
throw new AssertionError({ |
|
|
throw new AssertionError({ |
|
|
assertion: 'regex', |
|
|
assertion: 'regex', |
|
@ -313,6 +328,21 @@ function wrapAssertions(callbacks) { |
|
|
}, |
|
|
}, |
|
|
|
|
|
|
|
|
notRegex(string, regex, message) { |
|
|
notRegex(string, regex, message) { |
|
|
|
|
|
if (typeof string !== 'string') { |
|
|
|
|
|
throw new AssertionError({ |
|
|
|
|
|
assertion: 'notRegex', |
|
|
|
|
|
message: '`t.notRegex()` must be called with a string', |
|
|
|
|
|
values: [formatAssertError.formatWithLabel('Called with:', string)] |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
if (!(regex instanceof RegExp)) { |
|
|
|
|
|
throw new AssertionError({ |
|
|
|
|
|
assertion: 'notRegex', |
|
|
|
|
|
message: '`t.notRegex()` must be called with a regular expression', |
|
|
|
|
|
values: [formatAssertError.formatWithLabel('Called with:', regex)] |
|
|
|
|
|
}); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (regex.test(string)) { |
|
|
if (regex.test(string)) { |
|
|
throw new AssertionError({ |
|
|
throw new AssertionError({ |
|
|
assertion: 'notRegex', |
|
|
assertion: 'notRegex', |
|
|