ecma-re-validator 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e57fb40607606a28b871027d9d5dfa2ec0a9cca0
4
- data.tar.gz: b275df109a0f087e9e13694c51201ef42c7f61a9
3
+ metadata.gz: 052e537ab03509e84cc428edf02258ee8c852b8b
4
+ data.tar.gz: 79b4cec8335b67f6b46e149b7267d6c807118edf
5
5
  SHA512:
6
- metadata.gz: f35cd75278a8e2837d2c60c42b6e23640bb7631fdf3cec3a76d591e135d68c26f77a98a9b1b8a498aaebba7fdca0bfb891a909aba3d75dff7b6cf3347009ddfd
7
- data.tar.gz: 63767431a1c105d52e10c8272a881620d875313c4dc55186afd0b11e73052222e9c6e9de8d5fdabadc11ae3aeeca1bd758150574038fd355b3c045ae60d750a8
6
+ metadata.gz: c29be446bc18b0dd381baa35d2ee190bd1cbcf97eb311e2d0f8239e34836ca8490b2a4282b4d421a5dc32d7a62f04ea2309392b8b520c98b5f9c2c9641c2391a
7
+ data.tar.gz: 3ba486142599c4e8ea56a6efc9af557c7d30c68c7fcb0f4c8df8cd6465b1393c649dd4c37dca4047e965d3b015bf4b2456db426e78fa9dee20bb640af85fd2d9
@@ -11,8 +11,8 @@ module EcmaReValidator
11
11
  UNICODE_CHARACTERS = Regexp::Syntax::Token::UnicodeProperty::All
12
12
 
13
13
  INVALID_REGEXP = [
14
- # JS doesn't have \A or \Z
15
- :bos, :eos_ob_eol,
14
+ # JS doesn't have \A, \Z, \z
15
+ :bos, :eos_ob_eol, :eos,
16
16
  # JS doesn't have lookbehinds
17
17
  :lookbehind, :nlookbehind,
18
18
  # JS doesn't have atomic grouping
@@ -1,3 +1,3 @@
1
1
  module EcmaReValidator
2
- VERSION = '0.1.1'
2
+ VERSION = '0.1.2'
3
3
  end
@@ -1,62 +1,92 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe 'EcmaReValidator::Anchors' do
4
+ it 'should pass if regexp has ^' do
5
+ re = '^anchor'
6
+
7
+ expect(EcmaReValidator.valid?(re)).to eql(true)
8
+ end
9
+
10
+ it 'should pass if regexp has $' do
11
+ re = 'anchor$'
12
+
13
+ expect(EcmaReValidator.valid?(re)).to eql(true)
14
+ end
15
+
4
16
  it 'should pass if regexp has no \A' do
5
- re = 'moby'
17
+ re = 'anchor'
6
18
 
7
19
  expect(EcmaReValidator.valid?(re)).to eql(true)
8
20
  end
9
21
 
10
22
  it 'should pass if regexp is escaped \A' do
11
- re = 'moby\\\\A'
23
+ re = 'anchor\\\\A'
12
24
 
13
25
  expect(EcmaReValidator.valid?(re)).to eql(true)
14
26
  end
15
27
 
16
28
  it 'should fail if regexp is not escaped \A' do
17
- re = 'moby\\A'
29
+ re = 'anchor\\A'
18
30
 
19
31
  expect(EcmaReValidator.valid?(re)).to eql(false)
20
32
  end
21
33
 
22
34
  it 'should fail if regexp is not escaped \A, despite backslashes' do
23
- re = 'moby\\\\\\A'
35
+ re = 'anchor\\\\\\A'
24
36
 
25
37
  expect(EcmaReValidator.valid?(re)).to eql(false)
26
38
  end
27
39
 
28
40
  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'
41
+ re = 'anchor\\\\\\\\A'
36
42
 
37
43
  expect(EcmaReValidator.valid?(re)).to eql(true)
38
44
  end
39
45
 
40
46
  it 'should pass if regexp is escaped \Z' do
41
- re = 'dick\\\\A'
47
+ re = 'anchor\\\\Z'
42
48
 
43
49
  expect(EcmaReValidator.valid?(re)).to eql(true)
44
50
  end
45
51
 
46
52
  it 'should fail if regexp is not escaped \Z' do
47
- re = 'dick\\A'
53
+ re = 'anchor\\Z'
48
54
 
49
55
  expect(EcmaReValidator.valid?(re)).to eql(false)
50
56
  end
51
57
 
52
58
  it 'should fail if regexp is not escaped \Z, despite backslashes' do
53
- re = 'moby\\\\\\Z'
59
+ re = 'anchor\\\\\\Z'
54
60
 
55
61
  expect(EcmaReValidator.valid?(re)).to eql(false)
56
62
  end
57
63
 
58
64
  it 'should pass if regexp is escaped \Z, with many backslashes' do
59
- re = 'moby\\\\\\\\Z'
65
+ re = 'anchor\\\\\\\\Z'
66
+
67
+ expect(EcmaReValidator.valid?(re)).to eql(true)
68
+ end
69
+
70
+ it 'should pass if regexp is escaped \z' do
71
+ re = 'anchor\\\\z'
72
+
73
+ expect(EcmaReValidator.valid?(re)).to eql(true)
74
+ end
75
+
76
+ it 'should fail if regexp is not escaped \z' do
77
+ re = 'anchor\\z'
78
+
79
+ expect(EcmaReValidator.valid?(re)).to eql(false)
80
+ end
81
+
82
+ it 'should fail if regexp is not escaped \z, despite backslashes' do
83
+ re = 'anchor\\\\\\z'
84
+
85
+ expect(EcmaReValidator.valid?(re)).to eql(false)
86
+ end
87
+
88
+ it 'should pass if regexp is escaped \z, with many backslashes' do
89
+ re = 'anchor\\\\\\\\z'
60
90
 
61
91
  expect(EcmaReValidator.valid?(re)).to eql(true)
62
92
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ecma-re-validator
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Garen Torikian
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-25 00:00:00.000000000 Z
11
+ date: 2015-04-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: regexp_parser