From 1bcc9629a8058dc7a066ab363cc0241286b8b1bf Mon Sep 17 00:00:00 2001 From: =?utf8?q?Jean-Christophe=20Beaupr=C3=A9?= Date: Sun, 7 Dec 2014 01:02:47 -0500 Subject: [PATCH] ropes: Fix `RopeBuffer.reset`. 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_to_s.res | 3 +++ tests/test_ropes_buffer_to_s.nit | 21 +++++++++++++++++++++ 3 files changed, 25 insertions(+) diff --git a/lib/standard/ropes.nit b/lib/standard/ropes.nit index 8d2d057..d7bc8e8 100644 --- a/lib/standard/ropes.nit +++ b/lib/standard/ropes.nit @@ -229,6 +229,7 @@ class RopeBuffer var nns = new NativeString(buf_size) var blen = rpos - dumped ns.copy_to(nns, blen, dumped, 0) + ns = nns dumped = 0 rpos = blen written = false diff --git a/tests/sav/test_ropes_buffer_to_s.res b/tests/sav/test_ropes_buffer_to_s.res index 0bf725e..5bff6e1 100644 --- a/tests/sav/test_ropes_buffer_to_s.res +++ b/tests/sav/test_ropes_buffer_to_s.res @@ -2,3 +2,6 @@ `clear` and `add`: ab `add` at `maxlen + 1`: c `append` up to `maxlen + 1`: ab +`reverse`: xyz +`upper`: foo +`lower`: BAR diff --git a/tests/test_ropes_buffer_to_s.nit b/tests/test_ropes_buffer_to_s.nit index 4933a1b..cc8eb4f 100644 --- a/tests/test_ropes_buffer_to_s.nit +++ b/tests/test_ropes_buffer_to_s.nit @@ -56,3 +56,24 @@ buffer.append "ab" s = buffer.to_s buffer.append("*" * (maxlen -1)) print s + +sys.stdout.write "`reverse`: " +buffer.clear +buffer.append "xyz" +s = buffer.to_s +buffer.reverse +print s + +sys.stdout.write "`upper`: " +buffer.clear +buffer.append "foo" +s = buffer.to_s +buffer.upper +print s + +sys.stdout.write "`lower`: " +buffer.clear +buffer.append "BAR" +s = buffer.to_s +buffer.lower +print s -- 1.7.9.5