Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Bowen7 committed Aug 13, 2024
1 parent a8a6179 commit 5b44428
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 1 deletion.
27 changes: 27 additions & 0 deletions src/parser/__tests__/literal-gen.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,29 @@ it('gen with literal = false', () => {
escapeBackslash: false,
}),
).toBe('/')

expect(
gen({
id: '',
type: 'regex',
body: [
{
id: '',
type: 'backReference',
ref: 'name',
quantifier: {
kind: '?',
min: 0,
max: 1,
greedy: true,
},
},
],
flags: [],
literal: false,
escapeBackslash: true,
}),
).toBe('\\k<name>?')
})

it('gen with escapeBackslash = false', () => {
Expand Down Expand Up @@ -132,6 +155,7 @@ it('gen with escapeBackslash = false', () => {
id: '',
type: 'backReference',
ref: '123',
quantifier: null,
},
],
flags: [],
Expand All @@ -149,6 +173,7 @@ it('gen with escapeBackslash = false', () => {
id: '',
type: 'backReference',
ref: 'name',
quantifier: null,
},
],
flags: [],
Expand Down Expand Up @@ -206,6 +231,7 @@ it('gen with escapeBackslash = true', () => {
id: '',
type: 'backReference',
ref: '123',
quantifier: null,
},
],
flags: [],
Expand All @@ -223,6 +249,7 @@ it('gen with escapeBackslash = true', () => {
id: '',
type: 'backReference',
ref: 'name',
quantifier: null,
},
],
flags: [],
Expand Down
2 changes: 2 additions & 0 deletions src/parser/__tests__/non-literal-parse.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ it('parse should return correct ast when receiving \'\\1\'', () => {
id: '',
type: 'backReference',
ref: '1',
quantifier: null,
},
],
flags: [],
Expand Down Expand Up @@ -318,6 +319,7 @@ it('parse should return correct ast when receiving \'\\\\1\'', () => {
id: '',
type: 'backReference',
ref: '1',
quantifier: null,
},
],
flags: [],
Expand Down
7 changes: 7 additions & 0 deletions src/parser/__tests__/valid-2015.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,7 @@ const tests: Tests = {
id: '',
type: 'backReference',
ref: '1',
quantifier: null,
},
],
flags: [],
Expand Down Expand Up @@ -865,6 +866,7 @@ const tests: Tests = {
id: '',
type: 'backReference',
ref: '1',
quantifier: null,
},
],
flags: [],
Expand All @@ -879,6 +881,7 @@ const tests: Tests = {
id: '',
type: 'backReference',
ref: '1',
quantifier: null,
},
{
id: '',
Expand Down Expand Up @@ -925,6 +928,7 @@ const tests: Tests = {
id: '',
type: 'backReference',
ref: '1',
quantifier: null,
},
],
flags: [],
Expand Down Expand Up @@ -1402,6 +1406,7 @@ const tests: Tests = {
id: '',
type: 'backReference',
ref: '377',
quantifier: null,
},
],
flags: [],
Expand All @@ -1416,6 +1421,7 @@ const tests: Tests = {
id: '',
type: 'backReference',
ref: '400',
quantifier: null,
},
],
flags: [],
Expand Down Expand Up @@ -4227,6 +4233,7 @@ const tests: Tests = {
id: '',
type: 'backReference',
ref: 'Name',
quantifier: null,
},
],
flags: [],
Expand Down
2 changes: 1 addition & 1 deletion src/parser/modifiers/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const updateContent = (ast: AST.Regex, id: string, content: AST.Content) => {
}
case 'backReference': {
const { ref } = content
nodeList[index] = { id, type: 'backReference', ref }
nodeList[index] = { id, type: 'backReference', ref, quantifier }
break
}
case 'beginningAssertion': {
Expand Down

0 comments on commit 5b44428

Please sign in to comment.