Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on Jun 9, 2025. It is now read-only.

Commiteb2f057

Browse files
authored
Fix#11, add test cases relative to#11, release 0.2.2 (#16)
1 parent93e1c74 commiteb2f057

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

‎lib/Language/Helpers/buildQuery.js‎

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,9 +42,13 @@ function buildQuery(query, builder = new Builder()) {
4242
// Now, append that method to the builder object.
4343
method.setParameters(parameters).callMethodOn(builder)
4444
}catch(e){
45-
if(Array.isArray(parameters[0])){
45+
constlastIndex=parameters.length-1
46+
if(Array.isArray(parameters[lastIndex])){
47+
if(lastIndex!==0){
48+
method.setParameters(parameters.slice(0,lastIndex))
49+
}
4650
method.callMethodOn(builder)
47-
builder.and(buildQuery(parameters[0],newNonCapture()))
51+
builder.and(buildQuery(parameters[lastIndex],newNonCapture()))
4852
}else{
4953
thrownewSyntaxException(`Invalid parameter given for${method.origin}`)
5054
}

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"srl",
3-
"version":"0.2.1",
3+
"version":"0.2.2",
44
"description":"Simple Regex Language",
55
"main":"lib/SRL.js",
66
"scripts": {

‎test/issue-11-test.js‎

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
'use strict'
2+
3+
constassert=require('assert')
4+
constSRL=require('../')
5+
6+
describe('Fix issue 11',()=>{
7+
it('Numerical quantifies & non-capturing group',()=>{
8+
constquery=newSRL('digit, exactly 5 times, (letter, twice) optional')
9+
assert.ok(query.isMatching('12345'))
10+
assert.ok(query.isMatching('12345aa'))
11+
})
12+
13+
it('Complicated case',()=>{
14+
constquery=newSRL('begin with, digit, exactly 5 times, ( literally \'-\', digit, exactly 4 times ), optional, must end')
15+
assert.ok(query.isMatching('12345-1234'))
16+
})
17+
})
18+
19+

‎test/parseParentheses-test.js‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ describe('ParseParentheses Test', () => {
1818
assert.deepEqual(parseParentheses('foo (0)'),['foo',['0']])
1919

2020
assert.deepEqual(
21-
parseParentheses('foo (bar (nested)) baz'),
22-
['foo',['bar',['nested']],'baz']
21+
parseParentheses('foo (bar (nested)) baz'),
22+
['foo',['bar',['nested']],'baz']
2323
)
2424

2525
assert.deepEqual(

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp