1 # This file is part of NIT ( http://www.nitlanguage.org ).
3 # Licensed under the Apache License, Version 2.0 (the "License");
4 # you may not use this file except in compliance with the License.
5 # You may obtain a copy of the License at
7 # http://www.apache.org/licenses/LICENSE-2.0
9 # Unless required by applicable law or agreed to in writing, software
10 # distributed under the License is distributed on an "AS IS" BASIS,
11 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 # See the License for the specific language governing permissions and
13 # limitations under the License.
15 # Checks the immutability of the strings returned by `RopeBuffer.to_s`.
16 module test_ropes_buffer_to_s
20 # Note: In this sort of test, never print the string more than once: the string
21 # itself may cache an flatten representation of itself when `print` calls `to_s`
22 # on it. For example, the original bug that motivated the writting of the
23 # present test got unoticed until we tried to edit the buffer **before**
26 var buffer
= new RopeBuffer
29 sys
.stdout
.write
"`clear` and `append`: "
36 sys
.stdout
.write
"`clear` and `add`: "
45 sys
.stdout
.write
"`add` at `maxlen + 1`: "
49 buffer
.append
("*" * (maxlen
-1))
53 sys
.stdout
.write
"`append` up to `maxlen + 1`: "
57 buffer
.append
("*" * (maxlen
-1))
60 sys
.stdout
.write
"`reverse`: "
67 sys
.stdout
.write
"`upper`: "
74 sys
.stdout
.write
"`lower`: "