summaryrefslogtreecommitdiffstats
path: root/tests/nonRegression/bug1812.sci
blob: 800dd60b9bb3c6c9ecc4be655ac0966b2f043c3d (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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// <-- Non-regression test for bug 1812 -->
//
// <-- Bugzilla URL -->
// http://www.scilab.org/cgi-bin/bugzilla_bug_II/show_bug.cgi?id=1812
//
// <-- Short Description -->
//    error in converting matlab || as && and other translator doubts

// Copyright INRIA
// Scilab Project - F. Belahcene

MFILECONTENTS=[
"m=3; a=5; b=2; c=3; d=6";
" ";
"if a==0 && b==2"; 
"m=2";
"end";
" ";
"if a==0 && b==2 && c==3 && d==4";
"m=2";
"end";
" ";
"if a==0 && b==2"; 
"m=2";
"end";
" ";
"if a==0 || b==2 || c==3 || d==4";
"m=2";
"end"
]

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

fd=mopen(MFILE,"w");
mputl(MFILECONTENTS,fd);
mclose(fd);

mfile2sci(MFILE,TMPDIR);

fd=mopen(SCIFILE,"r");
SCIFILECONTENTS=mgetl(fd,-1);
mclose(fd);

SCIFILECONTENTSREF=["";
"// Display mode";
"mode(0);";
"";
"// Display warning for floating point exception";
"ieee(1);";
"";
"m = 3;a = 5;b = 2;c = 3;d = 6";
"";
"%v02 = bool2s(%f);if bool2s(a==0) then %v02 = bool2s(b==2);end;";
"if %v02 then";
"  m = 2";
"end;";
"";
"%v02 = bool2s(%f);if bool2s(a==0) then %v02 = bool2s(b==2);end;%v12 = bool2s(%f);if %v02 then %v12 = bool2s(c==3);end;";
"if %v12&bool2s(d==4) then";
"  m = 2";
"end;";
"";
"%v02 = bool2s(%f);if bool2s(a==0) then %v02 = bool2s(b==2);end;";
"if %v02 then";
"  m = 2";
"end;";
"";
"%v02 = bool2s(%t);if ~bool2s(a==0) then %v02 = bool2s(b==2);end;%v12 = bool2s(%t);if ~%v02 then %v12 = bool2s(c==3);end;";
"if %v12|bool2s(d==4) then";
"  m = 2";
"end;";
]

correct=%T
if or(SCIFILECONTENTSREF<>SCIFILECONTENTS) then
  correct=%F
end

affich_result(correct,1812);