restore tests from operations module
[scilab.git] / scilab / modules / ast / tests / unit_tests / addition_output_type.tst
1 // ============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2014 - Scilab Enterprises - Antoine ELIAS
4 //
5 //  This file is distributed under the same license as the Scilab package.
6 // ============================================================================
7
8 // <-- JVM NOT MANDATORY -->
9
10 function ret = bool(b)
11     ret = (b == 1);
12 endfunction
13 types = list(int8, uint8, int16, uint16, int32, uint32, int64, uint64, double, bool);
14
15
16 ref =[  "int8","uint8","int16","uint16","int32","uint32","int64","uint64","int8","int8"; ...
17         "uint8","uint8","uint16","uint16","uint32","uint32","uint64","uint64","uint8","uint8"; ...
18         "int16","uint16","int16","uint16","int32","uint32","int64","uint64","int16","int16"; ...
19         "uint16","uint16","uint16","uint16","uint32","uint32","uint64","uint64","uint16","uint16"; ...
20         "int32","uint32","int32","uint32","int32","uint32","int64","uint64","int32","int32"; ...
21         "uint32","uint32","uint32","uint32","uint32","uint32","uint64","uint64","uint32","uint32"; ...
22         "int64","uint64","int64","uint64","int64","uint64","int64","uint64","int64","int64"; ...
23         "uint64","uint64","uint64","uint64","uint64","uint64","uint64","uint64","uint64","uint64"; ...
24         "int8","uint8","int16","uint16","int32","uint32","int64","uint64","constant","constant"; ...
25         "int8","uint8","int16","uint16","int32","uint32","int64","uint64","constant","boolean"]
26
27 typesize = size(types);
28
29 //Scalar + Scalar
30 for i = 1 : typesize
31     for j = 1 : typesize
32         ScalarScalarComputed(i,j) = typeof(types(i)(1) + types(j)(1));
33     end
34 end
35
36 assert_checkequal(ref, ScalarScalarComputed);
37
38 //Scalar + Matrix
39 for i = 1 : typesize
40     for j = 1 : typesize
41         ScalarMatrixComputed(i,j) = typeof(types(i)(1) + types(j)([1 2]));
42     end
43 end
44
45 assert_checkequal(ref, ScalarMatrixComputed);
46
47 //Matrix + Scalar
48 for i = 1 : typesize
49     for j = 1 : typesize
50         MatrixScalarComputed(i,j) = typeof(types(i)([1 2]) + types(j)(1));
51     end
52 end
53
54 assert_checkequal(ref, MatrixScalarComputed);
55
56 //Matrix + Matrix
57 for i = 1 : typesize
58     for j = 1 : typesize
59         MatrixMatrixComputed(i,j) = typeof(types(i)([1 2]) + types(j)([1 2]));
60     end
61 end
62
63 assert_checkequal(ref, MatrixMatrixComputed);