moy-fp
Version:
A functional programming library.
48 lines (40 loc) • 1.07 kB
JavaScript
import __ from '../../src/Function/__'
/**
* RegExp | String -> String -> [String]
*/
import match from '../../src/String/match'
test('match(not using __), string', () => {
expect(
match('a')('murakami')
).toEqual(['a'])
})
test('match(not using __), regexp without g flag and subexpression', () => {
expect(
match(/a/)('murakami')
).toEqual(['a'])
})
test('match(not using __), regexp without g flag and with subexpression', () => {
expect(
match(/([kr])a/)('murakami')
).toEqual(['ra', 'r'])
})
test('match(not using __), regexp with g flag and without subexpression', () => {
expect(
match(/a/g)('murakami')
).toEqual(['a', 'a'])
})
test('match(not using __), regexp with g flag and subexpression', () => {
expect(
match(/([kr])a/g)('murakami')
).toEqual(['ra', 'ka'])
})
test('match(not using __), not match', () => {
expect(
match(/([xyz])a/g)('murakami')
).toEqual([])
})
test('match(using __), regexp without g flag and subexpression', () => {
expect(
match(__, 'murakami')(/a/)
).toEqual(['a'])
})