Skip to content

Commit

Permalink
Tests: Error for quantified directives
Browse files Browse the repository at this point in the history
  • Loading branch information
slevithan committed Dec 30, 2024
1 parent 9c4a08b commit 4589e46
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ Notice that nearly every feature below has at least subtle differences from Java
✔ Includes all JS forms<br>
✔ Adds <code>{,n}</code> for min 0<br>
✔ Explicit bounds have upper limit of 100,000 (unlimited in JS)<br>
✔ Error with assertions (same as JS with flag <code>u</code>, <code>v</code>)<br>
✔ Error with assertions (same as JS with flag <code>u</code>, <code>v</code>) and directives<br>
</td>
</tr>
<tr valign="top">
Expand Down
34 changes: 21 additions & 13 deletions spec/match-directive.spec.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,29 @@
import {toDetails} from '../dist/index.mjs';
import {r} from '../src/utils.js';
import {matchers} from './helpers/matchers.js';

beforeEach(() => {
jasmine.addMatchers(matchers);
});

// TODO: Add me
// describe('Directive', () => {
// describe('flags', () => {
// it('should', () => {
// expect('').toExactlyMatch(r``);
// });
// });
describe('Directive', () => {
describe('flags', () => {
it('should not allow quantification', () => {
expect(() => toDetails('(?i)+')).toThrow();
expect(() => toDetails('(?imx)+')).toThrow();
expect(() => toDetails('(?-i)+')).toThrow();
expect(() => toDetails('(?im-x)+')).toThrow();
});

// describe('keep', () => {
// it('should', () => {
// expect('').toExactlyMatch(r``);
// });
// });
// });
// TODO: Add remaining
});

describe('keep', () => {
it('should not allow quantification', () => {
expect(() => toDetails(r`\K+`)).toThrow();
expect(() => toDetails(r`a\K+a`)).toThrow();
});

// TODO: Add remaining
});
});

0 comments on commit 4589e46

Please sign in to comment.