summaryrefslogtreecommitdiffstats
path: root/tests/nonRegression/bug2341.sci
blob: fb18e88cf5dd409defc9bd1c1eb29c052db2def8 (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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
// <-- Non-regression test for bug 2341 -->
//
// <-- Bugzilla URL -->
// http://www.scilab.org/cgi-bin/bugzilla_bug_II/show_bug.cgi?id=2341
//
// <-- Short Description -->
//    unhandled matlab syntax for lhs (Matlab accepts lhs calling sequence without commas

// Copyright INRIA
// Scilab Project - Vincent COUVERT

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

correct=%T;

// TEST1: no commas
MFILECONTENTS=["function [a b c d]=bug2341";
"a=1;b=2;c=3;d=4"]

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

ierr=execstr("mfile2sci("""+MFILE+""","""+TMPDIR+""")","errcatch")
correct=correct&ierr==0;

// TEST2: commas OK without spaces
MFILECONTENTS=["function [a,b,c,d]=bug2341";
"a=1;b=2;c=3;d=4"]

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

ierr=execstr("mfile2sci("""+MFILE+""","""+TMPDIR+""")","errcatch")
correct=correct&ierr==0;

// TEST3: commas OK with spaces before
MFILECONTENTS=["function [a  ,b ,c   ,d]=bug2341";
"a=1;b=2;c=3;d=4"]

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

ierr=execstr("mfile2sci("""+MFILE+""","""+TMPDIR+""")","errcatch")
correct=correct&ierr==0;

// TEST4: commas OK with spaces after
MFILECONTENTS=["function [a, b,  c,  d]=bug2341";
"a=1;b=2;c=3;d=4"]

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

ierr=execstr("mfile2sci("""+MFILE+""","""+TMPDIR+""")","errcatch")
correct=correct&ierr==0;

// TEST5: commas OK with spaces after and before
MFILECONTENTS=["function [a  , b,  c ,d]=bug2341";
"a=1;b=2;c=3;d=4"]

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

ierr=execstr("mfile2sci("""+MFILE+""","""+TMPDIR+""")","errcatch")
correct=correct&ierr==0;

// TEST6: commas OK or KO
MFILECONTENTS=["function [a   b,  c   d]=bug2341";
"a=1;b=2;c=3;d=4"]

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

ierr=execstr("mfile2sci("""+MFILE+""","""+TMPDIR+""")","errcatch")
correct=correct&ierr==0;

// TEST7: one output
MFILECONTENTS=["function [a]=bug2341";
"a=1;"]

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

ierr=execstr("mfile2sci("""+MFILE+""","""+TMPDIR+""")","errcatch")
correct=correct&ierr==0;

// TEST8: one output with blanks
MFILECONTENTS=["function [ a ]=bug2341";
"a=1;"]

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

ierr=execstr("mfile2sci("""+MFILE+""","""+TMPDIR+""")","errcatch")
correct=correct&ierr==0;

affich_result(correct,2341);