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.

Fix #11, add test cases relative to #11, release 0.2.2#16

Merged
teabyii merged 1 commit intomasterfromfix-issue-11
Oct 19, 2017
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletionslib/Language/Helpers/buildQuery.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -42,9 +42,13 @@ function buildQuery(query, builder = new Builder()) {
// Now, append that method to the builder object.
method.setParameters(parameters).callMethodOn(builder)
} catch (e) {
if (Array.isArray(parameters[0])) {
const lastIndex = parameters.length - 1
if (Array.isArray(parameters[lastIndex])) {
if (lastIndex !== 0) {
method.setParameters(parameters.slice(0, lastIndex))
}
method.callMethodOn(builder)
builder.and(buildQuery(parameters[0], new NonCapture()))
builder.and(buildQuery(parameters[lastIndex], new NonCapture()))
} else {
throw new SyntaxException(`Invalid parameter given for ${method.origin}`)
}
Expand Down
2 changes: 1 addition & 1 deletionpackage.json
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
{
"name": "srl",
"version": "0.2.1",
"version": "0.2.2",
"description": "Simple Regex Language",
"main": "lib/SRL.js",
"scripts": {
Expand Down
19 changes: 19 additions & 0 deletionstest/issue-11-test.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
'use strict'

const assert = require('assert')
const SRL = require('../')

describe('Fix issue 11', () => {
it('Numerical quantifies & non-capturing group', () => {
const query = new SRL('digit, exactly 5 times, (letter, twice) optional')
assert.ok(query.isMatching('12345'))
assert.ok(query.isMatching('12345aa'))
})

it('Complicated case', () => {
const query = new SRL('begin with, digit, exactly 5 times, ( literally \'-\', digit, exactly 4 times ), optional, must end')
assert.ok(query.isMatching('12345-1234'))
})
})


4 changes: 2 additions & 2 deletionstest/parseParentheses-test.js
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -18,8 +18,8 @@ describe('ParseParentheses Test', () => {
assert.deepEqual(parseParentheses('foo (0)'), [ 'foo', [ '0' ] ])

assert.deepEqual(
parseParentheses('foo (bar (nested)) baz'),
[ 'foo', [ 'bar', [ 'nested' ] ], 'baz' ]
parseParentheses('foo (bar (nested)) baz'),
[ 'foo', [ 'bar', [ 'nested' ] ], 'baz' ]
)

assert.deepEqual(
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp