File: unicode_spec.rb

package info (click to toggle)
ruby-ecma-re-validator 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 188 kB
  • sloc: ruby: 297; makefile: 4; sh: 3
file content (118 lines) | stat: -rw-r--r-- 2,479 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
# frozen_string_literal: true

require 'spec_helper'

describe 'EcmaReValidator::Unicode' do
  it 'should fail if regexp uses \p{L} or \p{Letter}' do
    re = /\p{L}/

    expect(EcmaReValidator.valid?(re)).to eql(false)

    re = /\p{Letter}/

    expect(EcmaReValidator.valid?(re)).to eql(false)
  end

  it 'should fail if regexp uses \p{M} or \p{Mark}' do
    re = /\p{M}/

    expect(EcmaReValidator.valid?(re)).to eql(false)

    re = /\p{Mark}/

    expect(EcmaReValidator.valid?(re)).to eql(false)
  end

  it 'should fail if regexp uses \p{Z} or \p{Separator}' do
    re = /\p{Z}/

    expect(EcmaReValidator.valid?(re)).to eql(false)

    re = /\p{Separator}/

    expect(EcmaReValidator.valid?(re)).to eql(false)
  end

  it 'should fail if regexp uses \p{S} or \p{Symbol}' do
    re = /\p{S}/

    expect(EcmaReValidator.valid?(re)).to eql(false)

    re = /\p{Symbol}/

    expect(EcmaReValidator.valid?(re)).to eql(false)
  end

  it 'should fail if regexp uses \p{N} or \p{Number}' do
    re = /\p{N}/

    expect(EcmaReValidator.valid?(re)).to eql(false)

    re = /\p{Number}/

    expect(EcmaReValidator.valid?(re)).to eql(false)
  end

  it 'should fail if regexp uses \p{P} or \p{Punctuation}' do
    re = /\p{P}/

    expect(EcmaReValidator.valid?(re)).to eql(false)

    re = /\p{Punctuation}/

    expect(EcmaReValidator.valid?(re)).to eql(false)
  end

  it 'should fail if regexp uses \p{C} or \p{Other}' do
    re = /\p{C}/

    expect(EcmaReValidator.valid?(re)).to eql(false)

    re = /\p{Other}/

    expect(EcmaReValidator.valid?(re)).to eql(false)
  end

  it 'should fail if regexp uses a script' do
    re = /\p{Armenian}/

    expect(EcmaReValidator.valid?(re)).to eql(false)
  end

  # not yet supported
  # it 'should fail if regexp uses a block' do
  #   re = /\p{InArmenian}/
  #
  #   expect(EcmaReValidator.valid?(re)).to eql(false)
  # end

  it 'should pass if regexp uses a \u' do
    re = /\uf8f8/

    expect(EcmaReValidator.valid?(re)).to eql(true)
  end

  it 'should pass if regexp uses a \x' do
    re = /\x22/

    expect(EcmaReValidator.valid?(re)).to eql(true)
  end

  it 'should pass if regexp uses a \w' do
    re = /^\w+/

    expect(EcmaReValidator.valid?(re)).to eql(true)
  end

  it 'should pass if regexp uses a \s' do
    re = /\s*wow/

    expect(EcmaReValidator.valid?(re)).to eql(true)
  end

  it 'should pass if regexp uses a \d' do
    re = /\d$/

    expect(EcmaReValidator.valid?(re)).to eql(true)
  end
end