1 // =============================================================================
2 // Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3 // Copyright (C) 2010 - DIGITEO - Sylvestre LEDRU
5 // This file is distributed under the same license as the Scilab package.
6 // =============================================================================
7 // <-- ENGLISH IMPOSED -->
8 // <-- CLI SHELL MODE -->
9 // unit tests for structs
10 // =============================================================================
11 date_st=struct('jour',25,'mois','DEC','annee',2006);
12 if date_st.jour <> 25 then bugmes();quit;end
13 if date_st.mois <> 'DEC' then bugmes();quit;end
14 if date_st.annee <> 2006 then bugmes();quit;end
16 if date_st.jour <> 19 then bugmes();quit;end
18 if date_st.mois <> 'AOU' then bugmes();quit;end
20 if date_st.annee <> 1973 then bugmes();quit;end
22 if date_st.semaine <> 32 then bugmes();quit;end
23 // Example from bug #7244
30 if [1; 3; 2] <> foo then bugmes();quit;end
35 foo = foo([%T %F %T]);
37 if or([1; 3; 2] <> foo) then bugmes();quit;end
44 if foo(1).bar <> 1 then bugmes();quit;end
45 if foo(2).bar <> 3 then bugmes();quit;end
46 if foo(3).bar <> 2 then bugmes();quit;end
49 if size(out,'*') <> 1 then bugmes();quit;end
51 if or(size(out) <> [2 3]) then bugmes();quit;end
52 s=struct("txt","Hello","num",%pi,"pol",%z^2+1);
53 if s.pol <> %z^2+1 then bugmes();quit;end
54 if s.txt <> "Hello" then bugmes();quit;end
55 s.txt=null();s.num=null();s.pol=null();
56 if isfield( s , "txt" ) then bugmes();quit;end
57 if isfield( s , "num" ) then bugmes();quit;end
58 if isfield( s , "pol" ) then bugmes();quit;end
59 if or(isfield( s , ["pol", "num", "txt"] )) then bugmes();quit;end
60 if or(size(s) <> [1 1]) then bugmes();quit;end
68 if z.m.o.y.m.i.j.k.l.y <> 42 then bugmes();quit;end
69 if ~isfield(z.m.o.y.m.i.j.k.l,"y") then bugmes();quit;end
73 if z.z <> 21 then bugmes();quit;end
74 if z.b.c.z <> 21 then bugmes();quit;end
75 if ~isfield(z,"b") then bugmes();quit;end
76 if ~isfield(z.b,"c") then bugmes();quit;end
78 if execstr('z(42).x','errcatch')<>999 then bugmes();quit;end