Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Newer
Older
100644 84 lines (66 sloc) 1.356 kB
51cc887 @mjackson Improved support for multibyte characters
authored
1 # encoding: UTF-8
2
fdd8b48 @mjackson Added tests for multibyte encodings
authored
3 require File.expand_path('../helper', __FILE__)
4
5 class MultibyteTest < Test::Unit::TestCase
6110cf1 @mjackson Fixed memoization bug
authored
6 grammar :Multibyte do
7 rule :string do
51cc887 @mjackson Improved support for multibyte characters
authored
8 "ä"
fdd8b48 @mjackson Added tests for multibyte encodings
authored
9 end
10
6110cf1 @mjackson Fixed memoization bug
authored
11 rule :regexp do
51cc887 @mjackson Improved support for multibyte characters
authored
12 /(ä)+/
fdd8b48 @mjackson Added tests for multibyte encodings
authored
13 end
14
6110cf1 @mjackson Fixed memoization bug
authored
15 rule :character_class do
51cc887 @mjackson Improved support for multibyte characters
authored
16 /[ä]+/
fdd8b48 @mjackson Added tests for multibyte encodings
authored
17 end
8d0ff78 @mjackson Use UTF-8 encoding for Citrus::DOT
authored
18
19 rule :dot do
20 DOT
21 end
fdd8b48 @mjackson Added tests for multibyte encodings
authored
22 end
23
24 def test_multibyte_string
51cc887 @mjackson Improved support for multibyte characters
authored
25 m = Multibyte.parse("ä", :root => :string)
fdd8b48 @mjackson Added tests for multibyte encodings
authored
26 assert(m)
27 end
28
29 def test_multibyte_regexp
51cc887 @mjackson Improved support for multibyte characters
authored
30 m = Multibyte.parse("äää", :root => :regexp)
fdd8b48 @mjackson Added tests for multibyte encodings
authored
31 assert(m)
32 end
33
34 def test_multibyte_character_class
51cc887 @mjackson Improved support for multibyte characters
authored
35 m = Multibyte.parse("äää", :root => :character_class)
36 assert(m)
37 end
38
8d0ff78 @mjackson Use UTF-8 encoding for Citrus::DOT
authored
39 def test_multibyte_dot
40 m = Multibyte.parse("ä", :root => :dot)
41 assert(m)
42 end
43
51cc887 @mjackson Improved support for multibyte characters
authored
44 Citrus.eval(<<-CITRUS)
45 grammar Multibyte2
46 rule string
47 "ä"
48 end
49
50 rule regexp
51 /(ä)+/
52 end
53
54 rule character_class
55 [ä]+
56 end
8d0ff78 @mjackson Use UTF-8 encoding for Citrus::DOT
authored
57
58 rule dot
59 .+
60 end
51cc887 @mjackson Improved support for multibyte characters
authored
61 end
62 CITRUS
63
64 def test_multibyte2_string
65 m = Multibyte2.parse("ä", :root => :string)
66 assert(m)
67 end
68
69 def test_multibyte2_regexp
70 m = Multibyte2.parse("äää", :root => :regexp)
71 assert(m)
72 end
73
74 def test_multibyte2_character_class
75 m = Multibyte2.parse("äää", :root => :character_class)
fdd8b48 @mjackson Added tests for multibyte encodings
authored
76 assert(m)
77 end
8d0ff78 @mjackson Use UTF-8 encoding for Citrus::DOT
authored
78
79 def test_multibyte2_dot
80 m = Multibyte2.parse("äää", :root => :dot)
81 assert(m)
82 end
fdd8b48 @mjackson Added tests for multibyte encodings
authored
83 end
Something went wrong with that request. Please try again.