Rename REAMDE to README.md
[nit.git] / tests / utf_noindex_test.nit
1 # This file is part of NIT ( http://www.nitlanguage.org ).
2 #
3 # This file is free software, which comes along with NIT. This software is
4 # distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
5 # without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
6 # PARTICULAR PURPOSE. You can modify it is you want, provided this header
7 # is kept unaltered, and a notification of the changes is added.
8 # You are allowed to redistribute it and sell it, alone or is a part of
9 # another product.
10
11 import standard
12 intrude import string_experimentations::utf8_noindex
13
14 var s = "aàハ𐍆".as(FlatString)
15 assert s.char_at(0).code_point == 97
16 assert s.char_at(1).code_point == 224
17 assert s.char_at(2).code_point == 12495
18 assert s.char_at(3).code_point == 66374
19
20 var str = "ハaロЖー𐍃aδΈ–η•Œ α“€ . α“‚ A,𐍆 aζ—₯本Aθͺžaです".as(FlatString)
21
22 print str.length
23 print str
24
25 for i in [0 .. str.length[ do
26 str.char_at(i).output
27 end
28
29 '\n'.output
30
31 var ss = str.reversed.as(FlatString)
32
33 for i in [0 .. ss.length[ do ss.char_at(i).output
34
35 '\n'.output
36
37 var x = str.substring(4,4).as(FlatString)
38
39 for i in [0 .. x.length[ do x.char_at(i).output
40
41 '\n'.output
42
43 var xx = x.reversed.as(FlatString)
44
45 for i in [0 .. xx.length[ do xx.char_at(i).output
46
47 '\n'.output
48
49 var it = new FlatStringReviter(x)
50 for i in it do
51 i.output
52 end
53
54 '\n'.output
55
56 var it2 = new FlatStringIter(x)
57 for i in it2 do
58 i.output
59 end
60
61 '\n'.output
62
63 it = new FlatStringReviter(str)
64 for i in it do
65 i.output
66 end
67
68 '\n'.output
69
70 it2 = new FlatStringIter(str)
71 for i in it2 do
72 i.output
73 end
74
75 '\n'.output
76
77 assert str * 2 == str + str
78
79 assert x * 2 == x + x
80
81 print str.to_upper
82
83 print str.to_lower
84
85 var buf = new FlatBuffer.from(str)
86
87 buf.append str
88
89 var bf = new FlatBuffer.from(str)
90
91 bf.times(2)
92
93 assert bf == buf
94
95 var bf2 = new FlatBuffer.from(str)
96
97 bf2.char_at(0) = str.char_at(1)
98 bf2.char_at(1) = str.char_at(0)
99
100 for i in [0 .. bf2.length[ do bf2.char_at(i).output
101
102 '\n'.output
103
104 bf2.lower
105
106 for i in [0 .. bf2.length[ do bf2.char_at(i).output
107
108 '\n'.output
109
110 bf2.upper
111
112 for i in [0 .. bf2.length[ do bf2.char_at(i).output
113
114 '\n'.output
115
116 bf2.reverse
117
118 for i in [0 .. bf2.length[ do bf2.char_at(i).output
119
120 '\n'.output