mirror of
https://activitypub.software/TransFem-org/sfm-js
synced 2024-11-22 14:05:13 +00:00
cb611b278b
it's not supported by many browsers, also the vue/vite compiler refuses to allow it
30 lines
892 B
TypeScript
30 lines
892 B
TypeScript
import assert from 'assert';
|
|
import * as P from '../src/internal/core';
|
|
|
|
describe('core', () => {
|
|
describe('difference', () => {
|
|
test('basic', () => {
|
|
const parser = P.difference(P.regexp(/\p{Letter}/u), P.str('x'));
|
|
|
|
let result = parser.handler('x',0,{}) as P.Success<any>;
|
|
assert.deepStrictEqual(result,P.failure());
|
|
|
|
result = parser.handler('a',0,{}) as P.Success<any>;
|
|
assert.deepStrictEqual(result,P.success(1,'a'));
|
|
});
|
|
|
|
test('horizontal whitespace', () => {
|
|
const parser = P.difference(P.regexp(/\s/u), P.newline);
|
|
|
|
let result = parser.handler('\n',0,{}) as P.Success<any>;
|
|
assert.deepStrictEqual(result,P.failure());
|
|
|
|
result = parser.handler(' ',0,{}) as P.Success<any>;
|
|
assert.deepStrictEqual(result,P.success(1,' '));
|
|
|
|
result = parser.handler('\t',0,{}) as P.Success<any>;
|
|
assert.deepStrictEqual(result,P.success(1,'\t'));
|
|
});
|
|
|
|
});
|
|
});
|