* Bug #8687 fixed - typeof() function failed on uint8, depending on the format (...
[scilab.git] / scilab / modules / core / tests / unit_tests / typeof.dia.ref
1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2013 - Scilab Enterprises - Charlotte HECQUET
4 //
5 //  This file is distributed under the same license as the Scilab package.
6 // =============================================================================
7 //
8 // <-- TEST WITH GRAPHICS -->
9 // unit test for typeof()
10 // constant
11 assert_checkequal(typeof(1),"constant");
12 assert_checkequal(typeof([1,1]),"constant");
13 assert_checkequal(typeof([1;1]),"constant");
14 assert_checkequal(typeof([1,1;1,1]),"constant");
15 assert_checkequal(typeof([1+%i,1+%i;1,1]),"constant");
16 // polynomial
17 assert_checkequal(typeof(poly(0,"s")),"polynomial");
18 // boolean
19 assert_checkequal(typeof(%t),"boolean");
20 assert_checkequal(typeof([%t,%t;%f,%f]),"boolean");
21 assert_checkequal(typeof("s"=="s"),"boolean");
22 // sparse
23 assert_checkequal(typeof(sparse([0,1,0,1:1,0,1,0])),"sparse");
24 // boolean sparse
25 assert_checkequal(typeof(sparse([1,1;2,2;3,3],[%t,%t,%t])),"boolean sparse");
26 // Matlab sparse
27 X=sparse(rand(2,2)); Y=mtlb_sparse(X);
28 assert_checkequal(typeof(Y),"Matlab sparse");
29 // int
30 assert_checkequal(typeof(int8(1:4)),"int8");
31 assert_checkequal(typeof(uint8(1:4)),"uint8");
32 assert_checkequal(typeof(int16(1:4)),"int16");
33 assert_checkequal(typeof(uint16(1:4)),"uint16");
34 assert_checkequal(typeof(int32(1:4)),"int32");
35 assert_checkequal(typeof(uint32(1:4)),"uint32");
36 format("e");
37 assert_checkequal(typeof(uint8(1:4)),"uint8"); // bug 8687
38 format("v");
39 // handle
40 plot();
41 f=gcf();
42 assert_checkequal(typeof(f),"handle");
43 a=gca();
44 assert_checkequal(typeof(a),"handle");
45 e=gce();
46 assert_checkequal(typeof(e),"handle");
47 assert_checkequal(typeof(a.children(1)),"handle");
48 close
49 // string
50 assert_checkequal(typeof("s"),"string");
51 assert_checkequal(typeof("string"),"string");
52 assert_checkequal(typeof(["s","s"]),"string");
53 // function
54 deff('[x]=myplus(y,z)','x=y+z');
55 assert_checkequal(typeof(myplus),"function");
56 // library
57 assert_checkequal(typeof(elementary_functionslib),"library");
58 assert_checkequal(typeof(corelib),"library");
59 // pointer
60 a=rand(5,5);b=rand(5,1);A=sparse(a);
61 [h,rk]=lufact(A);
62 x=lusolve(h,b);a*x-b;
63 ludel(h);
64 assert_checkequal(typeof(h),"pointer");
65 // size implicit
66 assert_checkequal(typeof(1:1:$), "size implicit");
67 // list
68 assert_checkequal(typeof(list(1,2)),"list");
69 t = tlist(["listtype","field1","field2"], [], []);
70 assert_checkequal(typeof(t),t(1)(1));
71 M = mlist(['V','name','value'],['a','b','c'],[1 2 3]);
72 M1=getfield(1,M);
73 assert_checkequal(typeof(M),M1(1));
74 // rational, state-space
75 assert_checkequal(typeof(1/poly(0,"s")),"rational");
76 A=[0,1;0,0];B=[1;1];C=[1,1];
77 S1=syslin('c',A,B,C);
78 assert_checkequal(typeof(S1),"state-space");
79 S2=syslin('d',A,B,C);
80 assert_checkequal(typeof(S2),"state-space");
81 S3=syslin(1,A,B,C);
82 assert_checkequal(typeof(S3),"state-space");
83 assert_checkequal(typeof(tf2ss(1/poly(0,"s"))),"state-space");
84 // hypermat
85 assert_checkequal(typeof(hypermat([2 3 2 2],1:24)),"hypermat");
86 A=[1,2,3;4,5,6];
87 A(:,:,2)=[1,2,3;4,5,6];
88 assert_checkequal(typeof(A),"hypermat");
89 // fptr
90 assert_checkequal(typeof(abs),"fptr");
91 // cell
92 assert_checkequal(typeof(cell(3)),"ce");
93 //structure
94 assert_checkequal(typeof(struct('jour',25,'mois','DEC','annee',2006)),"st");