From: Jean-Christophe Beaupré Date: Thu, 4 Dec 2014 18:53:01 +0000 (-0500) Subject: ropes: Reset everything when clearing. X-Git-Tag: v0.7~77^2~2 X-Git-Url: http://nitlanguage.org ropes: Reset everything when clearing. Signed-off-by: Jean-Christophe Beaupré --- diff --git a/lib/standard/ropes.nit b/lib/standard/ropes.nit index 12ad67e..db635d9 100644 --- a/lib/standard/ropes.nit +++ b/lib/standard/ropes.nit @@ -240,6 +240,7 @@ class RopeBuffer str = "" length = 0 rpos = 0 + dumped = 0 end redef fun substring(from, count) do diff --git a/tests/sav/test_ropes_buffer_clear.res b/tests/sav/test_ropes_buffer_clear.res new file mode 100644 index 0000000..951dbb9 --- /dev/null +++ b/tests/sav/test_ropes_buffer_clear.res @@ -0,0 +1,2 @@ +23 +3 diff --git a/tests/test_ropes_buffer_clear.nit b/tests/test_ropes_buffer_clear.nit new file mode 100644 index 0000000..eba364e --- /dev/null +++ b/tests/test_ropes_buffer_clear.nit @@ -0,0 +1,37 @@ +# This file is part of NIT ( http://www.nitlanguage.org ). +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# Checks if `RopeBuffer.clear` actually reset everything. +module test_ropes_buffer_clear + +import standard + +var buffer = new RopeBuffer + +buffer.append "1" +# Force to flush the internal buffer, so that all the internal positions will be +# set to a non-zero value. +buffer.append("?" * (maxlen + 1)) +buffer.clear +buffer.append "23" +print buffer + +buffer = new RopeBuffer +buffer.append "12" +# Force to flush the internal buffer, so that all the internal positions will be +# set to a non-zero value. +buffer.append("?" * (maxlen + 1)) +buffer.clear +buffer.append "3" +print buffer