tests: update to use `CString`
authorAlexis Laferrière <alexis.laf@xymus.net>
Tue, 13 Dec 2016 04:02:45 +0000 (23:02 -0500)
committerAlexis Laferrière <alexis.laf@xymus.net>
Tue, 13 Dec 2016 04:05:07 +0000 (23:05 -0500)
Signed-off-by: Alexis Laferrière <alexis.laf@xymus.net>

27 files changed:
tests/base_test_obj_id.nit
tests/error_needed_method.nit
tests/sav/error_needed_method_alt3.res
tests/sav/nitce/test_new_native.res
tests/sav/nitce/test_new_native_alt1.res
tests/sav/niti/error_needed_method_alt4.res
tests/sav/nitj/test_new_native.res
tests/sav/nitj/test_new_native_alt1.res
tests/sav/nitpretty_args21.res
tests/sav/nitpretty_args52.res
tests/sav/string_ffi_ref_test.res
tests/sav/test_new_native.res
tests/sav/test_new_native_alt1.res
tests/shootout_nsieve_bytes_alt.nit
tests/string_ffi_ref_test.nit
tests/test_copy_to_native.nit
tests/test_ffi_c_accessor.nit
tests/test_ffi_c_callback_extern_receiver.nit
tests/test_ffi_c_more.nit
tests/test_ffi_c_new_extern.nit
tests/test_ffi_c_primitives.nit
tests/test_ffi_c_strings.nit
tests/test_ffi_c_super.nit
tests/test_hash_text.nit
tests/test_nativestring_fill_from.nit
tests/test_new_native.nit
tests/test_pretty/test_extern1.nit

index cf467d0..5c70cb9 100644 (file)
@@ -26,5 +26,5 @@ assert 'd'.object_id.to_s.is_numeric
 # Check Float.object_id
 assert 1.0.object_id.to_s.is_numeric
 
-# Check NativeString.object_id
+# Check CString.object_id
 assert "Test".as(FlatString).items.object_id.to_s.is_numeric
index c78ec94..eea217f 100644 (file)
@@ -32,7 +32,7 @@ end
 class String
 end
 
-enum NativeString
+enum CString
 end
 
 class Array[E]
index f06d6c6..60df1cb 100644 (file)
@@ -1 +1 @@
-alt/error_needed_method_alt3.nit:48,9--13: Fatal Error: `NativeString` must have a property named `to_s_full`.
+alt/error_needed_method_alt3.nit:48,9--13: Fatal Error: `CString` must have a property named `to_s_full`.
index 5b1731b..b1bbd91 100644 (file)
@@ -1 +1 @@
-alt/error_needed_method_alt4.nit:49,10--14: Fatal Error: `NativeString` must have a property named `to_s_full`.
+alt/error_needed_method_alt4.nit:49,10--14: Fatal Error: `CString` must have a property named `to_s_full`.
index ef5a694..3182a71 100644 (file)
@@ -70,8 +70,8 @@ extern class TimeT `{time_t`}
        new from_i(i: Int) `{ return i; `}
        fun update `{ time(&self); `}
 
-       fun ctime: String import NativeString.to_s_with_copy `{
-               return NativeString_to_s_with_copy( ctime(&self) );
+       fun ctime: String import CString.to_s_with_copy `{
+               return CString_to_s_with_copy( ctime(&self) );
        `}
 
        # Difference in secondes from start (self if the end time)
index 33a3bfe..94f2a3a 100644 (file)
@@ -71,8 +71,8 @@ extern class TimeT `{time_t`}
 
        fun update `{ time(&self); `}
 
-       fun ctime: String import NativeString.to_s_with_copy `{
-               return NativeString_to_s_with_copy( ctime(&self) );
+       fun ctime: String import CString.to_s_with_copy `{
+               return CString_to_s_with_copy( ctime(&self) );
        `}
 
        # Difference in secondes from start (self if the end time)
index e9856d5..b018ff9 100644 (file)
@@ -1,3 +1,3 @@
 This is a test string
 This is a test string
-Do the strings have the same NativeString reference ? False
+Do the strings have the same CString reference ? False
index 3bc3c92..02b60bc 100644 (file)
@@ -1,4 +1,4 @@
-NativeString
+CString
 0x4e
 Nit
 NativeArray[Int]
index 38c4890..c36446c 100644 (file)
@@ -1,4 +1,4 @@
 Runtime error: Cast failed. Expected `E`, got `Bool` (../lib/core/collection/array.nit:991)
-NativeString
+CString
 0x4e
 Nit
index b5ad0cb..6a05c79 100644 (file)
@@ -39,7 +39,7 @@ fun nsieve(n: Int): Int
 do
        var count = 0
        var b_arrsz = ((n - 1).to_f / 8.0).ceil.to_i
-       var bitarr = new Bitarray(new Bytes(new NativeString(b_arrsz), b_arrsz, b_arrsz))
+       var bitarr = new Bitarray(new Bytes(new CString(b_arrsz), b_arrsz, b_arrsz))
        for i in [2 .. n[ do
                # If self is already false, then no need to check for multiples
                if not bitarr[i] then continue
index 1e28c3c..18b98b7 100644 (file)
@@ -25,18 +25,18 @@ class StringTest
 
        var referenced_str: nullable String = null
 
-       fun get_c_string import FlatString.items, NativeString.to_s, NativeString.to_s_with_copy, StringTest.ref_test, StringTest.copy_test `{
+       fun get_c_string import FlatString.items, CString.to_s, CString.to_s_with_copy, StringTest.ref_test, StringTest.copy_test `{
                char* string = "This is a test string";
 
-               FlatString ref_string = NativeString_to_s(string);
+               FlatString ref_string = CString_to_s(string);
                StringTest_ref_test(self, ref_string);
 
-               FlatString copy_string = NativeString_to_s_with_copy(string);
+               FlatString copy_string = CString_to_s_with_copy(string);
                StringTest_copy_test(self, copy_string);
 
                int same_refs = FlatString_items(copy_string) == FlatString_items(ref_string);
 
-               printf("Do the strings have the same NativeString reference ? ");
+               printf("Do the strings have the same CString reference ? ");
 
                if(same_refs){
                        printf("True\n");
index 0018f1d..f7ab36f 100644 (file)
@@ -16,7 +16,7 @@ import core
 #alt1 intrude import core::text::ropes
 #alt2 intrude import core::text::ropes
 
-var ons = new NativeString(9)
+var ons = new CString(9)
 var base_str = "%Dégâštr"
 
 var str: String = base_str
index 71634fd..93d6491 100644 (file)
@@ -24,16 +24,16 @@ class A
                        String_to_cstring( A_r( self ) ),
                        String_to_cstring( A_rw( self ) ) );
        `}
-       fun modify import NativeString.to_s, w=, rw= `{
-               A_w__assign( self, NativeString_to_s( "w set from native" ) );
-               A_rw__assign( self, NativeString_to_s( "rw set from native" ) );
+       fun modify import CString.to_s, w=, rw= `{
+               A_w__assign( self, CString_to_s( "w set from native" ) );
+               A_rw__assign( self, CString_to_s( "rw set from native" ) );
        `}
 end
 
 class B
-       fun print_and_modify( a : A ) import A.rw, A.rw=, String.to_cstring, NativeString.to_s `{
+       fun print_and_modify( a : A ) import A.rw, A.rw=, String.to_cstring, CString.to_s `{
                printf( "%s\n", String_to_cstring( A_rw( a ) ) );
-               A_rw__assign( a, NativeString_to_s( "set from native" ) );
+               A_rw__assign( a, CString_to_s( "set from native" ) );
                printf( "%s\n", String_to_cstring( A_rw( a ) ) );
        `}
 end
index 7e05520..5fc1a52 100644 (file)
@@ -29,11 +29,11 @@ extern class Test
         return foobar;
     `}
 
-    fun test_me is extern import Test.foo, NativeString.to_s `{
+    fun test_me is extern import Test.foo, CString.to_s `{
         int i;
         for(i = 0; i < 2000; ++i) {
             printf("%d\n", i);
-            Test_foo(self, NativeString_to_s("asdf"));
+            Test_foo(self, CString_to_s("asdf"));
         }
     `}
 
index 24d152d..9dcf6db 100644 (file)
@@ -38,8 +38,8 @@ extern class A
 
        fun m : Int is extern `{ return 10; `}
 
-       fun n : String is extern import NativeString.to_s `{
-               return NativeString_to_s( "allo" );
+       fun n : String is extern import CString.to_s `{
+               return CString_to_s( "allo" );
        `}
 
        fun o ( str : String ) is extern import String.to_cstring `{
index 5181198..da5c83c 100644 (file)
@@ -23,11 +23,11 @@ extern class IntPtr `{ int* `}
                return r;
        `}
 
-       redef fun to_s import NativeString, NativeString.to_s `{
+       redef fun to_s import CString, CString.to_s `{
                int len = snprintf(NULL, 0, "%d", *self) + 1;
-               char *c = new_NativeString(len);
+               char *c = new_CString(len);
                sprintf(c, "%d", *self);
-               return NativeString_to_s(c);
+               return CString_to_s(c);
        `}
 end
 
index 2295927..c3244c8 100644 (file)
@@ -32,7 +32,7 @@ fun plus_0x10(v: Byte): Byte `{
        return v + 0x10;
 `}
 
-fun print_ns(s: NativeString) `{
+fun print_ns(s: CString) `{
        printf("%s\n", s);
 `}
 
index e4d3fe2..3da9b4b 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-fun print_cstring(cstr: NativeString) `{
+fun print_cstring(cstr: CString) `{
        printf("cstr-> %s\n", cstr);
 `}
 
-fun get_cstring: NativeString `{
+fun get_cstring: CString `{
        return "char* from C";
 `}
 
@@ -26,8 +26,8 @@ fun print_string(str: String) import String.to_cstring `{
        printf("str-> %s\n", String_to_cstring(str) );
 `}
 
-fun get_string: String import NativeString.to_s, String.output `{
-       String str = NativeString_to_s("Nit string from C");
+fun get_string: String import CString.to_s, String.output `{
+       String str = CString_to_s("Nit string from C");
        String_output(str);
        printf("\n");
        return str;
index e3052cf..1353325 100644 (file)
@@ -21,7 +21,7 @@ end
 class B
        super A
 
-       redef fun id : String import super, NativeString.to_s, String.to_cstring `{
+       redef fun id : String import super, CString.to_s, String.to_cstring `{
                char *new_name;
                char *prefix = "B special ";
                char *super_name = String_to_cstring( B_id___super( self ) );
@@ -31,7 +31,7 @@ class B
                strcpy( new_name+strlen( prefix ), super_name );
                new_name[ strlen( prefix )+strlen( super_name ) ] = '\0';
 
-               return NativeString_to_s( new_name );
+               return CString_to_s( new_name );
        `}
 end
 
index 39d0f48..907f897 100644 (file)
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-var x = "string__NativeString__to_s_with_length"
+var x = "string__CString__to_s_with_length"
 
-var y = "string" + "__" + "NativeString" + "__" + "to_s_with_length"
+var y = "string" + "__" + "CString" + "__" + "to_s_with_length"
 
 var z = new FlatBuffer.from("string")
 z.append("__")
-z.append("NativeString")
+z.append("CString")
 z.append("__")
 z.append("to_s_with_length")
 
-var a = ["string", "NativeString", "to_s_with_length"].join("__")
+var a = ["string", "CString", "to_s_with_length"].join("__")
 
 print x.hash == y.hash
 print y.hash == z.hash
index 4a88e23..51d917b 100644 (file)
@@ -21,7 +21,7 @@ var cpstr: Text = src_s
 #alt2 cpstr = new FlatBuffer.from(src_s)
 #alt3 cpstr = cpstr.substring(1, 5)
 
-var ns = new NativeString(cpstr.byte_length)
+var ns = new CString(cpstr.byte_length)
 ns.fill_from(cpstr)
 
 print ns.to_s_with_length(cpstr.byte_length)
index 28facde..e6fee68 100644 (file)
@@ -12,7 +12,7 @@
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
-var s = new NativeString(4)
+var s = new CString(4)
 s[0] = 0x4Eu8
 s[2] = 0x74u8
 s[1] = 0x69u8
index 4b0964b..40f9579 100644 (file)
@@ -70,8 +70,8 @@ extern class TimeT `{time_t`}
 
        fun update `{ time(&self); `}
 
-       fun ctime: String import NativeString.to_s_with_copy `{
-               return NativeString_to_s_with_copy( ctime(&self) );
+       fun ctime: String import CString.to_s_with_copy `{
+               return CString_to_s_with_copy( ctime(&self) );
        `}
 
        # Difference in secondes from start (self if the end time)