From 1e1c34b0ed04924cfcd35988544111915e1ac28d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Christophe=20Beaupr=C3=A9?= Date: Thu, 4 Dec 2014 13:53:01 -0500 Subject: [PATCH] ropes: Reset everything when clearing. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jean-Christophe Beaupré --- lib/standard/ropes.nit | 1 + tests/sav/test_ropes_buffer_clear.res | 2 ++ tests/test_ropes_buffer_clear.nit | 37 +++++++++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 tests/sav/test_ropes_buffer_clear.res create mode 100644 tests/test_ropes_buffer_clear.nit 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 -- 1.7.9.5