tests: update test_ffi_c_operators for << and >>
[nit.git] / tests / test_ffi_c_operators.nit
index 3174cb7..5261b5e 100644 (file)
@@ -1,6 +1,6 @@
 # This file is part of NIT ( http://www.nitlanguage.org ).
 #
-# Copyright 2011-2013 Alexis Laferrière <alexis.laf@xymus.net>
+# Copyright 2011-2014 Alexis Laferrière <alexis.laf@xymus.net>
 #
 # Licensed under the Apache License, Version 2.0 (the "License");
 # you may not use this file except in compliance with the License.
@@ -26,6 +26,11 @@ class A
                return new_A( s + o );
        `}
 
+       fun +: A import value, A `{
+               int s = A_value(recv);
+               return new_A(+s);
+       `}
+
        fun -( other : A ) : A import value, A `{
                int s = A_value( recv );
                int o = A_value( other );
@@ -33,6 +38,11 @@ class A
                return new_A( s - o );
        `}
 
+       fun -: A import value, A `{
+               int s = A_value(recv);
+               return new_A(-s);
+       `}
+
        fun *( by : Int ) : A import value, A `{
                int s = A_value( recv );
 
@@ -92,14 +102,16 @@ class A
                return A_value( recv ) <= A_value( other );
        `}
 
-       fun >>( other : A ) import value, value=, A `{
+       fun >>( other : A ): A import value, value=, A `{
                int new_val = A_value( recv ) >> A_value( other );
                A_value__assign( recv, new_val );
+               return recv;
        `}
 
-       fun <<( other : A ) import value, A `{
+       fun <<( other : A ): A import value, A `{
                int new_val = A_value( recv ) << A_value( other );
                A_value__assign( recv, new_val );
+               return recv;
        `}
 
        fun []( index : Int ) : A import A `{
@@ -144,13 +156,13 @@ print new A( 1 ) >= new A( 100 ) # false
 print new A( 100 ) >= new A( 100 ) # true
 print new A( 100 ) >= new A( 1 ) # true
 
-#var x = new A( 1 )
-#x << new A( 5 )
-#print x # 16
+var x = new A( 1 )
+x = x << new A( 5 )
+print x # 32
 
-#var y = new A( 32 )
-#y >> new A( 2 )
-#print y # 8
+var y = new A( 32 )
+y = y >> new A( 2 )
+print y # 8
 
 var a = new A( 456 )
 print a[ 52 ] # 52
@@ -158,3 +170,5 @@ print a[ 52 ] # 52
 a[ 74 ] = new A( 96 )
 print a # 96
 
+print(+(new A(123)))
+print(-(new A(123)))