/[eiffelstudio]/trunk/eweasel/tests/rdtp003/test_utf8.e
ViewVC logotype

Contents of /trunk/eweasel/tests/rdtp003/test_utf8.e

Parent Directory Parent Directory | Revision Log Revision Log


Revision 86987 - (show annotations)
Thu Aug 11 21:49:58 2011 UTC (8 years, 4 months ago) by manus
File size: 4724 byte(s)
New test similar to rdtp001 except that it ensures that the implementation of `is_equivalent' from AST_EIFFEL is correct by comparing the result of two parsings of the same class and verifying they are indeed equivalent.

1 note
2 test: "测试"
3 test: "Test 测试 Test"
4
5 class
6 TEST_UTF8
7
8 create
9 make
10
11 feature -- Make
12
13 make
14 do
15 test_char
16 test_string_32
17 test_string_8
18 test_system_string
19 end
20
21 feature -- Run time
22
23 test_char
24 do
25 print ("Manifest CHARACTER_32: " + (char1.code = 27979).out + "%N")
26 print ("CHARACTER_8 vs Unicode: " + (({CHARACTER_8}'测').code = 75).out + "%N")
27 print ("CHARACTER_32 vs ASCII: " + (({CHARACTER_32}'a').code = 97).out + "%N")
28 print ("CHARACTER_32 vs Unicode: " + (({CHARACTER_32}'测').code = 27979).out + "%N")
29 print ("CHARACTER_8 vs ASCII: " + (({CHARACTER_8}'a').code = 97).out + "%N")
30 print ("CHARACTER_32 constant type: " + (char1.generating_type).out + "%N")
31 print ("CHARACTER_8 constant type: " + (char_8.generating_type).out + "%N")
32 print ("Manifest Unicode char type: " + ('测').generating_type.out + "%N")
33 print ("Manifest ASCII char type: " + ('a').generating_type.out + "%N")
34 print ("CHARACTER_8 typed Unicode character type: " + ({CHARACTER_8}'测').generating_type.out + "%N")
35 print ("CHARACTER_32 ASCII character type: " + ({CHARACTER_32}'a').generating_type.out + "%N")
36 print ("CHARACTER_32 typed Unicode character type: " + ({CHARACTER_32}'测').generating_type.out + "%N")
37 print ("CHARACTER_8 typed ASCII character type: " + ({CHARACTER_8}'a').generating_type.out + "%N")
38 end
39
40 test_string_32
41 local
42 l_pass: BOOLEAN
43 l_str: STRING_32
44 do
45 l_pass :=
46 str32_1.item (1).code = 27979 and then
47 str32_1.item (2).code = 35797 and then
48 str32_1.count = 2
49 print ("STRING_32 constants test 1: " + l_pass.out + "%N")
50
51 l_pass :=
52 str32_2.item (1).code = 27979 and then
53 str32_2.item (2).code = 35797 and then
54 str32_2.count = 2
55 print ("STRING_32 constants test 2: " + l_pass.out + "%N")
56
57 l_pass :=
58 str32_3.item (1).code = 27979 and then
59 str32_3.item (2).code = 35797 and then
60 str32_3.count = 2
61 print ("STRING_32 constants test 3: " + l_pass.out + "%N")
62
63 l_str := once_str_in_feature
64 l_pass :=
65 l_str.item (1).code = 27979 and then
66 l_str.item (2).code = 35797 and then
67 l_str.count = 2
68 print ("STRING_32 constants test 4: " + l_pass.out + "%N")
69
70 l_str := str_in_feature
71 l_pass :=
72 l_str.item (1).code = 27979 and then
73 l_str.item (2).code = 35797 and then
74 l_str.count = 2
75 print ("STRING_32 constants test 5: " + l_pass.out + "%N")
76 end
77
78 test_string_8
79 local
80 l_pass: BOOLEAN
81 do
82 -- STRING_8
83 l_pass :=
84 str8_1.item (1).code = 0xE6 and then
85 str8_1.item (2).code = 0xB5 and then
86 str8_1.item (3).code = 0x8B and then
87 str8_1.item (4).code = 0xE8 and then
88 str8_1.item (5).code = 0xAF and then
89 str8_1.item (6).code = 0x95 and then
90 str8_1.count = 6
91 print ("STRING_8 constants test 1: " + l_pass.out + "%N")
92
93 l_pass :=
94 str8_2.item (1).code = 0xE6 and then
95 str8_2.item (2).code = 0xB5 and then
96 str8_2.item (3).code = 0x8B and then
97 str8_2.item (4).code = 0xE8 and then
98 str8_2.item (5).code = 0xAF and then
99 str8_2.item (6).code = 0x95 and then
100 str8_2.count = 6
101 print ("STRING_8 constants test 2: " + l_pass.out + "%N")
102
103 l_pass :=
104 str8_3.item (1).code = 0xE6 and then
105 str8_3.item (2).code = 0xB5 and then
106 str8_3.item (3).code = 0x8B and then
107 str8_3.item (4).code = 0xE8 and then
108 str8_3.item (5).code = 0xAF and then
109 str8_3.item (6).code = 0x95 and then
110 str8_3.count = 6
111 print ("STRING_8 constants test 3: " + l_pass.out + "%N")
112 end
113
114 test_system_string
115 local
116 l_s: SYSTEM_STRING
117 do
118 if {PLATFORM}.is_dotnet then
119 l_s := str32_1
120 l_s := {STRING_32}"测试"
121 l_s := str8_1
122 l_s := "a"
123 end
124 end
125
126 feature -- Comment 注释测试
127
128 -- 注释测试
129 -- Comment Test 注释测试 Comment Test
130
131 feature -- Characters
132
133 char1: CHARACTER_32 = '测'
134 char_8: CHARACTER = 's'
135
136 feature -- Strings
137
138 str32_1: STRING_32 = {STRING_32}"测试"
139 str32_2: STRING_32 = {STRING_32}"%/27979/%/35797/"
140 str32_3: STRING_32 =
141 {STRING_32}
142 "[
143 测试
144 ]"
145
146 str8_1: STRING = "测试"
147 str8_2: STRING = "%/27979/%/35797/"
148 str8_3: STRING =
149 "[
150 测试
151 ]"
152
153 -- Conversion
154 str8_4: STRING = {STRING_32}"测试"
155 str8_5: STRING = {STRING_32}"%/27979/%/35797/"
156 str8_6: STRING =
157 {STRING_32}
158 "[
159 测试
160 ]"
161
162 str1: STRING =
163 "[
164 Test 测试 Test.
165 这是一段用于测试的中文。
166 ]"
167 str2: STRING = "Test %/27979/ %/35797/ Test code points."
168
169 once_str_in_feature: STRING_32
170 local
171 l_str: STRING_32
172 do
173 l_str := (once {STRING_32} "测试")
174 Result := l_str
175 end
176
177 str_in_feature: STRING_32
178 local
179 l_str: STRING_32
180 do
181 l_str := ({STRING_32} "测试")
182 Result := l_str
183 end
184
185 end

Properties

Name Value
svn:eol-style native
svn:keywords Author Date Id Revision

  ViewVC Help
Powered by ViewVC 1.1.23