tests: improve (and rename) test_operators.nit
authorJean Privat <jean@pryen.org>
Thu, 23 Apr 2015 08:45:41 +0000 (15:45 +0700)
committerJean Privat <jean@pryen.org>
Fri, 24 Apr 2015 07:47:47 +0000 (14:47 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

tests/base_operators.nit [moved from tests/test_operators.nit with 75% similarity]
tests/sav/base_operators.res [new file with mode: 0644]
tests/sav/test_operators.res [deleted file]

similarity index 75%
rename from tests/test_operators.nit
rename to tests/base_operators.nit
index d828220..e993cc9 100644 (file)
@@ -1,7 +1,5 @@
 # This file is part of NIT ( http://www.nitlanguage.org ).
 #
-# Copyright 2004-2008 Jean Privat <jean@pryen.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
 # See the License for the specific language governing permissions and
 # limitations under the License.
 
+import standard::kernel
 
 class A
+   fun +: A
+   do
+          0.output
+          return self
+   end
    fun +(a: A): A
    do
           2.output
@@ -86,6 +90,31 @@ class A
           15.output
           return a
    end
+   fun **(a: A): A
+   do
+          16.output
+          return a
+   end
+   fun |(a: A): A
+   do
+          16.output
+          return a
+   end
+   fun ^(a: A): A
+   do
+          17.output
+          return a
+   end
+   fun &(a: A): A
+   do
+          18.output
+          return a
+   end
+   fun ~: A
+   do
+          19.output
+          return self
+   end
 
    init do end
 end
@@ -94,6 +123,21 @@ var a = new A
 var a2 = new A
 var b : Bool
 var i: Int
-a = a + -a - a * a / a % a >> a << a
+
+a = +a + -a - a * a / a % a >> a << a ** a | ~a ^ a & a
 b = a == a2 and a < a and a > a and a <= a and a >= a
 i = a <=> a
+
+'\n'.output
+
+a += a
+a -= a
+a *= a
+a /= a
+a %= a
+a **= a
+a <<= a
+a >>= a
+a |= a
+a ^= a
+a &= a
diff --git a/tests/sav/base_operators.res b/tests/sav/base_operators.res
new file mode 100644 (file)
index 0000000..9533fc2
--- /dev/null
@@ -0,0 +1,32 @@
+0
+1
+2
+3
+4
+5
+6
+15
+16
+14
+19
+18
+17
+16
+7
+9
+10
+11
+12
+13
+
+2
+6
+3
+4
+5
+16
+14
+15
+16
+17
+18
diff --git a/tests/sav/test_operators.res b/tests/sav/test_operators.res
deleted file mode 100644 (file)
index cf2273e..0000000
+++ /dev/null
@@ -1,14 +0,0 @@
-1
-2
-3
-4
-5
-6
-15
-14
-7
-9
-10
-11
-12
-13