From b214234e1c55374827470bd1d75f8102440d4b39 Mon Sep 17 00:00:00 2001 From: Lucas Bajolet Date: Wed, 8 Jul 2015 16:46:32 -0400 Subject: [PATCH] tests: Update for new NativeString and Byte views Signed-off-by: Lucas Bajolet --- tests/sav/nitce/test_new_native.res | 2 +- tests/sav/nitce/test_new_native_alt1.res | 2 +- tests/sav/nitpick_args1.res | 6 ++-- tests/sav/test_binary.res | 2 +- tests/sav/test_binary_alt1.res | 2 +- tests/sav/test_binary_alt2.res | 2 +- tests/sav/test_binary_alt3.res | 2 +- tests/sav/test_new_native.res | 2 +- tests/sav/test_new_native_alt1.res | 2 +- tests/sav/test_string_bytes.res | 12 +++++++ tests/test_binary.nit | 2 +- tests/test_new_native.nit | 8 ++--- tests/test_string_bytes.nit | 51 ++++++++++++++++++++++++++++++ 13 files changed, 79 insertions(+), 16 deletions(-) create mode 100644 tests/sav/test_string_bytes.res create mode 100644 tests/test_string_bytes.nit diff --git a/tests/sav/nitce/test_new_native.res b/tests/sav/nitce/test_new_native.res index 44b504c..825c7f5 100644 --- a/tests/sav/nitce/test_new_native.res +++ b/tests/sav/nitce/test_new_native.res @@ -1,5 +1,5 @@ NativeString -N +0x4e Nit NativeArray 3 diff --git a/tests/sav/nitce/test_new_native_alt1.res b/tests/sav/nitce/test_new_native_alt1.res index cf6635c..0b4d438 100644 --- a/tests/sav/nitce/test_new_native_alt1.res +++ b/tests/sav/nitce/test_new_native_alt1.res @@ -1,5 +1,5 @@ NativeString -N +0x4e Nit NativeArray 3 diff --git a/tests/sav/nitpick_args1.res b/tests/sav/nitpick_args1.res index b79b2fc..6e97e37 100644 --- a/tests/sav/nitpick_args1.res +++ b/tests/sav/nitpick_args1.res @@ -1,6 +1,6 @@ -../lib/standard/bytes.nit:51,7--19: Documentation warning: Undocumented property `with_capacity` -../lib/standard/bytes.nit:164,6--13: Documentation warning: Undocumented property `to_bytes` -../lib/standard/stream.nit:425,6--17: Documentation warning: Undocumented property `buffer_reset` +../lib/standard/bytes.nit:49,7--19: Documentation warning: Undocumented property `with_capacity` +../lib/standard/bytes.nit:162,6--13: Documentation warning: Undocumented property `to_bytes` +../lib/standard/stream.nit:426,6--17: Documentation warning: Undocumented property `buffer_reset` ../lib/standard/file.nit:455,6--19: Documentation warning: Undocumented property `read_all_bytes` test_advice_repeated_types.nit:36,15--20: Warning: useless type repetition on redefined attribute `_a` test_advice_repeated_types.nit:37,18--20: Warning: useless type repetition on parameter `b1` for redefined method `b` diff --git a/tests/sav/test_binary.res b/tests/sav/test_binary.res index f071d47..887631f 100644 --- a/tests/sav/test_binary.res +++ b/tests/sav/test_binary.res @@ -1,6 +1,6 @@ no error hello -77 +0x4d 1.235 1.235 123456789 diff --git a/tests/sav/test_binary_alt1.res b/tests/sav/test_binary_alt1.res index eb0468f..832041b 100644 --- a/tests/sav/test_binary_alt1.res +++ b/tests/sav/test_binary_alt1.res @@ -1,6 +1,6 @@ no error hello -77 +0x4d 144545136640.0 0.0 1571011930645069824 diff --git a/tests/sav/test_binary_alt2.res b/tests/sav/test_binary_alt2.res index eb0468f..832041b 100644 --- a/tests/sav/test_binary_alt2.res +++ b/tests/sav/test_binary_alt2.res @@ -1,6 +1,6 @@ no error hello -77 +0x4d 144545136640.0 0.0 1571011930645069824 diff --git a/tests/sav/test_binary_alt3.res b/tests/sav/test_binary_alt3.res index f071d47..887631f 100644 --- a/tests/sav/test_binary_alt3.res +++ b/tests/sav/test_binary_alt3.res @@ -1,6 +1,6 @@ no error hello -77 +0x4d 1.235 1.235 123456789 diff --git a/tests/sav/test_new_native.res b/tests/sav/test_new_native.res index 060a759..3bc3c92 100644 --- a/tests/sav/test_new_native.res +++ b/tests/sav/test_new_native.res @@ -1,5 +1,5 @@ NativeString -N +0x4e Nit NativeArray[Int] 3 diff --git a/tests/sav/test_new_native_alt1.res b/tests/sav/test_new_native_alt1.res index 209563a..7d3c3bb 100644 --- a/tests/sav/test_new_native_alt1.res +++ b/tests/sav/test_new_native_alt1.res @@ -1,4 +1,4 @@ Runtime error: Cast failed. Expected `E`, got `Bool` (../lib/standard/collection/array.nit:957) NativeString -N +0x4e Nit diff --git a/tests/sav/test_string_bytes.res b/tests/sav/test_string_bytes.res new file mode 100644 index 0000000..8d98756 --- /dev/null +++ b/tests/sav/test_string_bytes.res @@ -0,0 +1,12 @@ +[0x54,0x68,0x69,0x73,0x20,0x73,0x74,0x72,0x69,0x6e,0x67,0x20,0x69,0x73,0x20,0x63,0x6f,0x6f,0x6c] +[0x54,0x68,0x69,0x73,0x20,0x73,0x74,0x72,0x69,0x6e,0x67,0x20,0x69,0x73,0x20,0x63,0x6f,0x6f,0x6c,0x54,0x68,0x69,0x73,0x20,0x73,0x74,0x72,0x69,0x6e,0x67,0x20,0x69,0x73,0x20,0x63,0x6f,0x6f,0x6c,0x54,0x68,0x69,0x73,0x20,0x73,0x74,0x72,0x69,0x6e,0x67,0x20,0x69,0x73,0x20,0x63,0x6f,0x6f,0x6c,0x54,0x68,0x69,0x73,0x20,0x73,0x74,0x72,0x69,0x6e,0x67,0x20,0x69,0x73,0x20,0x63,0x6f,0x6f,0x6c] +[0x54,0x68,0x69,0x73,0x20,0x73,0x74,0x72,0x69,0x6e,0x67,0x20,0x69,0x73,0x20,0x63,0x6f,0x6f,0x6c,0x54,0x68,0x69,0x73,0x20,0x73,0x74,0x72,0x69,0x6e,0x67,0x20,0x69,0x73,0x20,0x63,0x6f,0x6f,0x6c,0x54,0x68,0x69,0x73,0x20,0x73,0x74,0x72,0x69,0x6e,0x67,0x20,0x69,0x73,0x20,0x63,0x6f,0x6f,0x6c,0x54,0x68,0x69,0x73,0x20,0x73,0x74,0x72,0x69,0x6e,0x67,0x20,0x69,0x73,0x20,0x63,0x6f,0x6f,0x6c] +[0x6c,0x6f,0x6f,0x63,0x20,0x73,0x69,0x20,0x67,0x6e,0x69,0x72,0x74,0x73,0x20,0x73,0x69,0x68,0x54] +[0x6c,0x6f,0x6f,0x63,0x20,0x73,0x69,0x20,0x67,0x6e,0x69,0x72,0x74,0x73,0x20,0x73,0x69,0x68,0x54,0x6c,0x6f,0x6f,0x63,0x20,0x73,0x69,0x20,0x67,0x6e,0x69,0x72,0x74,0x73,0x20,0x73,0x69,0x68,0x54,0x6c,0x6f,0x6f,0x63,0x20,0x73,0x69,0x20,0x67,0x6e,0x69,0x72,0x74,0x73,0x20,0x73,0x69,0x68,0x54,0x6c,0x6f,0x6f,0x63,0x20,0x73,0x69,0x20,0x67,0x6e,0x69,0x72,0x74,0x73,0x20,0x73,0x69,0x68,0x54] +[0x6c,0x6f,0x6f,0x63,0x20,0x73,0x69,0x20,0x67,0x6e,0x69,0x72,0x74,0x73,0x20,0x73,0x69,0x68,0x54,0x6c,0x6f,0x6f,0x63,0x20,0x73,0x69,0x20,0x67,0x6e,0x69,0x72,0x74,0x73,0x20,0x73,0x69,0x68,0x54,0x6c,0x6f,0x6f,0x63,0x20,0x73,0x69,0x20,0x67,0x6e,0x69,0x72,0x74,0x73,0x20,0x73,0x69,0x68,0x54,0x6c,0x6f,0x6f,0x63,0x20,0x73,0x69,0x20,0x67,0x6e,0x69,0x72,0x74,0x73,0x20,0x73,0x69,0x68,0x54] +This string is cool +This string is coolA +Ahis string is coolA +This string is cool +This string is coolA +Ahis string is coolA diff --git a/tests/test_binary.nit b/tests/test_binary.nit index a38619b..3af2fd6 100644 --- a/tests/test_binary.nit +++ b/tests/test_binary.nit @@ -19,7 +19,7 @@ var writer = new FileWriter.open(path) #alt1# writer.big_endian = false #alt3# writer.big_endian = false writer.write "hello" -writer.write_byte 77 +writer.write_byte 77u8 writer.write_float 1.23456789 writer.write_double 1.23456789 writer.write_int64 123456789 diff --git a/tests/test_new_native.nit b/tests/test_new_native.nit index c1ecc49..28facde 100644 --- a/tests/test_new_native.nit +++ b/tests/test_new_native.nit @@ -13,10 +13,10 @@ # limitations under the License. var s = new NativeString(4) -s[0] = 'N' -s[2] = 't' -s[1] = 'i' -s[3] = '\0' +s[0] = 0x4Eu8 +s[2] = 0x74u8 +s[1] = 0x69u8 +s[3] = 0u8 print s.class_name print s[0] print s.to_s diff --git a/tests/test_string_bytes.nit b/tests/test_string_bytes.nit new file mode 100644 index 0000000..875f5dc --- /dev/null +++ b/tests/test_string_bytes.nit @@ -0,0 +1,51 @@ +# 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 x = "This string is cool" + +var y = x + x + x + x + +var z = x * 4 + +print x.bytes.iterator.to_a +print y.bytes.iterator.to_a +print z.bytes.iterator.to_a + +print x.bytes.reverse_iterator.to_a +print y.bytes.reverse_iterator.to_a +print z.bytes.reverse_iterator.to_a + +var b = new FlatBuffer.from(x) + +print b + +b.bytes.add 0x41u8 + +print b + +b.bytes[0] = 0x41u8 + +print b + +var c = new RopeBuffer.from(x) + +print c + +c.bytes.add 0x41u8 + +print c + +c.bytes[0] = 0x41u8 + +print c -- 1.7.9.5