ecma-re-validator 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +32 -0
- data/.travis.yml +17 -0
- data/Gemfile +3 -0
- data/LICENSE +22 -0
- data/README.md +17 -0
- data/Rakefile +8 -0
- data/ecma-re-validator.gemspec +24 -0
- data/lib/ecma-re-validator.rb +47 -0
- data/lib/ecma-re-validator/version.rb +3 -0
- data/script/bootstrap +3 -0
- data/script/cibuild +5 -0
- data/spec/anchors_spec.rb +63 -0
- data/spec/atomic_grouping_spec.rb +9 -0
- data/spec/comments_spec.rb +22 -0
- data/spec/conditionals_spec.rb +21 -0
- data/spec/lookbehind_spec.rb +27 -0
- data/spec/mode_modifiers_spec.rb +27 -0
- data/spec/named_capture_groups_spec.rb +15 -0
- data/spec/possesive_quantifiers_spec.rb +21 -0
- data/spec/spec_helper.rb +16 -0
- data/spec/unicode_spec.rb +98 -0
- data/spec/validator_spec.rb +27 -0
- data/vendor/cache/awesome_print-1.6.1.gem +0 -0
- data/vendor/cache/coderay-1.1.0.gem +0 -0
- data/vendor/cache/diff-lcs-1.2.5.gem +0 -0
- data/vendor/cache/method_source-0.8.2.gem +0 -0
- data/vendor/cache/pry-0.10.1.gem +0 -0
- data/vendor/cache/rake-10.4.2.gem +0 -0
- data/vendor/cache/regexp_parser-0.2.0.gem +0 -0
- data/vendor/cache/rspec-3.2.0.gem +0 -0
- data/vendor/cache/rspec-core-3.2.2.gem +0 -0
- data/vendor/cache/rspec-expectations-3.2.0.gem +0 -0
- data/vendor/cache/rspec-mocks-3.2.1.gem +0 -0
- data/vendor/cache/rspec-support-3.2.2.gem +0 -0
- data/vendor/cache/slop-3.6.0.gem +0 -0
- metadata +161 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: ad7c47aa986f667a8972067436fcd35c8e5b1c3b
|
4
|
+
data.tar.gz: 157e0ee1420ecf52a1725609de98af9c38edc5bd
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: b773ba7a38ac1ef62d14438ae5052ad4c30810e5bd9246b4e824b6b3cf6fe7ac5125b0075cc29756e5c395b7e5bb14267952a8f0a1424b4fd446162396b63146
|
7
|
+
data.tar.gz: e1501b5f7f7068c72bd62f8d724b0af1874e7a5b27519721c5307df83eafbc33bcd6b814d1f41fe682f0cc3a92563e3fda96aeda5cb0627896b84e8040452f8d
|
data/.gitignore
ADDED
@@ -0,0 +1,32 @@
|
|
1
|
+
# File generated by script/bootstrap
|
2
|
+
/.bundle/
|
3
|
+
/bin
|
4
|
+
/vendor/ruby
|
5
|
+
/vendor/gems/
|
6
|
+
/vendor/cache/ruby/
|
7
|
+
|
8
|
+
*.rbc
|
9
|
+
.bundle
|
10
|
+
.config
|
11
|
+
coverage
|
12
|
+
InstalledFiles
|
13
|
+
lib/bundler/man
|
14
|
+
pkg
|
15
|
+
rdoc
|
16
|
+
spec/reports
|
17
|
+
test/tmp
|
18
|
+
test/version_tmp
|
19
|
+
tmp
|
20
|
+
|
21
|
+
Gemfile.lock
|
22
|
+
out/
|
23
|
+
sample.rb
|
24
|
+
run_sample.rb
|
25
|
+
src/
|
26
|
+
docs/
|
27
|
+
|
28
|
+
# YARD artifacts
|
29
|
+
.yardoc
|
30
|
+
_yardoc
|
31
|
+
doc/
|
32
|
+
.DS_Store
|
data/.travis.yml
ADDED
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2015 Garen Torikian
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
21
|
+
SOFTWARE.
|
22
|
+
|
data/README.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
# ecma-re-validator
|
2
|
+
|
3
|
+
[![Build Status](https://travis-ci.org/gjtorikian/ecma-re-validator.svg?branch=master)](https://travis-ci.org/gjtorikian/ecma-re-validator)
|
4
|
+
|
5
|
+
Pass in a string to validate if it would work in ECMA-262, aka JavaScript.
|
6
|
+
|
7
|
+
The information for what is valid and what isn't comes from <http://www.regular-expressions.info/javascript.html>.
|
8
|
+
|
9
|
+
## Usage
|
10
|
+
|
11
|
+
``` ruby
|
12
|
+
require 'ecma-re-validator'
|
13
|
+
|
14
|
+
re = "[Ss]mith\\\\b"
|
15
|
+
|
16
|
+
EcmaReValidator.valid?(re) # true
|
17
|
+
```
|
data/Rakefile
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$LOAD_PATH.push File.expand_path('../lib', __FILE__)
|
3
|
+
require 'ecma-re-validator/version'
|
4
|
+
|
5
|
+
Gem::Specification.new do |gem|
|
6
|
+
gem.name = 'ecma-re-validator'
|
7
|
+
gem.version = EcmaReValidator::VERSION
|
8
|
+
gem.authors = ['Garen Torikian']
|
9
|
+
gem.email = ['gjtorikian@gmail.com']
|
10
|
+
gem.description = %(Validate a regular expression string against what ECMA-262 can actually do.)
|
11
|
+
gem.summary = %(Validate a regular expression string against what ECMA-262 can actually do.)
|
12
|
+
gem.homepage = 'https://github.com/gjtorikian/ecma-re-validator'
|
13
|
+
gem.license = 'MIT'
|
14
|
+
gem.files = `git ls-files -z`.split("\x0")
|
15
|
+
gem.test_files = gem.files.grep(%r{^(spec)/})
|
16
|
+
gem.require_paths = ['lib']
|
17
|
+
|
18
|
+
gem.add_dependency 'regexp_parser', '~> 0.2'
|
19
|
+
|
20
|
+
gem.add_development_dependency 'rspec', '~> 3.1'
|
21
|
+
gem.add_development_dependency 'rake'
|
22
|
+
gem.add_development_dependency 'awesome_print'
|
23
|
+
gem.add_development_dependency "pry", "~> 0.10"
|
24
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
begin
|
2
|
+
require 'awesome_print'
|
3
|
+
require 'pry'
|
4
|
+
rescue LoadError; end
|
5
|
+
|
6
|
+
require 'regexp_parser'
|
7
|
+
|
8
|
+
module EcmaReValidator
|
9
|
+
|
10
|
+
# JS doesn't have Unicode matching
|
11
|
+
UNICODE_CHARACTERS = Regexp::Syntax::Token::UnicodeProperty::All
|
12
|
+
|
13
|
+
INVALID_REGEXP = [
|
14
|
+
# JS doesn't have \A or \Z
|
15
|
+
:bos, :eos_ob_eol,
|
16
|
+
# JS doesn't have lookbehinds
|
17
|
+
:lookbehind, :nlookbehind,
|
18
|
+
# JS doesn't have atomic grouping
|
19
|
+
:atomic,
|
20
|
+
# JS doesn't have possesive quantifiers
|
21
|
+
:zero_or_one_possessive, :zero_or_more_possessive, :one_or_more_possessive,
|
22
|
+
# JS doesn't have named capture groups
|
23
|
+
:named_ab, :named_sq,
|
24
|
+
# JS doesn't support modifying options
|
25
|
+
:options,
|
26
|
+
# JS doesn't support conditionals
|
27
|
+
:condition_open,
|
28
|
+
# JS doesn't support comments
|
29
|
+
:comment
|
30
|
+
]
|
31
|
+
|
32
|
+
INVALID_TOKENS = INVALID_REGEXP + UNICODE_CHARACTERS
|
33
|
+
|
34
|
+
def self.valid?(input)
|
35
|
+
if input.is_a? String
|
36
|
+
begin
|
37
|
+
input = Regexp.new(input)
|
38
|
+
rescue RegexpError
|
39
|
+
return false
|
40
|
+
end
|
41
|
+
elsif !input.is_a? Regexp
|
42
|
+
return false
|
43
|
+
end
|
44
|
+
|
45
|
+
Regexp::Scanner.scan(input).none? { |t| INVALID_TOKENS.include?(t[1]) }
|
46
|
+
end
|
47
|
+
end
|
data/script/bootstrap
ADDED
data/script/cibuild
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'EcmaReValidator::Anchors' do
|
4
|
+
it 'should pass if regexp has no \A' do
|
5
|
+
re = 'moby'
|
6
|
+
|
7
|
+
expect(EcmaReValidator.valid?(re)).to eql(true)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should pass if regexp is escaped \A' do
|
11
|
+
re = 'moby\\\\A'
|
12
|
+
|
13
|
+
expect(EcmaReValidator.valid?(re)).to eql(true)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should fail if regexp is not escaped \A' do
|
17
|
+
re = 'moby\\A'
|
18
|
+
|
19
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should fail if regexp is not escaped \A, despite backslashes' do
|
23
|
+
re = 'moby\\\\\\A'
|
24
|
+
|
25
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'should pass if regexp is escaped \A, with many backslashes' do
|
29
|
+
re = 'moby\\\\\\\\A'
|
30
|
+
|
31
|
+
expect(EcmaReValidator.valid?(re)).to eql(true)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should pass if regexp has no \Z' do
|
35
|
+
re = 'dick'
|
36
|
+
|
37
|
+
expect(EcmaReValidator.valid?(re)).to eql(true)
|
38
|
+
end
|
39
|
+
|
40
|
+
it 'should pass if regexp is escaped \Z' do
|
41
|
+
re = 'dick\\\\A'
|
42
|
+
|
43
|
+
expect(EcmaReValidator.valid?(re)).to eql(true)
|
44
|
+
end
|
45
|
+
|
46
|
+
it 'should fail if regexp is not escaped \Z' do
|
47
|
+
re = 'dick\\A'
|
48
|
+
|
49
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
50
|
+
end
|
51
|
+
|
52
|
+
it 'should fail if regexp is not escaped \Z, despite backslashes' do
|
53
|
+
re = 'moby\\\\\\Z'
|
54
|
+
|
55
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
56
|
+
end
|
57
|
+
|
58
|
+
it 'should pass if regexp is escaped \Z, with many backslashes' do
|
59
|
+
re = 'moby\\\\\\\\Z'
|
60
|
+
|
61
|
+
expect(EcmaReValidator.valid?(re)).to eql(true)
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'EcmaReValidator::Comments' do
|
4
|
+
it 'should fail if regexp has inline comments' do
|
5
|
+
re = /(?#comment)hello/
|
6
|
+
|
7
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should fail if regexp has inline comments across lines' do
|
11
|
+
re = %r{
|
12
|
+
start # some text
|
13
|
+
\s # white space char
|
14
|
+
(group) # first group
|
15
|
+
(?:alt1|alt2) # some alternation
|
16
|
+
end
|
17
|
+
}x
|
18
|
+
|
19
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'EcmaReValidator::Conditionals' do
|
4
|
+
it 'should pass if regexp is using just (?...)' do
|
5
|
+
re = '(?:Aa)'
|
6
|
+
|
7
|
+
expect(EcmaReValidator.valid?(re)).to eql(true)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should fail if regexp is using complicated if-then-else' do
|
11
|
+
re = '(?(?=condition)(then1|then2|then3)|(else1|else2|else3))'
|
12
|
+
|
13
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should fail if regexp is using basic if-then-else' do
|
17
|
+
re = 'b(?(1)c|d)'
|
18
|
+
|
19
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'EcmaReValidator::Lookbehind' do
|
4
|
+
it 'should fail if regexp has a positive lookbehind' do
|
5
|
+
re = '(?<=a)b'
|
6
|
+
|
7
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should pass if regexp has an escaped positive lookbehind' do
|
11
|
+
re = '\\(?<=a\\)b'
|
12
|
+
|
13
|
+
expect(EcmaReValidator.valid?(re)).to eql(true)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should fail if regexp has a negative lookbehind' do
|
17
|
+
re = '(?<!a)b'
|
18
|
+
|
19
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should pass if regexp has an escaped negative lookbehind' do
|
23
|
+
re = '\\(?<!a\\)b'
|
24
|
+
|
25
|
+
expect(EcmaReValidator.valid?(re)).to eql(true)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'EcmaReValidator::ModeModifiers' do
|
4
|
+
it 'should fail if regexp has simple option' do
|
5
|
+
re = '(?i)test'
|
6
|
+
|
7
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should fail if regexp has multiple options' do
|
11
|
+
re = '(?ism)test'
|
12
|
+
|
13
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should fail if regexp has colon option' do
|
17
|
+
re = '(?mix:abc)'
|
18
|
+
|
19
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'should fail if regexp has hyphen option' do
|
23
|
+
re = 'te(?-i)st'
|
24
|
+
|
25
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'EcmaReValidator::NamedCaptureGroups' do
|
4
|
+
it 'should fail if regexp has named capture group using ?<>' do
|
5
|
+
re = /(?<name>group)/
|
6
|
+
|
7
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should fail if regexp has named capture group using ?\'\'' do
|
11
|
+
re = /(?'name'group)/
|
12
|
+
|
13
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'EcmaReValidator::PossesiveQuantifiers' do
|
4
|
+
it 'should fail if regexp has *+ possesive quantifier' do
|
5
|
+
re = /"[^"]*+"/
|
6
|
+
|
7
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should fail if regexp has ++ possesive quantifier' do
|
11
|
+
re = /"[^"]++"/
|
12
|
+
|
13
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'should fail if regexp has ?+ possesive quantifier' do
|
17
|
+
re = /"[^"]?+"/
|
18
|
+
|
19
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'bundler/setup'
|
2
|
+
require_relative "../lib/ecma-re-validator"
|
3
|
+
|
4
|
+
RSpec.configure do |config|
|
5
|
+
# Use color in STDOUT
|
6
|
+
config.color = true
|
7
|
+
|
8
|
+
# Use color not only in STDOUT but also in pagers and files
|
9
|
+
config.tty = true
|
10
|
+
|
11
|
+
# Use the specified formatter
|
12
|
+
config.formatter = :documentation # :progress, :html, :textmate
|
13
|
+
|
14
|
+
# Run in a random order
|
15
|
+
config.order = :random
|
16
|
+
end
|
@@ -0,0 +1,98 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'EcmaReValidator::Unicode' do
|
4
|
+
it 'should fail if regexp uses \p{L} or \p{Letter}' do
|
5
|
+
re = /\p{L}/
|
6
|
+
|
7
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
8
|
+
|
9
|
+
re = /\p{Letter}/
|
10
|
+
|
11
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
12
|
+
end
|
13
|
+
|
14
|
+
it 'should fail if regexp uses \p{M} or \p{Mark}' do
|
15
|
+
re = /\p{M}/
|
16
|
+
|
17
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
18
|
+
|
19
|
+
re = /\p{Mark}/
|
20
|
+
|
21
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
22
|
+
end
|
23
|
+
|
24
|
+
it 'should fail if regexp uses \p{Z} or \p{Separator}' do
|
25
|
+
re = /\p{Z}/
|
26
|
+
|
27
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
28
|
+
|
29
|
+
re = /\p{Separator}/
|
30
|
+
|
31
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
32
|
+
end
|
33
|
+
|
34
|
+
it 'should fail if regexp uses \p{S} or \p{Symbol}' do
|
35
|
+
re = /\p{S}/
|
36
|
+
|
37
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
38
|
+
|
39
|
+
re = /\p{Symbol}/
|
40
|
+
|
41
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
42
|
+
end
|
43
|
+
|
44
|
+
it 'should fail if regexp uses \p{N} or \p{Number}' do
|
45
|
+
re = /\p{N}/
|
46
|
+
|
47
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
48
|
+
|
49
|
+
re = /\p{Number}/
|
50
|
+
|
51
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
52
|
+
end
|
53
|
+
|
54
|
+
it 'should fail if regexp uses \p{P} or \p{Punctuation}' do
|
55
|
+
re = /\p{P}/
|
56
|
+
|
57
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
58
|
+
|
59
|
+
re = /\p{Punctuation}/
|
60
|
+
|
61
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
62
|
+
end
|
63
|
+
|
64
|
+
it 'should fail if regexp uses \p{C} or \p{Other}' do
|
65
|
+
re = /\p{C}/
|
66
|
+
|
67
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
68
|
+
|
69
|
+
re = /\p{Other}/
|
70
|
+
|
71
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
72
|
+
end
|
73
|
+
|
74
|
+
it 'should fail if regexp uses a script' do
|
75
|
+
re = /\p{Armenian}/
|
76
|
+
|
77
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
78
|
+
end
|
79
|
+
|
80
|
+
# not yet supported
|
81
|
+
# it 'should fail if regexp uses a block' do
|
82
|
+
# re = /\p{InArmenian}/
|
83
|
+
#
|
84
|
+
# expect(EcmaReValidator.valid?(re)).to eql(false)
|
85
|
+
# end
|
86
|
+
|
87
|
+
it 'should pass if regexp uses a \u' do
|
88
|
+
re = /\uf8f8/
|
89
|
+
|
90
|
+
expect(EcmaReValidator.valid?(re)).to eql(true)
|
91
|
+
end
|
92
|
+
|
93
|
+
it 'should pass if regexp uses a \x' do
|
94
|
+
re = /\x22/
|
95
|
+
|
96
|
+
expect(EcmaReValidator.valid?(re)).to eql(true)
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe 'EcmaRe' do
|
4
|
+
it 'should fail if input is not a string or regexp' do
|
5
|
+
re = 92
|
6
|
+
|
7
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
8
|
+
end
|
9
|
+
|
10
|
+
it 'should fail if string is not resolvable' do
|
11
|
+
re = '(\w'
|
12
|
+
|
13
|
+
expect(EcmaReValidator.valid?(re)).to eql(false)
|
14
|
+
end
|
15
|
+
|
16
|
+
it 'passes for a valid regexp string' do
|
17
|
+
re = "[Ss]mith\\\\b"
|
18
|
+
|
19
|
+
expect(EcmaReValidator.valid?(re)).to eql(true)
|
20
|
+
end
|
21
|
+
|
22
|
+
it 'passes for a valid regexp' do
|
23
|
+
re = /[Ss]mith\\\\b/
|
24
|
+
|
25
|
+
expect(EcmaReValidator.valid?(re)).to eql(true)
|
26
|
+
end
|
27
|
+
end
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
metadata
ADDED
@@ -0,0 +1,161 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: ecma-re-validator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Garen Torikian
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2015-03-19 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: regexp_parser
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - "~>"
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0.2'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0.2'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: rspec
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '3.1'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '3.1'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: awesome_print
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :development
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: pry
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - "~>"
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: '0.10'
|
76
|
+
type: :development
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0.10'
|
83
|
+
description: Validate a regular expression string against what ECMA-262 can actually
|
84
|
+
do.
|
85
|
+
email:
|
86
|
+
- gjtorikian@gmail.com
|
87
|
+
executables: []
|
88
|
+
extensions: []
|
89
|
+
extra_rdoc_files: []
|
90
|
+
files:
|
91
|
+
- ".gitignore"
|
92
|
+
- ".travis.yml"
|
93
|
+
- Gemfile
|
94
|
+
- LICENSE
|
95
|
+
- README.md
|
96
|
+
- Rakefile
|
97
|
+
- ecma-re-validator.gemspec
|
98
|
+
- lib/ecma-re-validator.rb
|
99
|
+
- lib/ecma-re-validator/version.rb
|
100
|
+
- script/bootstrap
|
101
|
+
- script/cibuild
|
102
|
+
- spec/anchors_spec.rb
|
103
|
+
- spec/atomic_grouping_spec.rb
|
104
|
+
- spec/comments_spec.rb
|
105
|
+
- spec/conditionals_spec.rb
|
106
|
+
- spec/lookbehind_spec.rb
|
107
|
+
- spec/mode_modifiers_spec.rb
|
108
|
+
- spec/named_capture_groups_spec.rb
|
109
|
+
- spec/possesive_quantifiers_spec.rb
|
110
|
+
- spec/spec_helper.rb
|
111
|
+
- spec/unicode_spec.rb
|
112
|
+
- spec/validator_spec.rb
|
113
|
+
- vendor/cache/awesome_print-1.6.1.gem
|
114
|
+
- vendor/cache/coderay-1.1.0.gem
|
115
|
+
- vendor/cache/diff-lcs-1.2.5.gem
|
116
|
+
- vendor/cache/method_source-0.8.2.gem
|
117
|
+
- vendor/cache/pry-0.10.1.gem
|
118
|
+
- vendor/cache/rake-10.4.2.gem
|
119
|
+
- vendor/cache/regexp_parser-0.2.0.gem
|
120
|
+
- vendor/cache/rspec-3.2.0.gem
|
121
|
+
- vendor/cache/rspec-core-3.2.2.gem
|
122
|
+
- vendor/cache/rspec-expectations-3.2.0.gem
|
123
|
+
- vendor/cache/rspec-mocks-3.2.1.gem
|
124
|
+
- vendor/cache/rspec-support-3.2.2.gem
|
125
|
+
- vendor/cache/slop-3.6.0.gem
|
126
|
+
homepage: https://github.com/gjtorikian/ecma-re-validator
|
127
|
+
licenses:
|
128
|
+
- MIT
|
129
|
+
metadata: {}
|
130
|
+
post_install_message:
|
131
|
+
rdoc_options: []
|
132
|
+
require_paths:
|
133
|
+
- lib
|
134
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
135
|
+
requirements:
|
136
|
+
- - ">="
|
137
|
+
- !ruby/object:Gem::Version
|
138
|
+
version: '0'
|
139
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
140
|
+
requirements:
|
141
|
+
- - ">="
|
142
|
+
- !ruby/object:Gem::Version
|
143
|
+
version: '0'
|
144
|
+
requirements: []
|
145
|
+
rubyforge_project:
|
146
|
+
rubygems_version: 2.2.2
|
147
|
+
signing_key:
|
148
|
+
specification_version: 4
|
149
|
+
summary: Validate a regular expression string against what ECMA-262 can actually do.
|
150
|
+
test_files:
|
151
|
+
- spec/anchors_spec.rb
|
152
|
+
- spec/atomic_grouping_spec.rb
|
153
|
+
- spec/comments_spec.rb
|
154
|
+
- spec/conditionals_spec.rb
|
155
|
+
- spec/lookbehind_spec.rb
|
156
|
+
- spec/mode_modifiers_spec.rb
|
157
|
+
- spec/named_capture_groups_spec.rb
|
158
|
+
- spec/possesive_quantifiers_spec.rb
|
159
|
+
- spec/spec_helper.rb
|
160
|
+
- spec/unicode_spec.rb
|
161
|
+
- spec/validator_spec.rb
|