summaryrefslogtreecommitdiffstats
path: root/tests/nonRegression/bug1262.sci
blob: 7e9d83ea8350e7d04fc3510d4109a6b135232bdd (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
81
82
83
84
85
86
// <-- Non-regression test for bug 1262 -->
//
// <-- Bugzilla URL -->
// http://www.scilab.org/cgi-bin/bugzilla_bug_II/show_bug.cgi?id=1262
//
// <-- Short Description -->
//    Four errors of mfile2sci are reported
//    (scilab-3.0-u-20050309) Linux+Windows+Solaris.
//
//    Briefly: 
//    1) end; end -> endend
//    2) Initialization to empty matrix at wrong place
//    3) Problem with useless [ or ]
//    4) -(A-B) -> -A-B
//
//    Apply mfile2sci to the Matlab script given below.

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

// Modified by Pierre MARECHAL
// Scilab Project
// 20 mai 2005

MFILECONTENTS=["A = rand(3,3);"
	""
	"for ii=1:3; for jj=1:3; disp(A(ii,jj)); end; end"
	""
	"k=0;"
	"for ii=1:3;"
	"   for jj=1:3;"
	"      if k>2 then"
	"         B(ii,jj) = A(ii,jj);"
	"         k = 0;"
	"      else"
	"         k = k+1;"
	"      end;"
	"  end;"
	"end;"
	""
	"C = [A [A [1;2;3]]];"
	""
	"B = -(A-A)"]

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

mputl(MFILECONTENTS,MFILE);

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


SCIFILECONTENTSREF=["";
	"// Display mode";
	"mode(0);";
	"";
	"// Display warning for floating point exception";
	"ieee(1);";
	"";
	"A = rand(3,3);"
	""
	"for ii = 1:3 for jj = 1:3 disp(A(ii,jj));end;end;"
	""
	"k = 0;"
	"for ii = 1:3"
	"  for jj = 1:3"
	"    if k>2 then"
	"      B(ii,jj) = A(ii,jj);"
	"      k = 0;"
	"    else"
	"      k = k+1;"
	"    end;"
	"  end;"
	"end;"
	""
	"C = [A,A,[1;2;3]];"
	""
	"B = -(A-A)"]

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

affich_result(correct,1262);