1 # This file is part of NIT ( http://www.nitlanguage.org ).
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
12 intrude import string_experimentations
::utf8_noindex
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
20 var str
= "γaγΠγΌπaδΈη α . α A,π aζ₯ζ¬Aθͺaγ§γ".as(FlatString)
25 for i
in [0 .. str
.length
[ do
31 var ss
= str
.reversed
.as(FlatString)
33 for i
in [0 .. ss
.length
[ do ss
.char_at
(i
).output
37 var x
= str
.substring
(4,4).as(FlatString)
39 for i
in [0 .. x
.length
[ do x
.char_at
(i
).output
43 var xx
= x
.reversed
.as(FlatString)
45 for i
in [0 .. xx
.length
[ do xx
.char_at
(i
).output
49 var it
= new FlatStringReviter(x
)
56 var it2
= new FlatStringIter(x
)
63 it
= new FlatStringReviter(str
)
70 it2
= new FlatStringIter(str
)
77 assert str
* 2 == str
+ str
85 var buf
= new FlatBuffer.from
(str
)
89 var bf
= new FlatBuffer.from
(str
)
95 var bf2
= new FlatBuffer.from
(str
)
97 bf2
.char_at
(0) = str
.char_at
(1)
98 bf2
.char_at
(1) = str
.char_at
(0)
100 for i
in [0 .. bf2
.length
[ do bf2
.char_at
(i
).output
106 for i
in [0 .. bf2
.length
[ do bf2
.char_at
(i
).output
112 for i
in [0 .. bf2
.length
[ do bf2
.char_at
(i
).output
118 for i
in [0 .. bf2
.length
[ do bf2
.char_at
(i
).output