From bbc0adda39a86858f153f8531c59466d218e394f Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Thu, 23 Jul 2015 11:14:36 -0400 Subject: [PATCH] tests: Updated for correct semantics, added new tests for Unicode Signed-off-by: Lucas Bajolet --- tests/bench_string_super.nit | 2 +- tests/bench_string_tos.nit | 2 +- tests/niti.skip | 1 + tests/nitvm.skip | 1 + tests/sav/error_class_glob.res | 4 +- tests/sav/example_objet.res | 18 +-- tests/sav/test_buffer_unicode.res | 266 ++++++++++++++++++++++++++++++++ tests/sav/test_buffer_unicode_alt1.res | 266 ++++++++++++++++++++++++++++++++ tests/sav/test_bufferedfilereader.res | 2 +- tests/sav/test_string_unicode.res | 8 +- tests/shootout_mandelbrot.nit | 12 +- tests/test_buffer_unicode.nit | 54 +++++++ 12 files changed, 611 insertions(+), 25 deletions(-) create mode 100644 tests/sav/test_buffer_unicode.res create mode 100644 tests/sav/test_buffer_unicode_alt1.res create mode 100644 tests/test_buffer_unicode.nit diff --git a/tests/bench_string_super.nit b/tests/bench_string_super.nit index c78f448..88b001a 100644 --- a/tests/bench_string_super.nit +++ b/tests/bench_string_super.nit @@ -23,4 +23,4 @@ while i < n do s = "Je dis «{s}» et redis «{s}» et trois fois de plus : «{s}{s}{s}».\n" i = i + 1 end -print(s.length) +print s.bytelen diff --git a/tests/bench_string_tos.nit b/tests/bench_string_tos.nit index a59c19e..f76b13a 100644 --- a/tests/bench_string_tos.nit +++ b/tests/bench_string_tos.nit @@ -23,4 +23,4 @@ while i < n do s = ["Je dis «", s, "» et redis «", s, "» et trois fois de plus : «", s, s, s, "».\n"].plain_to_s i = i + 1 end -print(s.length) +print(s.bytelen) diff --git a/tests/niti.skip b/tests/niti.skip index 5c4ff8a..9718dc3 100644 --- a/tests/niti.skip +++ b/tests/niti.skip @@ -28,3 +28,4 @@ blink input first_letter_last_letter fibonacci_word +shootout_nsieve diff --git a/tests/nitvm.skip b/tests/nitvm.skip index 5c4ff8a..9718dc3 100644 --- a/tests/nitvm.skip +++ b/tests/nitvm.skip @@ -28,3 +28,4 @@ blink input first_letter_last_letter fibonacci_word +shootout_nsieve diff --git a/tests/sav/error_class_glob.res b/tests/sav/error_class_glob.res index 3fe9caa..87aeaec 100644 --- a/tests/sav/error_class_glob.res +++ b/tests/sav/error_class_glob.res @@ -8,5 +8,5 @@ ../lib/standard/kernel.nit:333,1--415,3: Error: `kernel#Float` does not specialize `module_0#Object`. Possible duplication of the root class `Object`? ../lib/standard/kernel.nit:417,1--519,3: Error: `kernel#Byte` does not specialize `module_0#Object`. Possible duplication of the root class `Object`? ../lib/standard/kernel.nit:521,1--712,3: Error: `kernel#Int` does not specialize `module_0#Object`. Possible duplication of the root class `Object`? -../lib/standard/kernel.nit:714,1--854,3: Error: `kernel#Char` does not specialize `module_0#Object`. Possible duplication of the root class `Object`? -../lib/standard/kernel.nit:856,1--863,3: Error: `kernel#Pointer` does not specialize `module_0#Object`. Possible duplication of the root class `Object`? +../lib/standard/kernel.nit:714,1--867,3: Error: `kernel#Char` does not specialize `module_0#Object`. Possible duplication of the root class `Object`? +../lib/standard/kernel.nit:869,1--876,3: Error: `kernel#Pointer` does not specialize `module_0#Object`. Possible duplication of the root class `Object`? diff --git a/tests/sav/example_objet.res b/tests/sav/example_objet.res index 4154b82..ff5fc65 100644 --- a/tests/sav/example_objet.res +++ b/tests/sav/example_objet.res @@ -2,31 +2,31 @@ sans nom Montpellier -*** Entrepôt Lunel *** -L'entrepôt est vide +*** Entrep�t Lunel *** +L'entrep�t est vide Carotte:15 Carotte:20 -* Rayon : Légumes +* Rayon : L�gumes -* Rayon : Légumes +* Rayon : L�gumes Carotte:15 Navet:10 Chou:3 -* Rayon : Légumes +* Rayon : L�gumes Carotte:15 Navet:10 Chou:13 Courge:1 -*** Entrepôt Lunel *** -* Rayon : Légumes +*** Entrep�t Lunel *** +* Rayon : L�gumes Carotte:15 Navet:10 Chou:13 Courge:1 -* Rayon Réfrigéré : Surgelés - t° max : -5 +* Rayon R�frig�r� : Surgel�s - t� max : -5 Pizza:12 -Poisson pané:4 +Poisson pan�:4 diff --git a/tests/sav/test_buffer_unicode.res b/tests/sav/test_buffer_unicode.res new file mode 100644 index 0000000..08fb25a --- /dev/null +++ b/tests/sav/test_buffer_unicode.res @@ -0,0 +1,266 @@ +Char 0 = 𐏓 +Char 1 = A +Char 2 = A +Char 3 = A +Char 4 = A +Char 5 = A +Char 6 = A +Char 7 = A +Char 8 = A +Char 9 = A +Char 10 = A +Char 11 = A +Char 12 = A +Char 13 = A +Char 14 = A +Char 15 = A +Char 16 = A +Char 17 = A +Char 18 = A +Char 19 = A +Char 20 = A +Char 21 = A +Char 22 = A +Char 23 = A +Char 24 = A +Char 25 = A +Char 26 = A +Char 27 = A +Char 28 = A +Char 29 = A +Char 30 = A +Char 31 = A +Char 32 = Z +Char 33 = A +Char 34 = A +Char 35 = A +Char 36 = A +Char 37 = A +Char 38 = A +Char 39 = A +Char 40 = A +Char 41 = A +Char 42 = A +Char 43 = A +Char 44 = A +Char 45 = A +Char 46 = A +Char 47 = A +Char 48 = A +Char 49 = A +Char 50 = A +Char 51 = A +Char 52 = A +Char 53 = A +Char 54 = A +Char 55 = A +Char 56 = A +Char 57 = A +Char 58 = A +Char 59 = A +Char 60 = A +Char 61 = A +Char 62 = A +Char 63 = あ +Byte 0 = 0xf0 +Byte 1 = 0x90 +Byte 2 = 0x8f +Byte 3 = 0x93 +Byte 4 = 0x41 +Byte 5 = 0x41 +Byte 6 = 0x41 +Byte 7 = 0x41 +Byte 8 = 0x41 +Byte 9 = 0x41 +Byte 10 = 0x41 +Byte 11 = 0x41 +Byte 12 = 0x41 +Byte 13 = 0x41 +Byte 14 = 0x41 +Byte 15 = 0x41 +Byte 16 = 0x41 +Byte 17 = 0x41 +Byte 18 = 0x41 +Byte 19 = 0x41 +Byte 20 = 0x41 +Byte 21 = 0x41 +Byte 22 = 0x41 +Byte 23 = 0x41 +Byte 24 = 0x41 +Byte 25 = 0x41 +Byte 26 = 0x41 +Byte 27 = 0x41 +Byte 28 = 0x41 +Byte 29 = 0x41 +Byte 30 = 0x41 +Byte 31 = 0x41 +Byte 32 = 0x41 +Byte 33 = 0x41 +Byte 34 = 0x41 +Byte 35 = 0x5a +Byte 36 = 0x41 +Byte 37 = 0x41 +Byte 38 = 0x41 +Byte 39 = 0x41 +Byte 40 = 0x41 +Byte 41 = 0x41 +Byte 42 = 0x41 +Byte 43 = 0x41 +Byte 44 = 0x41 +Byte 45 = 0x41 +Byte 46 = 0x41 +Byte 47 = 0x41 +Byte 48 = 0x41 +Byte 49 = 0x41 +Byte 50 = 0x41 +Byte 51 = 0x41 +Byte 52 = 0x41 +Byte 53 = 0x41 +Byte 54 = 0x41 +Byte 55 = 0x41 +Byte 56 = 0x41 +Byte 57 = 0x41 +Byte 58 = 0x41 +Byte 59 = 0x41 +Byte 60 = 0x41 +Byte 61 = 0x41 +Byte 62 = 0x41 +Byte 63 = 0x41 +Byte 64 = 0x41 +Byte 65 = 0x41 +Byte 66 = 0xe3 +Byte 67 = 0x81 +Byte 68 = 0x82 +Char 63 = あ +Char 62 = A +Char 61 = A +Char 60 = A +Char 59 = A +Char 58 = A +Char 57 = A +Char 56 = A +Char 55 = A +Char 54 = A +Char 53 = A +Char 52 = A +Char 51 = A +Char 50 = A +Char 49 = A +Char 48 = A +Char 47 = A +Char 46 = A +Char 45 = A +Char 44 = A +Char 43 = A +Char 42 = A +Char 41 = A +Char 40 = A +Char 39 = A +Char 38 = A +Char 37 = A +Char 36 = A +Char 35 = A +Char 34 = A +Char 33 = A +Char 32 = Z +Char 31 = A +Char 30 = A +Char 29 = A +Char 28 = A +Char 27 = A +Char 26 = A +Char 25 = A +Char 24 = A +Char 23 = A +Char 22 = A +Char 21 = A +Char 20 = A +Char 19 = A +Char 18 = A +Char 17 = A +Char 16 = A +Char 15 = A +Char 14 = A +Char 13 = A +Char 12 = A +Char 11 = A +Char 10 = A +Char 9 = A +Char 8 = A +Char 7 = A +Char 6 = A +Char 5 = A +Char 4 = A +Char 3 = A +Char 2 = A +Char 1 = A +Char 0 = 𐏓 +Byte 68 = 0x82 +Byte 67 = 0x81 +Byte 66 = 0xe3 +Byte 65 = 0x41 +Byte 64 = 0x41 +Byte 63 = 0x41 +Byte 62 = 0x41 +Byte 61 = 0x41 +Byte 60 = 0x41 +Byte 59 = 0x41 +Byte 58 = 0x41 +Byte 57 = 0x41 +Byte 56 = 0x41 +Byte 55 = 0x41 +Byte 54 = 0x41 +Byte 53 = 0x41 +Byte 52 = 0x41 +Byte 51 = 0x41 +Byte 50 = 0x41 +Byte 49 = 0x41 +Byte 48 = 0x41 +Byte 47 = 0x41 +Byte 46 = 0x41 +Byte 45 = 0x41 +Byte 44 = 0x41 +Byte 43 = 0x41 +Byte 42 = 0x41 +Byte 41 = 0x41 +Byte 40 = 0x41 +Byte 39 = 0x41 +Byte 38 = 0x41 +Byte 37 = 0x41 +Byte 36 = 0x41 +Byte 35 = 0x5a +Byte 34 = 0x41 +Byte 33 = 0x41 +Byte 32 = 0x41 +Byte 31 = 0x41 +Byte 30 = 0x41 +Byte 29 = 0x41 +Byte 28 = 0x41 +Byte 27 = 0x41 +Byte 26 = 0x41 +Byte 25 = 0x41 +Byte 24 = 0x41 +Byte 23 = 0x41 +Byte 22 = 0x41 +Byte 21 = 0x41 +Byte 20 = 0x41 +Byte 19 = 0x41 +Byte 18 = 0x41 +Byte 17 = 0x41 +Byte 16 = 0x41 +Byte 15 = 0x41 +Byte 14 = 0x41 +Byte 13 = 0x41 +Byte 12 = 0x41 +Byte 11 = 0x41 +Byte 10 = 0x41 +Byte 9 = 0x41 +Byte 8 = 0x41 +Byte 7 = 0x41 +Byte 6 = 0x41 +Byte 5 = 0x41 +Byte 4 = 0x41 +Byte 3 = 0x93 +Byte 2 = 0x8f +Byte 1 = 0x90 +Byte 0 = 0xf0 diff --git a/tests/sav/test_buffer_unicode_alt1.res b/tests/sav/test_buffer_unicode_alt1.res new file mode 100644 index 0000000..08fb25a --- /dev/null +++ b/tests/sav/test_buffer_unicode_alt1.res @@ -0,0 +1,266 @@ +Char 0 = 𐏓 +Char 1 = A +Char 2 = A +Char 3 = A +Char 4 = A +Char 5 = A +Char 6 = A +Char 7 = A +Char 8 = A +Char 9 = A +Char 10 = A +Char 11 = A +Char 12 = A +Char 13 = A +Char 14 = A +Char 15 = A +Char 16 = A +Char 17 = A +Char 18 = A +Char 19 = A +Char 20 = A +Char 21 = A +Char 22 = A +Char 23 = A +Char 24 = A +Char 25 = A +Char 26 = A +Char 27 = A +Char 28 = A +Char 29 = A +Char 30 = A +Char 31 = A +Char 32 = Z +Char 33 = A +Char 34 = A +Char 35 = A +Char 36 = A +Char 37 = A +Char 38 = A +Char 39 = A +Char 40 = A +Char 41 = A +Char 42 = A +Char 43 = A +Char 44 = A +Char 45 = A +Char 46 = A +Char 47 = A +Char 48 = A +Char 49 = A +Char 50 = A +Char 51 = A +Char 52 = A +Char 53 = A +Char 54 = A +Char 55 = A +Char 56 = A +Char 57 = A +Char 58 = A +Char 59 = A +Char 60 = A +Char 61 = A +Char 62 = A +Char 63 = あ +Byte 0 = 0xf0 +Byte 1 = 0x90 +Byte 2 = 0x8f +Byte 3 = 0x93 +Byte 4 = 0x41 +Byte 5 = 0x41 +Byte 6 = 0x41 +Byte 7 = 0x41 +Byte 8 = 0x41 +Byte 9 = 0x41 +Byte 10 = 0x41 +Byte 11 = 0x41 +Byte 12 = 0x41 +Byte 13 = 0x41 +Byte 14 = 0x41 +Byte 15 = 0x41 +Byte 16 = 0x41 +Byte 17 = 0x41 +Byte 18 = 0x41 +Byte 19 = 0x41 +Byte 20 = 0x41 +Byte 21 = 0x41 +Byte 22 = 0x41 +Byte 23 = 0x41 +Byte 24 = 0x41 +Byte 25 = 0x41 +Byte 26 = 0x41 +Byte 27 = 0x41 +Byte 28 = 0x41 +Byte 29 = 0x41 +Byte 30 = 0x41 +Byte 31 = 0x41 +Byte 32 = 0x41 +Byte 33 = 0x41 +Byte 34 = 0x41 +Byte 35 = 0x5a +Byte 36 = 0x41 +Byte 37 = 0x41 +Byte 38 = 0x41 +Byte 39 = 0x41 +Byte 40 = 0x41 +Byte 41 = 0x41 +Byte 42 = 0x41 +Byte 43 = 0x41 +Byte 44 = 0x41 +Byte 45 = 0x41 +Byte 46 = 0x41 +Byte 47 = 0x41 +Byte 48 = 0x41 +Byte 49 = 0x41 +Byte 50 = 0x41 +Byte 51 = 0x41 +Byte 52 = 0x41 +Byte 53 = 0x41 +Byte 54 = 0x41 +Byte 55 = 0x41 +Byte 56 = 0x41 +Byte 57 = 0x41 +Byte 58 = 0x41 +Byte 59 = 0x41 +Byte 60 = 0x41 +Byte 61 = 0x41 +Byte 62 = 0x41 +Byte 63 = 0x41 +Byte 64 = 0x41 +Byte 65 = 0x41 +Byte 66 = 0xe3 +Byte 67 = 0x81 +Byte 68 = 0x82 +Char 63 = あ +Char 62 = A +Char 61 = A +Char 60 = A +Char 59 = A +Char 58 = A +Char 57 = A +Char 56 = A +Char 55 = A +Char 54 = A +Char 53 = A +Char 52 = A +Char 51 = A +Char 50 = A +Char 49 = A +Char 48 = A +Char 47 = A +Char 46 = A +Char 45 = A +Char 44 = A +Char 43 = A +Char 42 = A +Char 41 = A +Char 40 = A +Char 39 = A +Char 38 = A +Char 37 = A +Char 36 = A +Char 35 = A +Char 34 = A +Char 33 = A +Char 32 = Z +Char 31 = A +Char 30 = A +Char 29 = A +Char 28 = A +Char 27 = A +Char 26 = A +Char 25 = A +Char 24 = A +Char 23 = A +Char 22 = A +Char 21 = A +Char 20 = A +Char 19 = A +Char 18 = A +Char 17 = A +Char 16 = A +Char 15 = A +Char 14 = A +Char 13 = A +Char 12 = A +Char 11 = A +Char 10 = A +Char 9 = A +Char 8 = A +Char 7 = A +Char 6 = A +Char 5 = A +Char 4 = A +Char 3 = A +Char 2 = A +Char 1 = A +Char 0 = 𐏓 +Byte 68 = 0x82 +Byte 67 = 0x81 +Byte 66 = 0xe3 +Byte 65 = 0x41 +Byte 64 = 0x41 +Byte 63 = 0x41 +Byte 62 = 0x41 +Byte 61 = 0x41 +Byte 60 = 0x41 +Byte 59 = 0x41 +Byte 58 = 0x41 +Byte 57 = 0x41 +Byte 56 = 0x41 +Byte 55 = 0x41 +Byte 54 = 0x41 +Byte 53 = 0x41 +Byte 52 = 0x41 +Byte 51 = 0x41 +Byte 50 = 0x41 +Byte 49 = 0x41 +Byte 48 = 0x41 +Byte 47 = 0x41 +Byte 46 = 0x41 +Byte 45 = 0x41 +Byte 44 = 0x41 +Byte 43 = 0x41 +Byte 42 = 0x41 +Byte 41 = 0x41 +Byte 40 = 0x41 +Byte 39 = 0x41 +Byte 38 = 0x41 +Byte 37 = 0x41 +Byte 36 = 0x41 +Byte 35 = 0x5a +Byte 34 = 0x41 +Byte 33 = 0x41 +Byte 32 = 0x41 +Byte 31 = 0x41 +Byte 30 = 0x41 +Byte 29 = 0x41 +Byte 28 = 0x41 +Byte 27 = 0x41 +Byte 26 = 0x41 +Byte 25 = 0x41 +Byte 24 = 0x41 +Byte 23 = 0x41 +Byte 22 = 0x41 +Byte 21 = 0x41 +Byte 20 = 0x41 +Byte 19 = 0x41 +Byte 18 = 0x41 +Byte 17 = 0x41 +Byte 16 = 0x41 +Byte 15 = 0x41 +Byte 14 = 0x41 +Byte 13 = 0x41 +Byte 12 = 0x41 +Byte 11 = 0x41 +Byte 10 = 0x41 +Byte 9 = 0x41 +Byte 8 = 0x41 +Byte 7 = 0x41 +Byte 6 = 0x41 +Byte 5 = 0x41 +Byte 4 = 0x41 +Byte 3 = 0x93 +Byte 2 = 0x8f +Byte 1 = 0x90 +Byte 0 = 0xf0 diff --git a/tests/sav/test_bufferedfilereader.res b/tests/sav/test_bufferedfilereader.res index 3c68ca8..a66aa39 100644 --- a/tests/sav/test_bufferedfilereader.res +++ b/tests/sav/test_bufferedfilereader.res @@ -23,7 +23,7 @@ Read 4 chars: 3 Al Read 4 chars: exis Read 4 chars: Laf Read 4 chars: erri -Read 4 chars: ère +Read 3 chars: ère Read 4 chars: limit*limit then byte_acc = (byte_acc.lshift(1)) else - byte_acc = (byte_acc.lshift(1)) + 1 + byte_acc = (byte_acc.lshift(1)) + 1u8 end bit_num = bit_num + 1 if bit_num == 8 then - printn(byte_acc.ascii) - byte_acc = 0 + stdout.write_byte(byte_acc) + byte_acc = 0u8 bit_num = 0 else if x == w - 1 then byte_acc = byte_acc.lshift(8-w%8) - printn(byte_acc.ascii) - byte_acc = 0 + stdout.write_byte(byte_acc) + byte_acc = 0u8 bit_num = 0 end end diff --git a/tests/test_buffer_unicode.nit b/tests/test_buffer_unicode.nit new file mode 100644 index 0000000..f76ac5f --- /dev/null +++ b/tests/test_buffer_unicode.nit @@ -0,0 +1,54 @@ +# 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. + +var fb: Buffer = new RopeBuffer +#alt1 fb = new FlatBuffer + +for i in [0 .. 64[ do fb.add 'A' + +fb[63] = 'あ' + +fb[32] = 'き' + +fb[0] = '𐏓' + +fb[32] = 'Z' + +var l = 0 + +for i in fb.chars do + print "Char {l} = {i}" + l += 1 +end + +l = 0 + +for i in fb.bytes do + print "Byte {l} = {i}" + l += 1 +end + +l = fb.length - 1 + +for i in fb.chars.reverse_iterator do + print "Char {l} = {i}" + l -= 1 +end + +l = fb.bytelen - 1 + +for i in fb.bytes.reverse_iterator do + print "Byte {l} = {i}" + l -= 1 +end -- 1.7.9.5