summaryrefslogtreecommitdiffstats
path: root/tests/nonRegression/bug943.sci
blob: 0c8bbe85014ff3481d0cdf5e8b243248ef55ce36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// <-- Non-regression test for bug 943 -->
//
// <-- Bugzilla URL -->
// http://www.scilab.org/cgi-bin/bugzilla_bug_II/show_bug.cgi?id=943
//
// <-- Short Description -->
//    Conversion of (if, elseif, else) structure leads to 
//    mfile2sci failure in some particular indentation scheme.
//
//    Cyl_.m
//
//    function [v,G,J] = Cyl_(a,p1,p2,r)
//    v = (r^2)*abs(p2-p1)*pi;
//    l = p1-p2 ; d = 0.5*(p1+p2) ;
//    j1 = (r^2)/2. ; j2 = (r^2)/4. + (l^2)/12. + d^2 ;
//    if     (a==1), J = [j1,0.,0. ; 0.,j2,0. ; 0.,0.,j2] ; G = 
//    [0.5*(p1+p2);0.;0.] ;
//    elseif (a==2), J = [j2,0.,0. ; 0.,j1,0. ; 0.,0.,j2] ; G = 
//    [0.;0.5*(p1+p2);0.] ;
//    elseif (a==3), J = [j2,0.,0. ; 0.,j2,0. ; 0.,0.,j1] ; G = 
//    [0.;0.;0.5*(p1+p2)] ;
//    else, J = [0.,0.,0. ; 0.,0.,0. ; 0.,0.,0.] ; G = 
//    [0.;0.;0.] ; end,
//
//    Cyl2_.m
//
// ...

// Copyright INRIA
// Scilab Project - V. Couvert

// Modified by Pierre MARECHAL
// Copyright INRIA
// Date : 18 Mar 2005

MFILECONTENTS=["a=10;";
		"if     (a==1), J = [1 ; 2 ; 3] ; G = [4 ; 5 ; 6] ;";
		"elseif (a==2), J = [1 ; 2 ; 3] ; G = [4 ; 5 ; 6] ;";
		"elseif (a==3), J = [1 ; 2 ; 3] ; G = [4 ; 5 ; 6] ;";
		"else, J = [1 ; 2 ; 3] ; G = [4 ; 5 ; 6] ; end,"]

MFILE=TMPDIR+"/bug943.m"
SCIFILE=TMPDIR+"/bug943.sci"

mputl(MFILECONTENTS,MFILE);
mfile2sci(MFILE,TMPDIR);
SCIFILECONTENTS=mgetl(SCIFILE);

SCIFILECONTENTSREF=["";
		"// Display mode";
		"mode(0);";
		"";
		"// Display warning for floating point exception";
		"ieee(1);";
		"";
		"a = 10;";
		"if a==1 then J = [1;2;3]; G = [4;5;6];";
		"elseif a==2 then J = [1;2;3]; G = [4;5;6];";
		"elseif a==3 then J = [1;2;3]; G = [4;5;6];";
		"else J = [1;2;3]; G = [4;5;6];end;"]

if or(SCIFILECONTENTSREF<>SCIFILECONTENTS) then
	affich_result(%F,943);
else
	affich_result(%T,943);
end